test 2 & 3

main
Matthew Butterick 6 years ago
parent c489c007ff
commit f090fd0748

@ -78,7 +78,8 @@
["\\s+" (parse-1 ip)] ; whitespace
["\\d+ 0 obj" (parse-1 ip)] ;; obj name
["\\d+ 0 R"] ; xref
["[-]?\\d+"] ; number
["[-]?\\d*\\.\\d+"] ; real
["[-]?\\d+\\.?"] ; integer
["\\(.*?\\)"] ; parenstring
["/\\S+"] ; keystring
[else eof])]))
@ -107,11 +108,24 @@
(cons idx (parse-pdf-bytes (peek-bytes (- end start) start)))))
< #:key car))
(define (dict-compare d1 d2)
(and (dict? d1) (dict? d2)
(= (length d1) (length d2))
(for/and ([(k1 v1) (in-dict d1)]
[(k2 v2) (in-dict d2)])
(unless (equal? k1 k2)
(error (format "keys unequal: ~a ~a" k1 k2)))
(unless (equal? v1 v2)
(error (format "values unequal: ~a ~a" v1 v2)))
(when (dict? v1)
(dict-compare v1 v2))
#true)))
(define-simple-check (check-pdfs-equal? ps1 ps2)
(equal? (pdf->dict ps1) (pdf->dict ps2)))
(dict-compare (pdf->dict ps1) (pdf->dict ps2)))
#;(module+ main
(for ([p (in-directory)]
#:when (path-has-extension? p #"pdf"))
(with-handlers ([exn:fail? (λ (exn) (println (format "~a failed" p)))])
(pdf->dict p))))
(for ([p (in-directory)]
#:when (path-has-extension? p #"pdf"))
(with-handlers ([exn:fail? (λ (exn) (println (format "~a failed" p)))])
(pdf->dict p))))

@ -119,7 +119,7 @@ endobj
<<
/Producer (PDFKit)
/Creator (PDFKit)
/CreationDate (D:20170519210839Z)
/CreationDate (D:20181120221301Z)
>>
endobj
2 0 obj

Binary file not shown.

Binary file not shown.

@ -0,0 +1,158 @@
%PDF-1.3
%ÿÿÿÿ
6 0 obj
<<
/ca 0.8
/Type /ExtGState
>>
endobj
7 0 obj
<<
/ca 1
/Type /ExtGState
>>
endobj
8 0 obj
<<
/CA 1
/Type /ExtGState
>>
endobj
5 0 obj
<<
/Resources 4 0 R
/Contents 3 0 R
/MediaBox [0 0 612 792]
/Type /Page
/Parent 1 0 R
>>
endobj
4 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/ExtGState <<
/Gs3 8 0 R
/Gs2 7 0 R
/Gs1 6 0 R
>>
>>
endobj
3 0 obj
<<
/Length 890
>>
stream
1 0 0 -1 0 792 cm
0 20 m
100 160 l
130 200 150 120 v
190 -40 200 200 300 150 c
400 90 l
S
1 0 0 1 0 200 cm
100 0 m
50 100 l
150 100 l
h
S
q
1 0 0 1 200 0 cm
50 50 m
50 22.385763 72.385763 0 100 0 c
127.614237 0 150 22.385763 150 50 c
150 77.614237 127.614237 100 100 100 c
72.385763 100 50 77.614237 50 50 c
h
[5 10] 0 d
S
Q
q
1 0 0 1 400 0 cm
50 50 m
50 22.385763 72.385763 0 100 0 c
127.614237 0 150 22.385763 150 50 c
150 77.614237 127.614237 100 100 100 c
72.385763 100 50 77.614237 50 50 c
h
3 w
/Gs1 gs
/DeviceRGB cs
1 0 0 scn
/Gs2 gs
/DeviceRGB CS
0.6 0 0 SCN
/Gs3 gs
B
Q
1 0 0 1 0 200 cm
25 w
0 J
50 20 m
100 20 l
S
1 J
150 20 m
200 20 l
S
2 J
250 20 m
260 30 m
260 21.715729 266.715729 15 275 15 c
283.284271 15 290 21.715729 290 30 c
290 38.284271 283.284271 45 275 45 c
266.715729 45 260 38.284271 260 30 c
h
S
0 j
50 100 50 50 re
S
1 j
150 100 50 50 re
S
2 j
250 100 50 50 re
S
endstream
endobj
9 0 obj
<<
/CreationDate (D:19700101000000Z)
/Producer (PITKIT)
/Creator (PITKIT)
>>
endobj
2 0 obj
<<
/Pages 1 0 R
/Type /Catalog
>>
endobj
1 0 obj
<<
/Kids [5 0 R]
/Type /Pages
/Count 1
>>
endobj
xref
0 10
0000000000 65535 f
0000001452 00000 n
0000001403 00000 n
0000000370 00000 n
0000000253 00000 n
0000000149 00000 n
0000000015 00000 n
0000000061 00000 n
0000000105 00000 n
0000001311 00000 n
trailer
<<
/Size 10
/Root 2 0 R
/Info 9 0 R
>>
startxref
1509
%%EOF

@ -38,7 +38,7 @@ endobj
<<
/Producer (PDFKit)
/Creator (PDFKit)
/CreationDate (D:20170519210912Z)
/CreationDate (D:20181120222652Z)
>>
endobj
6 0 obj

Binary file not shown.

Binary file not shown.

@ -0,0 +1,83 @@
%PDF-1.3
%ÿÿÿÿ
5 0 obj
<<
/Resources 4 0 R
/Contents 3 0 R
/MediaBox [0 0 612 792]
/Type /Page
/Parent 1 0 R
>>
endobj
4 0 obj
<<
/Font <<
/F1 6 0 R
>>
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
>>
endobj
3 0 obj
<<
/Length 123
>>
stream
1 0 0 -1 0 792 cm
q
1 0 0 -1 0 792 cm
BT
1 0 0 1 72 711.384 Tm
/F1 12 Tf
[<48656c6c6f2077> 10 <6f72> -15 <6c64> 0] TJ
ET
Q
endstream
endobj
7 0 obj
<<
/CreationDate (D:19700101000000Z)
/Producer (PITKIT)
/Creator (PITKIT)
>>
endobj
6 0 obj
<<
/Subtype /Type1
/Encoding /WinAnsiEncoding
/BaseFont /Helvetica
/Type /Font
>>
endobj
2 0 obj
<<
/Pages 1 0 R
/Type /Catalog
>>
endobj
1 0 obj
<<
/Kids [5 0 R]
/Type /Pages
/Count 1
>>
endobj
xref
0 8
0000000000 65535 f
0000000620 00000 n
0000000571 00000 n
0000000208 00000 n
0000000119 00000 n
0000000015 00000 n
0000000474 00000 n
0000000382 00000 n
trailer
<<
/Size 8
/Root 2 0 R
/Info 7 0 R
>>
startxref
677
%%EOF
Loading…
Cancel
Save