pdf

The PDF file starts with the header %pdf. Can a valid pdf file have more than 1 such headers?


The PDF file starts with the header %pdf. Can a valid pdf file have more than 1 such headers? The Pdf specification says that it can have more than 1 trailers. But it does not talk about multiple headers. Can it have multiple headers?


Solution

  • It can have as many as you want, since the symbol % is used to represent comments inside a PDF file, so it's not actually a "header".

    From the PDF specification:

    7.2.3 Comments

    Any occurrence of the PERCENT SIGN (25h) outside a string or stream introduces a comment. The comment consists of all characters after the PERCENT SIGN and up to but not including the end of the line, including regular, delimiter, SPACE (20h), and HORZONTAL TAB characters (09h). A conforming reader shall ignore comments, and treat them as single white-space characters. That is, a comment separates the token preceding it from the one following it.

    EXAMPLE:

    The PDF fragment in this example is syntactically equivalent to just the tokens abc and 123. abc% comment ( /%) blah blah blah 123