Call Tools from JavaScript

This forum is for plugins used in the PDF-XChange Editor only.

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

Post Reply
kcd2015
User
Posts: 12
Joined: Tue Oct 11, 2016 6:55 pm

Call Tools from JavaScript

Post by kcd2015 »

From the JavaScript Console how would I activate the Line Tool with javascript? Or any of the tools for that matter?

My intent is to have a custom toolbar button and when the user clicks it will be prompted for a string value, I then need to set this string value as the subject property of the Line object and activate the line tool so the user can draw this line in the document.

I've already figured out how to create the custom toolbar function and get user input, I just need to figure out how to activate the line tool and manipulate it's properties.

pseudocode:

Code: Select all

var response = app.response({
	cQuestion: "What is the type?",
	cTitle: "Input Type",
	cLabel: "Type:"
});

newLine = Some_Call_That_Starts_Line_Tool;
newLine.subject = response;
something like that...??

[edit]

I've found that I can do this.addAnnot({type:'Line', etc...}); but this isn't ideal as I need the user to mouse click the start and end points of the lines.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19794
Joined: Mon Jan 12, 2009 8:07 am
Contact:

Re: Call Tools from JavaScript

Post by Stefan - PDF-XChange »

Hello kcd2015,

I am afraid that this is not possible with JS. You will need to use the Editor SDK to have control over the tools, and be able to activate them as needed:
https://www.pdf-xchange.com/produc ... editor-sdk

Regards,
Stefan
mhabubark
User
Posts: 1
Joined: Tue Aug 23, 2022 2:23 am

Re: Call Tools from JavaScript

Post by mhabubark »

Great! having the same issue with javascript but am able to solve by using Editor SDK. Thanks
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10891
Joined: Wed Jan 03, 2018 6:52 pm

Call Tools from JavaScript

Post by Daniel - PDF-XChange »

:)
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Post Reply