I have an existing editable PDF which is not generated with i-text.
And I am reading the values from pdf and i have to make the editable columns
readonly.
here is my following snippet of code
PdfCopyFields copy = new PdfCopyFields(new
FileOutputStream("C:\\Sample.pdf"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader, baos);
AcroFields acroFields = stamper.getAcroFields();
PRAcroForm acroForm = reader.getAcroForm();
for(FieldInformation info :acroForm.getFields()){
acroFields.setFieldProperty(info.getName(), "clrfflags",
PdfFormField.FF_READ_ONLY, null);
acroFields.setFieldProperty(info.getName(), "setfflags",
PdfFormField.FF_READ_ONLY, null);
acroFields.regenerateField(info.getName());
}
copy.addDocument(new PdfReader(reader.getPageContent(0)));
copy.close();
and i get this following error
Exception in thread "main" java.io.EOFException
at
com.itextpdf.text.pdf.RandomAccessFileOrArray.readFully(RandomAccessFileOrArray.java:287)
at
com.itextpdf.text.pdf.RandomAccessFileOrArray.readFully(RandomAccessFileOrArray.java:279)
at
com.itextpdf.text.pdf.PdfReader.getStreamBytesRaw(PdfReader.java:2297)
at com.itextpdf.text.pdf.PdfReader.getStreamBytes(PdfReader.java:2263)
at com.itextpdf.text.pdf.PdfReader.getPageContent(PdfReader.java:2033)
at com.itextpdf.text.pdf.PdfReader.getPageContent(PdfReader.java:2123)
help me in fixing this.
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/Make-existing-PDF-readonly-tp4660534.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
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