Hi All,
I am facing a problem where Layers from the source pdf documents are lost(or
not retained in the result) when the source pdfs are concatenated using the
below code.
The source PDF pages do contain a non printable Image layer filling the
entire page and various Acro form fields with data populated.
Result of the below code is that the concatenated pages do not have the
image in a non-printable layer (its coming out as a regular image pdf ) and
so when printing the result pdf, image is also getting printed. I am trying
not to print the image. I also tried setting the image as a non-printable
background in the source files but my concatenation code resulted the same
output and ended up printing the image.
Can anyone please suggest how to work around this problem of retaining the
layers which concatenating?
===========================================================================================================================
*public ByteArrayOutputStream
concatenatePdfPageStreams(List<ByteArrayOutputStream > pageList) throws
DocumentException{*
**
* ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
*
* Document document = new Document();*
* PdfCopy copy = new PdfCopy(document, outputStream);*
* document.open();*
**
* for(ByteArrayOutputStream page: pageList){*
* PdfReader reader = new PdfReader(page.toByteArray());*
* PdfStamper stamper = new PdfStamper(reader, outputStream);*
* PdfImportedPage importedPage =
stamper.getImportedPage(reader, 1); // I think this is the place where the
layer information is lost or probably flattened - I am not sure*
* Map<String, PdfLayer> layersMap = stamper.getPdfLayers(); //
I did debug and inspect the value of layersMap at this breakpoint and I do
see the non-printable image layer*
* copy.addPage(importedPage);*
* copy.freeReader(reader); *
* reader.close();*
* }*
* document.close();*
**
* return outputStream; // this concatenated pdf stream do not have
any layers*
**
*}*
===========================================================================================================================
Any help/suggestion is really appreciated.
--
Thank you and Best Regards.
Jaya.
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php