diff --git a/pdf.c b/pdf.c
index e4ba283315c0ce81c76bf2a1a3cbc04a2226e02e..df57b4dae5700290a208f83158a029701309413e 100644
--- a/pdf.c
+++ b/pdf.c
@@ -656,13 +656,13 @@ init_parser(struct Env *aux)
 	/* trailer */
 	H_RULE(startxr,	SEQ(nl, KW("startxref"), nl,
 			    lws, nat, nl,
-			    LIT("%%EOF"), CHX(nl, end)));
 		// XXX the real world sometimes omits nl after %%EOF inside the file.
 		//     the next 'tail' would be appended right after the 'F',
 		//     presumably because the previous version of the file
 		//     ended without a trailing newline. m)
 		//     this is invalid per spec, because it creates a run-on 
 		//     comment, but we should probably accept-and-warn.
+			    LIT("%%EOF"), CHX(h_many(nl), end)));
 		// XXX should lws be allowed before EOF marker?
 		// NB: lws before xref offset is allowed, cf. p.48 (example 4)
 	H_RULE(xr_td,	SEQ(xrefs, KW("trailer"), ws, dict));