Take the 2-minute tour ×

I'm looking for a grammar of PDF 1.7 (BNF or variant)

absolutely not googleable

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

PDF is a binary format. Most binary formats are not context-free, and PDF is no exception. In PDF for example you need to read and interpret the size of a binary stream before parsing the stream. BNF can only be used for context-free grammars, so there is no such thing as a BNF grammar for PDF.

Take a look at the specification here: PDF Reference Document

share|improve this answer
Binary does not imply it can't have a grammar. If you look at the PDF spec, you will see that pretty much all constructs are 'printable', except binary literals (streams). Some people must have written a PDF parser, so my guess is there must be a grammar around... –  3dGrabber Jun 13 '12 at 14:19
@3D-Grabber: yms didn't say 'Binary files can't have a grammar.' What he said was more of 'Context-free formats can't have a BNF grammar.' –  Kurt Pfeifle Jun 13 '12 at 16:35
@pipitas: 'Binary files can't have a grammar.' That's basically what he said before he edited the answer and clarified. I get the point now. –  3dGrabber Jun 14 '12 at 6:25
@3D-Grabber: Ok, I didn't notice the editing history of the answer. Sorry. –  Kurt Pfeifle Jun 14 '12 at 7:35
add comment

I am not aware of any formal specification of the PDF file format in the form of a grammar, BNF or not.

But I happen to know for sure that the ISO technical committee 171/SC2 which currently works on the specification of PDF-2.0 has an agenda topic of "Updates from ad hoc committees: [...] iv. File format syntax for validating PDF files (L. Rosenthol)" for its next face to face meeting taking place in Berlin, Sept 11-12 2012. -- Which agenda item I take as "some more people seem to be interested in a more formal description of the PDF syntax"... :-)

Leonard Rosenthol is an Adobe PDF higher-up, and he frequently answers questions in the Adobe user forums. Maybe it is a good idea to ask a question there? Chances are, there you'll get a better answer than here.

share|improve this answer
add comment

Your Answer


