I am trying to use PdfStamper to add (overlay) a PDF file to a newly
generated pdf which has been created via parsing an XML document. I keep
getting an error on the stamp.close() line. Any ideas what I'm doing
wrong??

Here are the main bits of code:


       Document document = new Document(PageSize.A4, left, right, top,
bottom);
                PdfReader ccreader = new PdfReader("c:\\Overlay.pdf");

      String outputFilePath = "c:\\batchOutput\\finalLetter.pdf"
                FileOutputStream os = new FileOutputStream(outputFilePath);

       XmlParser.parse(document, "c:\\letter.xml, tagmap);

      //Attempt to read and stamp an image in the newly created PDF file
(generated from XML)
                PdfReader newdoc = new PdfReader(outputFilePath);
                PdfStamper stamp = new PdfStamper(newdoc, os);
//filejustcraeted

                PdfContentByte under = stamp.getUnderContent(1);
                PdfImportedPage page = stamp.getImportedPage(ccreader, 1);
                under.addTemplate(page, 1.0f, 0, 0, 1.0f, 0, 0);
                stamp.close();


The stack trace for the error is

java.io.IOException: The specified procedure could not be found.

      void java.io.FileOutputStream.writeBytes(byte[], int, int)
            native code
      void java.io.FileOutputStream.write(byte[], int, int)
            FileOutputStream.java:212
      void java.io.BufferedOutputStream.flushBuffer()
            BufferedOutputStream.java:72
      void java.io.BufferedOutputStream.write(byte[], int, int)
            BufferedOutputStream.java:116
      void com.lowagie.text.pdf.OutputStreamCounter.write(byte[], int, int)
      void
com.lowagie.text.pdf.PRStream.toPdf(com.lowagie.text.pdf.PdfWriter,
java.io.OutputStream)
      void
com.lowagie.text.pdf.PdfIndirectObject.writeTo(java.io.OutputStream)
      com.lowagie.text.pdf.PdfIndirectObject
com.lowagie.text.pdf.PdfWriter$PdfBody.add(com.lowagie.text.pdf.PdfObject,
com.lowagie.text.pdf.PdfIndirectReference)
      com.lowagie.text.pdf.PdfIndirectObject
com.lowagie.text.pdf.PdfWriter.addToBody(com.lowagie.text.pdf.PdfObject,
com.lowagie.text.pdf.PdfIndirectReference)
      void com.lowagie.text.pdf.PdfReaderInstance.writeAllPages()
      void com.lowagie.text.pdf.PdfWriter.addSharedObjectsToBody()
      void com.lowagie.text.pdf.PdfStamperImp.close(java.util.HashMap)
      void com.lowagie.text.pdf.PdfStamper.close()
      boolean gov.ons.alp.output.LetterImage.create(java.lang.String, int,
int, int, int)
            LetterImage.java:132
      void gov.ons.alp.output.LetterImage.main(java.lang.String[])
            LetterImage.java:160
The specified procedure could not be found.





For the latest data on the economy and society 
consult National Statistics at http://www.statistics.gov.uk

**********************************************************************
Please Note:  Incoming and outgoing email messages
are routinely monitored for compliance with our policy
on the use of electronic communications
**********************************************************************
Legal Disclaimer  :  Any views expressed by
the sender of this message are not necessarily
those of the Office for National Statistics
**********************************************************************

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to