Outlines are handled differently in PdfCopy. See com.lowagie.tools.concat_pdf.java. If you wanr to add new outlines or manipulate the existing one see the javadocs for SimpleOutline.
Best Regards, Paulo Soares > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Matthias Ludwig > Sent: Tuesday, April 27, 2004 7:47 PM > To: [EMAIL PROTECTED] > Subject: [iText-questions] Create outline while merging > documents with Pdf-Copy > > Hi > > > first of all thanks to the develeloppers of iText. It's a > very comfortable > framework. > > I'm struggling with the following problem: I'd like to add an > Outline tree to > a document, while concatanating it with PdfCopy. > > I possibly found a bug. As my knowledge of iText internal is > very poor, I'm > not shure about that. > > > Here's the simpliefied code: > > > .... > PdfImportedPage page; > document.newPage(); > for (int i = 0; i < n;) > { > ++i; > page = writer.getImportedPage(reader, i); > writer.addPage(page); > > PdfDestination destination = new > PdfDestination(PdfDestination.FITB); > writer.getDirectContent().localDestination("Page " + > String.valueOf > (i),destination); > > PdfOutline outline = new PdfOutline(writer.getDirectContent > ().getRootOutline(),destination,"Page " + String.valueOf(i)); > } > ... > > The code always traps in the following > IllegalArgumentException, now matter if > I place the call to localDestination before or after the call > to addPage. > Here is the iText-code-snippet of PdfCopy > > > public PdfIndirectReference getPageReference(int page) { > if (page < 0 || page > pageNumbersToRefs.size()) > throw new IllegalArgumentException("Invalid page number > " + page); > return (PdfIndirectReference)pageNumbersToRefs.get(page - 1); > } > > > I see the following reasons: > > call to localDestination before addPage > page = currentPage = 1 (1 based) the size of the collection is 0, > -> thus page > pageNumbersToRefs.size() > -> exception > > call to localDestination after addPage > addPage increment both pageNumbersToRefs.size() and page > -> thus page = currentPage = 2 and pageNumbersToRefs.size() = 1 > -> exception > > > I've overwritten the method getCurrentPage of PdfWriter > > PdfIndirectReference getCurrentPage() { > return getPageReference(currentPageNumber); > } > > with the following code > PdfIndirectReference getCurrentPage() { > return getPageReference(currentPageNumber-1); > } > > and all worked fine. > > As I mentioned, I'not very into iText interals. Therefor I > can't assess if > this is the correct way to solve this problem. > I would be pleased, if someone more competent, would have a > look at it. > > Thanks, > > Matthias > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... > Oracle 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions > > ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id�66&op=click _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
