Hi

I am using iTextSharp to try to mix a MS Word generated PDF file with a 
hyperlinked table of contents with other PDF files and ensure that the 
hyperlinks in the original Word table of contents still work. When you take out 
a page which the Word table of contents went to, you can see you get a null 
link in the final PDF file.

I did get this to work by examining the PDF pages which I know contain the 
table of contents, looking for “/Links” which have a “null” dest and then 
adding a PdfAction.GotoLocalPage. The trouble is that it is really only 
guessing (e.g. the first null link is probably the first file I inserted, the 
second null link is probably the second file, etc). It works but only if every 
table of contents entry is on single line... if a Word table of contents entry 
is split over more than one line then each line is a separate link in the PDF 
file. So a long entry in a table of contents translates as several links, 
voiding the guesswork. 

Examining the final PDF file, the null table of contents links appear like this:
  21 0 obj
  <</F 4/Subtype/Link/BS<</W 0>>/Dest[null/XYZ 62 777 0]/StructParent 
13/Rect[62.65 176.77 542.82 190.57]>>
  endobj
  22 0 obj
  <</F 4/Subtype/Link/BS<</W 0>>/Dest[null/XYZ 62 777 0]/StructParent 
14/Rect[62.65 162.97 539.5 176.77]>>
  endobj
As far as I can see, there is no easy way of telling if that is two distinct 
table of contents entries or just one split over two lines. 

So I am now wondering if it possible to kind of ‘fake’ a page reference (which 
I hope makes sense). I can get the page reference I want of a page from the 
original Word saved PDF file, I can see it using 
MsgBox(reader.GetPageOrigRef(topage).ToString) and this gives a reference such 
as “31 0 R”

A working link from a Word table of contents in a PDF file looks like this:
  11 0 obj
  <</F 4/Subtype/Link/BS<</W 0>>/Dest[31 0 R/XYZ 62 777 0]/StructParent 
3/Rect[91 314.76 539.5 328.56]>>
  endobj
So what I want to do is to take out that page “31 0 R” from the Word generated 
PDF file, insert a new PDF file at that location but ensure the link still 
works.  Is there any way to edit the page reference on the first page of the 
file I am inserting and change it to “31 0 R”? So rather than GetPageOrigRef, 
it would be something like SetPageRef. Or maybe by manipulating the dictionary 
for the inserted file?

Many thanks (hope this e-mail isn’t too hard to follow)

Jay

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to