Empty indirect objects in PDF generated by convert
Posted: 2013-01-23T11:05:56-07:00
Sometimes convert produces a PDF that contains a totally empty PDF indirect object like
13 0 obj
endobj
It happens, for example, on converting a JPG image to PDF. (Here the PDF simply acts as a wrapper around the JPG bytes. Rendering the PDF shows the image on a single paged document.)
Most PDF readers accept such documents, yet this is not valid syntax. As per PDF spec:
"The definition of an indirect object in a PDF file consists of its object number and generation number, followed by the value of the object bracketed between the keywords obj and endobj"
The above syntax does not enclose anything that resembles a PDF object. I'm not even sure if the indirect object is ever referenced inside the PDF (e.g., by means of a 13 0 R construct). Since the object seems useless anyway, this is a second good reason not to produce it.
13 0 obj
endobj
It happens, for example, on converting a JPG image to PDF. (Here the PDF simply acts as a wrapper around the JPG bytes. Rendering the PDF shows the image on a single paged document.)
Most PDF readers accept such documents, yet this is not valid syntax. As per PDF spec:
"The definition of an indirect object in a PDF file consists of its object number and generation number, followed by the value of the object bracketed between the keywords obj and endobj"
The above syntax does not enclose anything that resembles a PDF object. I'm not even sure if the indirect object is ever referenced inside the PDF (e.g., by means of a 13 0 R construct). Since the object seems useless anyway, this is a second good reason not to produce it.