You are posting two questions.
1 - iTextSharp doesn't produce docs with errors in XREF tables or
elsewhere. If it does, please provide a small standalone program so that
the problem can be reproduced.
2 - Bookmarks are built outside the source docs and added before closing
the final doc. See the example below.
String[] inFile = new String[]{"c:\\doc1.pdf", "c:\\doc2.pdf",
"c:\\doc3.pdf"};
int pageOffset = 0;
ArrayList master = new ArrayList();
int f = 0;
String outFile = "c:\\PdfCopyOut_cs.pdf";
Document document = null;
PdfCopy copy = null;
while (f < inFile.Length) {
// we create a reader for a certain document
PdfReader reader = new PdfReader(inFile[f]);
reader.ConsolidateNamedDestinations();
// we retrieve the total number of pages
int n = reader.NumberOfPages;
ArrayList bookmarks = SimpleBookmark.GetBookmark(reader);
if (bookmarks != null) {
if (pageOffset != 0)
SimpleBookmark.ShiftPageNumbers(bookmarks, pageOffset,
null);
master.AddRange(bookmarks);
}
pageOffset += n;
if (f == 0) {
// step 1: creation of a document-object
document = new Document();
// step 2: we create a copy that listens to the document
copy = new PdfCopy(document, new FileStream(outFile,
FileMode.Create));
// step 3: we open the document
document.Open();
}
// step 4: we add content
PdfImportedPage page;
for (int i = 0; i < n; ) {
++i;
page = copy.GetImportedPage(reader, i);
copy.AddPage(page);
}
copy.FreeReader(reader);
f++;
}
if (master.Count > 0)
copy.Outlines = master;
// step 5: we close the document
document.Close();
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Mark Flagg
> Sent: Monday, May 05, 2008 11:56 AM
> To: itext-questions@lists.sourceforge.net
> Subject: [iText-questions] Bookmarks in merged PDF document
>
> Hi,
>
>
>
> I have created a document from three separate documents.
> These are Title, Table Of Contents (TOC) and Body. The
> document is generated correctly but when opened in my reader
> (PDF-Xchange Viewer) there are no bookmarks and there is a
> warning that there are errors in the XREF table. Adobe
> Acrobat 8 also shows there are no bookmarks. If I look at the
> individual 3 documents they have bookmarks except for my TOC document.
>
>
>
> I am using PDFCopy for doing the merging and I am using
> iTextSharp v4.1.0.0.
>
>
>
> My question is how do I get the final document to show
> bookmarks correctly? I have looked through all the previous
> posts on this topic and I cannot find a clear answer.
>
>
>
> Many thanks
>
>
>
> Mark.
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar