diff --git a/pdf.c b/pdf.c
index bd029edfd05893c5a32d3e9f090763aa9431e214..7df5565dc10cbfd709e9c269e5c4b4ad6512eda0 100644
--- a/pdf.c
+++ b/pdf.c
@@ -273,7 +273,7 @@ pdf_parser(void)
 
 	/* streams */
 	H_RULE(stmbeg,	SEQ(dict, KW("stream"), OPT(cr), lf));
-	H_RULE(stmend,	SEQ(eol, KW("endstream")));
+	H_RULE(stmend,	SEQ(OPT(eol), LIT("endstream")));
 	H_ARULE(stream,	h_left(h_bind(stmbeg, kstream, NULL), stmend));
 		// XXX is whitespace allowed between the eol and "endstream"?