Maybe reading what the exception says would help... 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Fernando Otero
> Sent: Thursday, March 31, 2005 3:38 PM
> To: [email protected]
> Subject: [iText-questions] reorderPages problem
> 
> 
> HI
> 
> I'm trying to make a Table of Contents for a PDF. The 
> following code works
> for 10 pages, but I can´t figure out why when I add one more page
> I get the following exception:
> 
> com.lowagie.text.DocumentException: Page reordering requires 
> a single parent
> in the page tree. Call PdfWriter.setLinearMode() after open.
>       at com.lowagie.text.pdf.PdfPages.reorderPages(PdfPages.java:187)
>       at 
> com.lowagie.text.pdf.PdfWriter.reorderPages(PdfWriter.java:2005)
>       at com.zeos.utils.PDFWriter.write(PDFWriter.java:183)
> ...
> 
> 
> ===============MY CODE=======================
> int totalPages = writer.getPageNumber();
> doc.resetPageCount();
> doc.setPageCount(0);
> doc.setFooter(null);
> doc.add(toc);
> 
> doc.newPage();
> int tocpages = writer.getPageNumber();
> totalPages += tocpages;
> int[] order = new int[totalPages];
> for(int i=0;i<totalPages;i++){
>       if(i==0)
>               order[i]=i+1;
>       else{
>               if(i<tocpages)
>                       order[i] = totalPages-i+1;
>               else
>                       order[i] = (i-tocpages+1)+1;
>       }
>       System.out.print(order[i]+" ");
> }
> 
> writer.reorderPages(order); <- LINE 183
> =============================================
> 
> The Console shows:
> 1 11 2 3 4 5 6 7 8 9 10 
> 
> If I comment my code everything works ok, but I get the TOC 
> on the last page
> and I want it to be on the second page (that's why I reorder 
> the pages).
> 
> 
> Any ideas?
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by Demarc:
> A global provider of Threat Management Solutions.
> Download our HomeAdmin security software for free today!
> http://www.demarc.com/Info/Sentarus/hamr30
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 


-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/Info/Sentarus/hamr30
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to