Here we are interested to collect the annotations on pages which
contains Goto page actions, using some readers,
And possibly, modify these annotations using a writer when page order
had been modified.
I was using
public ArrayList GetLinks(int page)
which in turn calls
internal PdfImportedLink(PdfDictionary annotation) {
parameters = (Hashtable)annotation.hashMap.Clone();
try {
destination = (PdfArray)parameters[PdfName.DEST];
parameters.Remove(PdfName.DEST);
}
I tested it with pdfs created with Acrobat 4 and Acrobat 8, and
destination is always null !!!
According to the PDF reference, there is no DEST parameter for a link
but there is an indirect reference to an Action[] dictionnary, which in
turn might contains a DEST.
So, trying to keep the same logic, I changed the beginning of this
routine for :
(I pass the reader because I need tor resolve the indirect
reference !)
internal PdfImportedLink(PdfDictionary annotation,PdfReader
reader) {
parameters = (Hashtable)annotation.hashMap.Clone();
try {
PRIndirectReference xref =
(PRIndirectReference)annotation.Get(PdfName.A);
PdfDictionary LinkActionDICT =
(PdfDictionary)reader.GetPdfObject(xref.Number);
destination =
(PdfArray)PdfReader.GetPdfObject(LinkActionDICT.Get(PdfName.D));
parameters.Remove(PdfName.A); //this is not
satisfactory, because A might contain multiple actions. But for my
sample, only one A
}
Later in CreateAnnotation, the following line does nothing
if (destination != null) annotation.Put(PdfName.DEST,
destination);
I changed it for
if (destination != null)
{
PdfAction action = new PdfAction();
action.Put(PdfName.S, PdfName.GOTO);
action.Put(PdfName.D, destination);
annotation.Put(PdfName.A, action);
}
But unfortunately, I still end up with a null in the refered page
destination
8 0 obj<</D[null/FitH 795]/S/GoTo>>
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/