diff --git a/pdf.c b/pdf.c
index 23cf121c93cbf2f07d6ddd74150de47f6180baf8..e4ba283315c0ce81c76bf2a1a3cbc04a2226e02e 100644
--- a/pdf.c
+++ b/pdf.c
@@ -667,10 +667,11 @@ init_parser(struct Env *aux)
 		// NB: lws before xref offset is allowed, cf. p.48 (example 4)
 	H_RULE(xr_td,	SEQ(xrefs, KW("trailer"), ws, dict));
 
+	H_RULE(junk,    h_many1(h_butnot(h_ch_range(0, 255), objdef)));
 	H_RULE(tail,	SEQ(body, h_optional(xr_td), startxr));
 		// XXX the real world likes to omit 'startxr' from all but the
 		// last trailer. we should accept-and-warn in that case.
-	H_RULE(pdf,	SEQ(header, h_many1(tail), end));
+	H_RULE(pdf,	SEQ(header, OPT(junk), h_many1(tail), end));
 
 	/* debug parser to consume as much as possible */
 	H_RULE(pdfdbg,	SEQ(header, h_many(tail), body, OPT(xr_td), OPT(startxr)));