IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#38709 - 03/05/12 11:28 PM PDF indexing / Chaptering
Wing Offline
OL Newbie

Registered: 09/20/10
Posts: 11
Hi,

I want to know can PlanetPress Image generate Index / TOC to let user click the index then directly go to the specify page?

Say, I want to generate a report for over 800 page per day, it contains 5 section. And the first page is TOC with these 5 section's header at the beginning of the file. When I clicked the section link, it will directly go to the section start page.

I know there may be some programming work but I want to know is that possible or not.

Please help.

Thank you

Top
#38711 - 03/06/12 11:09 AM Re: PDF indexing / Chaptering [Re: Wing]
Pages
Unregistered


Hi,

You will need to use what is called PDF Marks. This will allow you to create "bookmarks" inside your document and as such, have a fully functional index to your document.

Here is a reference link for PDF Marks :

http://partners.adobe.com/public/develop...rkReference.pdf

Please note that PDF Marks are outside of our support scope. There is no support offered for PDF Marks.

Hope this helps.
Regards,

Top
#38712 - 03/06/12 11:15 AM Re: PDF indexing / Chaptering [Re: Wing]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1984
Loc: Objectif Lune, Montreal, Qc
Wing,

To create a hyperlink that jumps to a specific page, you would need to create the following global function in your document:
Code:
function @PDFJumpToPage(&pagenumber: integer, &caption: string, &fontheight: measure)
  define(&currX,measure,&current.x)
  gsave()
  setstyleext(&internal.defaultfont,&fontheight,1,[100,100,0,0],-1)
  passthrough('[/Subtype /Link')
  passthrough('/Rect [ '+floattostr(&current.x*72)+' '+floattostr(&current.y-(&fontheight*2/3))+ ' ' + floattostr((&current.x+stringwidth(&caption))*72) + ' ' +  floattostr(&current.y+(&fontheight/3))+']')
  passthrough('/Border [ 0 0 0]')
  passthrough('/Page ' + inttostr(&pagenumber))
  passthrough('/View [/XYZ 0 '+floattostr(&current.pageheight*72)+' null]')
  passthrough('/ANN pdfmark')
  show(&caption)
  grestore()
  rmoveto(stringwidth(&caption),0)
endfunction()

Then, whenever you want to display a link that jumps to a specific page, you add a new PlanetPress Talk Object containing code similar to this:
Code:
@PDFJumpToPage(3,'Goto Page 3',12)

Where the first parameter is the page to jump to, the second parameter is the caption for the link, and the third parameter is the size of the font to use for displaying the link.

However, that won't address what - in my humble opinion - your real issues are: how to know on which page each of the sections begin? And then, how to add that information back to the TOC, which is usually found at the start of the document?

I have to admit having to perform a bit of research for that one, I had never tried it before. Well, it happens to be pretty simple after all! You will need to use Named Destinations within the document, instead of absolute page numbers. And you'll need to create a global function similar to the one above, but that references those Named Destinations instead.

Here's the code for the global function:
Code:
function @PDFJumpToDest(&Destname: string, &caption: string, &fontheight: measure)
  define(&currX,measure,&current.x)
  gsave()
  setstyleext(&internal.defaultfont,&fontheight,1,[100,100,0,0],-1)
  passthrough('[/Subtype /Link')
  passthrough('/Rect [ '+floattostr(&current.x*72)+' '+floattostr(&current.y-(&fontheight*2/3))+ ' ' + floattostr((&current.x+stringwidth(&caption))*72) + ' ' +  floattostr(&current.y+(&fontheight/3))+']')
  passthrough('/Border [ 0 0 0]')
  passthrough('/Dest /' + &Destname)
  passthrough('/View [/XYZ 0 '+floattostr(&current.pageheight*72)+' null]')
  passthrough('/ANN pdfmark')
  show(&caption)
  grestore()
  rmoveto(stringwidth(&caption),0)
endfunction()

Where the first parameter is the actual name of the destination, and the others are just like for the very first function above. Be careful: that name is case-sensitive, so you'll have to use the exact same name when you want to jump to it.

So let's say you already know your document will have 5 sections. You can create links on the very first page by creating 5 PlanetPress Talk Objects. They would contain something like:
Code:
%First PPTalk object
@PDFJumpToDest('MySection1','Goto Section 1',12)
...
%Second PPTalk object
@PDFJumpToDest('MySection2','Goto Section 2',12)
...
...
%Fifth PPTalk object
@PDFJumpToDest('MySection5','Goto Section 5',12)


Now all that's left is for you to actually create those named destinations as the job is being processed. I am assuming that you have some way of knowing when a new section begins, and which section it happens to be. Let's say, for instance, that you have a condition named IsNewSection which allows you to test if you are now entering a new section, and another variable named CurrentSection that you increment every time you move to the next section.

In a PlanetPress Talk object on the physical page that begins the section, you would therefore add the following code in the PlanetPress Tak Before section of its properties:
Code:
if(&IsNewSection)
  passthrough('[/Dest /MySection' + inttostr(&CurrentSection))
  passthrough(' /DEST pdfmark')
  &CurrentSection := &CurrentSection+1
endif()


Note how we are appending the current value stored in CurrentSection to the named destination /MySection (yielding, in the end, MySection1, MySection2, etc.)

Now, if you do all of this (and assuming there aren't too many typos in the code I posted...), you should be able to jump anywhere in your document.

Have fun!
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top