Our application uses iText 5 to populate a PDF form and write out the populated
form to disk. The code is roughly:
Document document = new Document();
copy = new PdfCopy(document, new FileOutputStream(newFileName));
document.open();
PdfReader reader = new PdfReader(formFileName);
reader = new PdfReader(formFileName);
// need this snippet of code in order to partially flatten XFA form
//
http://www.mail-archive.com/itext-questions@lists.sourceforge.net/msg39051.html
PdfDictionary acro =
(PdfDictionary)PdfReader.getPdfObject(reader.getCatalog().get(PdfName.ACROFORM));
if(acro != null) {
acro.remove(new PdfName("XFA"));
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader, baos);
AcroFields form = stamper.getAcroFields();
form.setField(fieldName, fieldValue);
...
stamper.close();
Occasionally, calling stamper.close() results in the following
FileNotFoundException:
java.io.FileNotFoundException: .\forms\UtilityBilling\SelfMtrUtilBill.pdf (The
system cannot find the path specified)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(Unknown Source)
at java.io.RandomAccessFile.<init>(Unknown Source)
at com.itextpdf.text.pdf.RandomAccessFileOrArray.openForPlainRandomAccess(
RandomAccessFileOrArray.java:172)
at com.itextpdf.text.pdf.RandomAccessFileOrArray.openFile(
RandomAccessFileOrArray.java:148)
at com.itextpdf.text.pdf.RandomAccessFileOrArray.reOpen(
RandomAccessFileOrArray.java:334)
at com.itextpdf.text.pdf.PdfReader.getStreamBytesRaw(PdfReader.java:2347)
at com.itextpdf.text.pdf.PRStream.toPdf(PRStream.java:215)
at com.itextpdf.text.pdf.PdfIndirectObject.writeTo(PdfIndirectObject.java:157)
at com.itextpdf.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java:391)
at com.itextpdf.text.pdf.PdfWriter.addToBody(PdfWriter.java:844)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:356)
at com.itextpdf.text.pdf.PdfStamperImp.close(PdfStamperImp.java:328)
at com.itextpdf.text.pdf.PdfStamper.close(PdfStamper.java:189)
Anybody else experience this?
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
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