diff --git a/pdf.c b/pdf.c
index 3e4cb376e526db0ad1aa8281fd26e6e23ed7b0e6..40223ec66a066ad2310fa8f2108d9a02c0ec46a8 100644
--- a/pdf.c
+++ b/pdf.c
@@ -1072,7 +1072,7 @@ ASCIIHexDecode(const Dict *parms, HBytes b, HParser *p)
 	H_ARULE(hupper,	h_ch_range('A', 'F'));
 	H_RULE(ahexeod,	h_ch('>'));
 	H_RULE(hdigit,	CHX(digit, hlower, hupper));
-	H_RULE(hdigitpair, h_middle(SEQ(lwchar),SEQ(hdigit,hdigit),SEQ(lwchar)));
+	H_RULE(hdigitpair, SEQ(h_many(CHX(lwchar,hdigit)),h_many(CHX(lwchar,hdigit))));
 	H_ARULE(ahextruncated, SEQ(hdigit,ahexeod));
 
 	H_RULE(hs_end, CHX(hdigitpair, ahextruncated));