PdfStamperImp enhancements for keeping the integrity of the original PDF
- From: "Paulo Soares" <psoares (at) consiste.pt>
- Date: Thu, 9 Feb 2006 15:23:34 -0000
Use PdfStamper.insertPage()
> -----Original Message-----
> From: itext-questions-admin (at) lists.sourceforge.net
> [mailto:itext-questions-admin (at) lists.sourceforge.net] On
> Behalf Of Tenesi
> Sent: Thursday, February 09, 2006 3:15 PM
> To: itext-questions (at) lists.sourceforge.net
> Subject: Re: [iText-questions] PdfStamperImp enhancements for
> keeping the integrity of the original PDF
>
>
> Thanks for the prompt good news.
>
> Would you please let me know what is wrong with this snippet
> and What would be the right approach to do it?
>
>
> FileOutputStream os= new FileOutputStream("final.pdf"); // The target
> com.lowagie.text.pdf.PdfReader baseR = new
> com.lowagie.text.pdf.PdfReader("base.pdf"); // The base file
> com.lowagie.text.pdf.PdfStamper update = new
> com.lowagie.text.pdf.PdfStamper(baseR, os, '\0',true); // An
> stamper prepared for incremental changes
>
> com.lowagie.text.pdf.PdfWriter stamperImp
> =update.getWriter(); // The corresponding writer of the appender
>
> //XXX: Add new page?
>
> stamperImp.setPageEmpty(false);
> stamperImp.newPage();
>
> //Fetch the new page from the additions
> com.lowagie.text.pdf.PdfReader reader2 = new
> com.lowagie.text.pdf.PdfReader("additions.pdf");
> com.lowagie.text.pdf.PdfImporte
> dPage ipage= stamperImp.getImportedPage(reader2,1);
>
> //XXX:Get the under layer to add the imprtedpage into the new
> page in target?
> // A getUnderContent(baseR.getNumberOfPages()+1) on the
> PdfStamper itself will not help as the newPage is not
> counted properly
>
> com.lowagie.text.pdf.PdfContentByte under =
> stamperImp.getDirectContentUnder();
>
> /*Add the page now this operation throws:
> java.lang.NullPointerException at
> com.lowagie.text.pdf.PdfContentByte.addTemplate(PdfContentByte
> .java:1898) under.addTemplate(ipage, 1, 0, 0, 1, 0, 0);*/
>
> //commit the updates
> update.close();
> os.close();
>
> Thanks again for your help in advance and best regards
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
iText-questions mailing list
iText-questions (at) lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions