Drawing lines using X 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

KD952
User
Posts: 109
Joined: Mon Feb 13, 2023 6:13 am

Drawing lines using X Y coordinates

Post by KD952 »

Hello!

I could not find any tool to draw lines using X Y coordinates, so I wrote this tool:

drawLineXY.zip

If there is anything better out there, please point me in the right direction. Thanks!

Disclaimer:
I don't know how to code.

Limitations:
  • For some reason does not work when there are no annotations in the document because I cannot get this part to work:

Code: Select all

var annots = this.getAnnots({nPage: this.pageNum,nSortBy: ANSB_ModDate});     // get all annots of current page and sort them

if (annots[0].type == "Line") {}
else if ( (annots[0].type != "Line") || (annots == null) ){}
Thanks for your input!

Kind regards,
Daniel
You do not have the required permissions to view the files attached to this post.
KD952
User
Posts: 109
Joined: Mon Feb 13, 2023 6:13 am

Re: Drawing lines using X Y coordinates

Post by KD952 »

Hello!

Maybe a little bit more information how it works:

  • If the last placed annotation is of the type "Line" the tool stats with the endpoint of this line as origin.
  • If the last placed annotation is not of type "Line" you get to set a new origin
Kind regards,
Daniel
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19883
Joined: Mon Jan 12, 2009 8:07 am

Re: Drawing lines using X Y coordinates

Post by Stefan - PDF-XChange »

Hello Daniel,

Thanks for doing the tool and sharing it with everyone else!
You are correct that there isn't really a way to create a line by specifying it's coordinates in the UI.

Kind regards,
Stefan
KD952
User
Posts: 109
Joined: Mon Feb 13, 2023 6:13 am

Re: Drawing lines using X Y coordinates

Post by KD952 »

Hello!

Figured it out. :D
Now works as intended.
drawLineXY_V02.zip
Kind regards,
Daniel
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19883
Joined: Mon Jan 12, 2009 8:07 am

Re: Drawing lines using X Y coordinates

Post by Stefan - PDF-XChange »

Hello Daniel,

Apologies - I missed that there was an enquiry in your initial post!
Happy to hear you've figured it out now!

Kind regards,
Stefan