Page 1 of 1

Javascript examples and autocompletion

Posted: Fri May 18, 2018 6:49 am
by sashu
Hello,

I was wondering if there are documented JavaScript examples in the PDF Editor. I was also wondering if I could use the autocompletion function in the JavaScript console or somewhere else. It makes life of a developer very much easier and long manuals even obsolete if autocompletion shows members and properties of a class and such stuff.

Best, sashu

Re: Javascript examples and autocompletion

Posted: Fri May 18, 2018 11:35 am
by Tracker Supp-Stefan
Hello Sashu,

Before I answer the question - can you please tell me if you are a developer or an end user trying to e.g. create a form with some JS?
Also - you seem to have posted in the wrong forums. Please let me know where the correct place is for this topic and I will move it accordingly.

Regards,
Stefan

Re: Javascript examples and autocompletion

Posted: Fri May 18, 2018 11:57 am
by sashu
Hello Stefan,

I am an end user that is interested in exploring the full spectrum of PDF-Xchange editor.

Best, sashu

Re: Javascript examples and autocompletion

Posted: Fri May 18, 2018 5:16 pm
by TrackerSupp-Daniel
Hello Sashu,
I have moved this topic into the Appropriate (PDF-XChange Editor) Forums.

I am sorry to say that to my knowledge there is no autocomplete functionality available in the built in JS function.
As for examples and long manuals:
I do not have much at the moment, just the base utilities I've nicked off my colleagues for JS examples, but here is my little (two item) Repository of them.

Code: Select all

//Reorder pages:
//Reorders Pages A1, B1, A2, B2, A3, B3...

for (i = 0; i < ((this.numPages - 1)/2); i++) 
{
  this.movePage(Math.ceil(this.numPages/2)+i,2*i);
}



//Reverse page numbering:
// Change file ext. to .js. Then save to C:\Program Files\Tracker Software\PDF Editor\JavaScripts

function ReversePageOrder()
{
   for (i = this.numPages - 1; i >= 0; i--) this.movePage(i);
}

app.addToolButton({
    cName: "Reverse Page Order",
    cExec: "ReversePageOrder()",
    cTooltext: "Reverse pages",
    cEnable: true,
    nPos: 0
});
As for long manuals!
https://www.adobe.com/content/dam/acom/ ... erence.pdf
Yes this is the Adobe JS API reference, we thankfully use the same calls as they do (its a compatibility thing). The only limitation I am aware of at this moment is that we cannot use calls with the security tag from this manual, yet.

Re: Javascript examples and autocompletion

Posted: Wed May 30, 2018 1:00 pm
by sashu
Great, thanks, Daniel. I was reading the pdf and saw the class EventListener (page 386) that probably listens for different events such as Open. Does every Pdf-Viewer support an event cycle and an event can be catched by the JS code?

Best, sashu

Re: Javascript examples and autocompletion

Posted: Wed May 30, 2018 2:08 pm
by Will - Tracker Supp
Hi Sashu,

It's not likely that every single one will, but I suspect that all of the major readers should (e.g. Adobe)

Re: Javascript examples and autocompletion

Posted: Wed May 30, 2018 2:33 pm
by sashu
Do you know how I overload an event handler or where to store JS in PDF? I am a real newbie in these matters.
Will - Tracker Supp wrote:Hi Sashu,

It's not likely that every single one will, but I suspect that all of the major readers should (e.g. Adobe)

Re: Javascript examples and autocompletion

Posted: Wed May 30, 2018 3:18 pm
by Will - Tracker Supp
Hi Sashu,

That really depends on how you want to use the JS and what you're doing. For example, you can apply specific JS actions to specific form fields; you can run an app/doc. wide script through the JS panel (Ctrl + J, or you can add a script to the document via the Document Properties (Ctrl + D --> Actions or Ctrl + D --> JavaScript).

Cheers,

Re: Javascript examples and autocompletion

Posted: Wed May 30, 2018 3:42 pm
by sashu
Thanks, Will, nice to know. I don't have a specific goal. Yet. Just wanted to know how I would develop a JS script that performs certain actions when a PDF is opened.

CU, Alexander

Re: Javascript examples and autocompletion

Posted: Wed May 30, 2018 3:55 pm
by Tracker Supp-Stefan
:D

Re: Javascript examples and autocompletion

Posted: Tue Jul 24, 2018 3:55 pm
by daniel_lutz
I would like to support this feature. I use the editor as end user , but i am also an developer so autocomplete support would be very nice to script some litte stuff in the console. I know there is an api document for this from Adobe but autocomplete invites you to try and explore things, but reading such a api document does not.

Best regards

Daniel

Re: Javascript examples and autocompletion

Posted: Tue Jul 24, 2018 4:08 pm
by Tracker Supp-Stefan
Hello Daniel,

Thanks for adding your vote! I am sure it will be taken into account when considering this feature!

Cheers,
Stefan