how to use javascript to highlight specific words

The PDF-XChange Viewer for End Users
+++ FREE +++

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

clcheung
User
Posts: 2
Joined: Mon Feb 11, 2013 8:40 am

how to use javascript to highlight specific words

Post by clcheung »

Hi

I have two questions would like to ask for your help.

Question 1:
I use the runjs option to execute a javascript file. I am able to open it, move to specific page.
I would like to highlight certain words on that page, like the effect of do a search on a particular word. How can I do it ?

==
Some more background:

The javascript file is like this:
var otherDoc = app.openDoc(file1);
otherDoc.pageNum=10;

The reason I use javascript "openDoc" , but not calling through command line, is that I have hit another problem of unicode file name handling. It seems PDF-XChange Viewer can only open those document with file name corresponding to the supported code page of the Windows 7 system. I have some documents with Traditional Chinese file name, and some documents with Simplified Chinese file name. They are of different code page. Although I can manually open them in PDF-XChange Viewer, I am not able to control it from a program. Since my system is Traditional Chinese, I am only able to open document with Traditional Chinese file name through programs.

The problem is complicated so I better stop it here. Now I am in final stage, my program generates a javascript file on demand, and call PDF-XChange Viewer to execute the javascript file, to open pdf files with whatever code page file name.
==

Question 2:
And, if I use runjs to call the javascript file, I have the document opened but the keyboard focus is not set to PDF-XChange Viewer. Any idea to pop the PDF-XChange Viewer to front and grab the keyboard focus ?
If the program call PDF-XChange Viewer through command line, the keyboard focus is always go to PDF-XChange Viewer after the document opened.

Thanks a lot.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19930
Joined: Mon Jan 12, 2009 8:07 am

Re: how to use javascript to highlight specific words

Post by Stefan - PDF-XChange »

Hello clcheung,

Please take a look at this document:
http://www.adobe.com/content/dam/Adobe/ ... erence.pdf
for a full list of JS methods. Our Viewer will support around 95% of those.

Without using our SDK products however I believe that the best you could do is to use the "highlight" annotation method through JS to highlight you desired words - but then those highlights can be saved inside the document by the user that would be viewing the file in our Viewer.

I am not sure how you can resolve 2)

In any case - I would recommend you to take a look at our Viewer AX SDK:
https://www.pdf-xchange.com/product/pdf ... ctivex-sdk
As you can then directly embed our Viewer in your own application and have much more control over it!

Best,
Stefan
clcheung
User
Posts: 2
Joined: Mon Feb 11, 2013 8:40 am

Re: how to use javascript to highlight specific words

Post by clcheung »

Stefan

Thanks a lot for the prompt reply.
I could not figure out the command that can do it in that adobe document.

I will try out your suggested method but it seems not work I want as I don't want to change the document.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19930
Joined: Mon Jan 12, 2009 8:07 am

Re: how to use javascript to highlight specific words

Post by Stefan - PDF-XChange »

Hi clcheung,

Please take a look at "Annotations. Highlight" on page 46 in the document.
Yes - this will modify it - and if you want to properly work with it, and have full control - you will need to use the Viewer AX SDK linked above.

Best,
Stefan