Edit the source of a pdf file and it corrupts the pdf (could not be opened)

88 views Asked by At

Open up a PDF file from a text editor, I would like to modify the content of this object below:

759 0 obj ($Revision:: 1.0 $) endobj 774 0 obj

from ($Revision:: 1.0 $) to ($Revision::20171219200322$), i.e. the total size of the object increased by 2 characters.

However, this change breaks the PDF.

How does that happen? I'm guessing there is somewhere else in the PDF that relies on the size of the obj.

could someone shed some light on it?

Much appreciated

===================UPDATE==================

Thanks for the comments below.

I tried to look for the xref table throughout the pdf file, but only found something like this:

... endobj startxref 116666 %%EOF

at the bottom of the file. There's no actual table there. Any idea?

Thanks for the help.

===================UPDATE 22/12/2017 ==================

Now I was able to find the AcroFields that's need to be modified using iText. However, I don't want to use AcroFields.setField(String name, String value) method to set the field value, I would like to modify the value of PdfString object that this field is referring to. I was able to get the object by calling PdfReader.getPdfObject(item.getMerged(0).get(PdfName.DV)) which gives me a PdfString Object, but I couldn't find a way to change the value of it. Any idea?

0

There are 0 answers