How to copy "X" and "Y" coordinates?

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

anton121
User
Posts: 13
Joined: Tue Feb 14, 2023 4:54 am

How to copy "X" and "Y" coordinates?

Post by anton121 »

Hi all.
Who know how can i copy to buffer X and Y coordinates? Like CTRL+C. (See the picture)
Thnx.
You do not have the required permissions to view the files attached to this post.
Willy Van Nuffel
User
Posts: 2771
Joined: Wed Jan 18, 2006 12:10 pm

Re: How to copy "X" and "Y" coordinates?

Post by Willy Van Nuffel »

The coordinates that you can see at the bottom of your screen are the coordinates of the mouse-pointer.

If you like to see the coordinates of a selected object (Text, Image, Shape, Comment, ...) then you can better use the Transform Selection dialog-box, available in the Home-ribbon > Selection > Transfer Selection.

In the raster you can select the point for which you like to see the coordinates (left upper corner, middle of the top line, ...).
The X-coordinate is the distance towards the left border of the page.
The Y-coordinate is the distance towards the bottom of the page.

Does that help ?
You do not have the required permissions to view the files attached to this post.
anton121
User
Posts: 13
Joined: Tue Feb 14, 2023 4:54 am

Re: How to copy "X" and "Y" coordinates?

Post by anton121 »

Willy Van Nuffel wrote: Tue Feb 14, 2023 9:05 am The coordinates that you can see at the bottom of your screen are the coordinates of the mouse-pointer.

If you like to see the coordinates of a selected object (Text, Image, Shape, Comment, ...) then you can better use the Transfer Selection dialog-box, available in the Home-ribbon > Selection > Transfer Selection.

In the raster you can select the point for which you like to see the coordinates (left upper corner, middle of the top line, ...).
The X-coordinate is the distance towards the left border of the page.
The Y-coordinate is the distance towards the bottom of the page.

Does that help ?
Sorry, but no. I need to copy cursor position, X and Y coordinates on the page (not coordinate object, text or comment), in the buffer, for paste this coordinate in excel or word.
Willy Van Nuffel
User
Posts: 2771
Joined: Wed Jan 18, 2006 12:10 pm

Re: How to copy "X" and "Y" coordinates?

Post by Willy Van Nuffel »

For as far as I know, it is not possible to copy the coordinates of the cursor position in PDF-XChange Editor.

@Tracker Support
Maybe this is an item for a feature request ?
anton121
User
Posts: 13
Joined: Tue Feb 14, 2023 4:54 am

Re: How to copy "X" and "Y" coordinates?

Post by anton121 »

Willy Van Nuffel wrote: Tue Feb 14, 2023 11:45 am For as far as I know, it is not possible to copy the coordinates of the cursor position in PDF-XChange Editor.

@Tracker Support
Maybe this is an item for a feature request ?
I thought JavaScript can.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: How to copy "X" and "Y" coordinates?

Post by Stefan - PDF-XChange »

Hello anton121,

I presume you not just need the coordinated but would need to do something else with them after?
You can indeed capture the coordinates of the mouse with JS:

Code: Select all

function getMouseCoor() {
console.println( "("+this.mouseX+","+ this.mouseY+")" );
}
var ckMouse = app.setInterval("getMouseCoor()", 100); var timeout = app.setTimeOut(
"app.clearInterval(ckMouse); app.clearTimeOut(timeout)",2000);

Kind regards,
Stefan
anton121
User
Posts: 13
Joined: Tue Feb 14, 2023 4:54 am

Re: How to copy "X" and "Y" coordinates?

Post by anton121 »

Tracker Supp-Stefan wrote: Tue Feb 14, 2023 2:25 pm Hello anton121,

I presume you not just need the coordinated but would need to do something else with them after?
You can indeed capture the coordinates of the mouse with JS:

Code: Select all

function getMouseCoor() {
console.println( "("+this.mouseX+","+ this.mouseY+")" );
}
var ckMouse = app.setInterval("getMouseCoor()", 100); var timeout = app.setTimeOut(
"app.clearInterval(ckMouse); app.clearTimeOut(timeout)",2000);

Kind regards,
Stefan
Thnx! But, what i do wrong?After left/r click nothing...
If have some way, to copy coordinates to buffer ( set some key CTRL+C+B for example) will be nice :)
scriptimage.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: How to copy "X" and "Y" coordinates?

Post by Stefan - PDF-XChange »

Hello anton121,

There's no such way to copy the mouse coordinates.
Why do you need those?
What is the next step for which you will need those stored?
I presume that if you need these for a different application you will have to write them down while the mouse cursor is at the desired coordinates. (E.g. you can open a notepad window with just the keyboard, so that the mouse location stays the same.)

Kind regards,
Stefan
anton121
User
Posts: 13
Joined: Tue Feb 14, 2023 4:54 am

Re: How to copy "X" and "Y" coordinates?

Post by anton121 »

Tracker Supp-Stefan wrote: Tue Feb 14, 2023 3:14 pm Hello anton121,

There's no such way to copy the mouse coordinates.
Why do you need those?
What is the next step for which you will need those stored?
I presume that if you need these for a different application you will have to write them down while the mouse cursor is at the desired coordinates. (E.g. you can open a notepad window with just the keyboard, so that the mouse location stays the same.)

Kind regards,
Stefan
I need only get cursor coordinate X and Y, then i past them in word or excel. If They will be in console - good.
scriptimage.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: How to copy "X" and "Y" coordinates?

Post by Stefan - PDF-XChange »

Hello anton121,

Actually I think I managed to get the JS console capture the desired result!
So - if you want a value in mm rounded to two decimal places - please open the JS console in the Editor (Ctrl + J ) and then paste this in there:

Code: Select all

console.println( "("+(this.mouseX/2.83464566929133).toFixed(2)+","+ (this.mouseY/2.83464566929133).toFixed(2)+")" );
Then move your mouse to the coordinates you want to measure without clicking , and hit Ctrl + Enter. This will execute the code in the JS console, and you will then receive your coordinates in the output of the JS console like this:
image.png
I've deliberately captured part of the Editor window - where you can compare the coordinates reported by the Editor itself are the same (rounded to 1 decimal place) as the output in the console. If you want 1 decimal place precision - just change the 2 to 1 in .toFixed(1).

Kind regards,
Stefan
You do not have the required permissions to view the files attached to this post.
anton121
User
Posts: 13
Joined: Tue Feb 14, 2023 4:54 am

Re: How to copy "X" and "Y" coordinates?

Post by anton121 »

Tracker Supp-Stefan wrote: Tue Feb 14, 2023 4:54 pm Hello anton121,

Actually I think I managed to get the JS console capture the desired result!
So - if you want a value in mm rounded to two decimal places - please open the JS console in the Editor (Ctrl + J ) and then paste this in there:

Code: Select all

console.println( "("+(this.mouseX/2.83464566929133).toFixed(2)+","+ (this.mouseY/2.83464566929133).toFixed(2)+")" );
Then move your mouse to the coordinates you want to measure without clicking , and hit Ctrl + Enter. This will execute the code in the JS console, and you will then receive your coordinates in the output of the JS console like this:
image.png

I've deliberately captured part of the Editor window - where you can compare the coordinates reported by the Editor itself are the same (rounded to 1 decimal place) as the output in the console. If you want 1 decimal place precision - just change the 2 to 1 in .toFixed(1).

Kind regards,
Stefan
Big thnx! I think is what i need. But i dont know why script not done - just nothing write in console. may be i need istall something to mi PC...
anton121
User
Posts: 13
Joined: Tue Feb 14, 2023 4:54 am

Re: How to copy "X" and "Y" coordinates?

Post by anton121 »

Tracker Supp-Stefan wrote: Tue Feb 14, 2023 4:54 pm Hello anton121,

Actually I think I managed to get the JS console capture the desired result!
So - if you want a value in mm rounded to two decimal places - please open the JS console in the Editor (Ctrl + J ) and then paste this in there:

Code: Select all

console.println( "("+(this.mouseX/2.83464566929133).toFixed(2)+","+ (this.mouseY/2.83464566929133).toFixed(2)+")" );
Then move your mouse to the coordinates you want to measure without clicking , and hit Ctrl + Enter. This will execute the code in the JS console, and you will then receive your coordinates in the output of the JS console like this:
image.png

I've deliberately captured part of the Editor window - where you can compare the coordinates reported by the Editor itself are the same (rounded to 1 decimal place) as the output in the console. If you want 1 decimal place precision - just change the 2 to 1 in .toFixed(1).

Kind regards,
Stefan
All good, install newest version :) THNX!
Now will try get PT coordinates
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: How to copy "X" and "Y" coordinates?

Post by Stefan - PDF-XChange »

Hello anton121,

Actually - my above code will not work correctly for pages that have been rotated, or where the media box does not match the crop box.
This updated code should correct that:

Code: Select all

m = (new Matrix2D).fromRotated(this, this.pageNum);
	mInv = m.invert();
	pt = mInv.transform([this.mouseX, this.mouseY]);
	var pt2mm = 25.4 / 72.0;
	console.println("X=" + pt[0] * pt2mm + ", Y=" + pt[1] * pt2mm);
Kind regards,
Stefan
User avatar
PHK
User
Posts: 1456
Joined: Tue Nov 24, 2020 4:02 pm

Re: How to copy "X" and "Y" coordinates?

Post by PHK »

Crude solution?

Take a screenshot of the Page Measurement box.

I know it's dirty but it's also quick.
All best,

FringePhil
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7388
Joined: Wed Mar 25, 2009 10:37 pm

Re: How to copy "X" and "Y" coordinates?

Post by Paul - PDF-XChange »

Great suggestion Phil, though that would produce an image and it would need to be run through OCR to make it text to copy/paste.

:)
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
User avatar
PHK
User
Posts: 1456
Joined: Tue Nov 24, 2020 4:02 pm

Re: How to copy "X" and "Y" coordinates?

Post by PHK »

Paul - Tracker Supp wrote: Thu Feb 16, 2023 3:23 pm ... it would need to be run through OCR to make it text to copy/paste.
....
Or, heaven forbid, you read the digits and actually type them in...
All best,

FringePhil
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

How to copy "X" and "Y" coordinates?

Post by Stefan - PDF-XChange »

:)
anton121
User
Posts: 13
Joined: Tue Feb 14, 2023 4:54 am

Re: How to copy "X" and "Y" coordinates?

Post by anton121 »

Tracker Supp-Stefan wrote: Wed Feb 15, 2023 9:12 am Hello anton121,

Actually - my above code will not work correctly for pages that have been rotated, or where the media box does not match the crop box.
This updated code should correct that:

Code: Select all

m = (new Matrix2D).fromRotated(this, this.pageNum);
	mInv = m.invert();
	pt = mInv.transform([this.mouseX, this.mouseY]);
	var pt2mm = 25.4 / 72.0;
	console.println("X=" + pt[0] * pt2mm + ", Y=" + pt[1] * pt2mm);
Kind regards,
Stefan
Hello!
I use this code to equal range:
scaled_value = low_2 + (high_2 - low_2) * (value - low) / (high - low)
and final code:
console.clear()
console.println( (4901.91+(739.97-4901.91)*(this.mouseY-0)/(4161.9-0)).toFixed(1)+";"+(2384+(345.17-2384)*(this.mouseX-0)/(2038.8-0)).toFixed(1));

All work :) Big thnx

Now i try to find the way copy console result in buffer, if i can - ALT+ENTER, then CTRL+V and done :)
I find many functions:
1) util.setClipboardText(copiedText);
2) copyToClipboard(Text).
3) navigator.clipboard.writeText(Text);
But i cand use it, becouce program say " cant find this function"....
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: How to copy "X" and "Y" coordinates?

Post by Stefan - PDF-XChange »

Hello anton121,

Those might be general JS methods, but they are in deed not supported inside PDF files (likely for security reasons).
In this file:
JavaScript for Acrobat API Reference
there is no mention of clipboard at all!

Kind regards,
Stefan
anton121
User
Posts: 13
Joined: Tue Feb 14, 2023 4:54 am

Re: How to copy "X" and "Y" coordinates?

Post by anton121 »

Tracker Supp-Stefan wrote: Mon Feb 20, 2023 3:37 pm Hello anton121,

Those might be general JS methods, but they are in deed not supported inside PDF files (likely for security reasons).
In this file:
[url=https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/pdfs/acrobatsdk_jsapiref.pdf]JavaScript for Acrobat API Reference[/url]
there is no mention of clipboard at all!

Kind regards,
Stefan
Its sad.... if i hame some values in console...why i cant copy them...)
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: How to copy "X" and "Y" coordinates?

Post by Stefan - PDF-XChange »

Hello anton121,

The issue here is that you want to "write" those values to the clipboard, and that is the operation that is not available for JS code inside PDF files.

Kind regards,
Stefan
User avatar
rakunavi
User
Posts: 1826
Joined: Sat Sep 11, 2021 5:04 am

Re: How to copy "X" and "Y" coordinates?

Post by rakunavi »

Hello anton121 and Stefan,

It might be useful to assign the function to copy the output on JavaScript Console to the clipboard to a specific key with autohotkey. In the verification video, after launching Free Clipboard Viewer and preparing to display the clipboard contents in real time, I moved the focus to JavaScript Console and pressed shortcut key F10 while moving the mouse.

  • CapturedVideoWithSample.zip

    sample.png

Code: Select all

F10::
WinActivate, JavaScript Console ahk_exe PDFXEdit.exe
Send, !{Enter}+{Up}^c
return
Tracker Supp-Stefan wrote: Tue Feb 21, 2023 12:27 pm The issue here is that you want to "write" those values to the clipboard, and that is the operation that is not available for JS code inside PDF files.
On a different note, many people are struggling with how to get variables and data out of JavaScript because of the security restrictions that Stefan has pointed out.

  • https://stackoverflow.com/questions/13760440/write-text-file-using-acrobat-javascript
If you register the variables you want to output from JavaScript in the document information (e.g., keywords, author, subject), you could access them from autohotkey script. Specifically, first set the following script to be executed before saving in the action of the document property.

Code: Select all

this.info.Keywords = Variable_A;
this.info.Author = Variable_B;
this.info.Subject = Variable_C;
Next, retrieve the variables with the autohotkey script as shown below.

Code: Select all

DocumentInfo_Keywords := FileGetInfo("Document.pdf", 18, 1)
DocumentInfo_Author := FileGetInfo("Document.pdf", 20, 1)
DocumentInfo_Subject := FileGetInfo("Document.pdf", 22, 1)
  • FileGetInfo() is introduced at the following URL.
    https://www.autohotkey.com/boards/viewtopic.php?t=983
The application is quite limited since the PDF must be saved once, but it is convenient since the file properties can be easily accessed in any programming language.

Best regards,
rakunavi
You do not have the required permissions to view the files attached to this post.
TOP desires for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: How to copy "X" and "Y" coordinates?

Post by Stefan - PDF-XChange »

Hello rakunavi,

Many thanks for the above! I am not using AutoHotkey personally, but I presume it is of great help for anyone who needs it!

Kind regards,
Stefan