Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript: search, navigate, extract

Status
Not open for further replies.

tgreer

Programmer
Oct 4, 2002
1,781
US
I have a collection of documents where I'd like to extract a page range to a new PDF. The page range is dynamic and is based on text on the page.

I'm a PostScript guy and have done a lot with PDF internals, but not with Acrobat itself.

Looking through the documentation, I see:

Code:
search.query

as a method. It works, returning a list of the pages containing my target text. So far so good.

I also see

Code:
doc.extractPages

which works as well.

What I'd like is direction as to how to put all of them together, so that I can

1) search for pages containing a text string
2) enumerate through those pages, retrieving and calculating page numbers (this.pageNum?)
3) use those page numbers to extract page ranges.

For example, assume that a section starts with the word "New Section". A search would reveal that I have "New Section" pages on pages 5, 10, and 12. I would like pages 5-9 extracted to a named PDF, pages 10 & 11 to a second PDF, and pages 12 through last page into a 3rd PDF.

I don't need someone to write the program for me, just point me to the appropriate methods, etc.

Currently I can't figure out how to use the search.query results to navigate/retrieve those specific pages.


Thomas D. Greer
 
tgreer, if it's with Adobe 5 and VB or C++ here's the steps.

Create the object,
Code:
AcroExch.AVDoc
call the method
Code:
.GetAVPageView
which has a function
Code:
.Goto()
to get to an exact page, if you know which pages to go to.

Code:
CAcroAVDoc.FindText method is used to find text within a PDF, FindText(szText As String, bCaseSensitive As Long, bWholeWordsOnly As Long, bReset As Long) As Long
.

I'm not familuar with
Code:
search.query
I found it referenced in the API document but I haven't been able to use it in the VB IDE. I have only been able to use the
Code:
.FindText
method.

I also can't find how to use the
Code:
ExtractPages
method, my only solution would be to write an app that searches for all of the pages you want and store them in an array. And them start deleting the unnecesary pages. By invoking the
Code:
CAcroPDDoc.DeletePages
method, which takes a starting and ending page.

If you or anyone else can tell me where to find the method/function for extract pages that would be great.


Did any of this help?

Craig
 
Thanks for the reply. No, it didn't help. I want to do this as a Document Level JavaScript within Acrobat.

I've learned that, believe it or not, Adobe designed the Search Object/Query method so that it would NOT provide the programmer a result set!

Let's hope they don't start designing calculators without equal keys, cars without ignitions and the like!

Thomas D. Greer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top