test 0 & 1

main
Matthew Butterick 6 years ago
parent 94fbf2ab94
commit c489c007ff

@ -60,7 +60,9 @@
(unless (even? (length items)) (raise items))
(define dic
(sort ; put hash into order so it's comparable
(for/list ([kv (in-slice 2 items)])
(for/list ([kv (in-slice 2 items)]
;; suppress these keys so we can compare pdfkit & pitfall output
#:unless (member (car kv) (list #"/Producer" #"/Creator" #"/CreationDate")))
(apply cons kv))
bytes<?
#:key car))
@ -108,7 +110,8 @@
(define-simple-check (check-pdfs-equal? ps1 ps2)
(equal? (pdf->dict ps1) (pdf->dict ps2)))
(for ([p (in-directory)]
#:when (path-has-extension? p #"pdf"))
(with-handlers ([exn:fail? (λ (exn) (println (format "~a failed" p)))])
(pdf->dict p)))
#;(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))))

@ -65,7 +65,7 @@
(set-field! _font this val))]
;; load the font
[else
(println (format "Load font: ~a" src))
#;(println (format "Load font: ~a" src))
(define id (format "F~a" (increment-field! _fontCount this)))
(set-field! _font this (PDFFont-open this src family id))

@ -1,5 +1,5 @@
#lang racket/base
(require "racket.rkt")
(require "racket.rkt" "check-pdf.rkt")
(provide (all-from-out "racket.rkt"))
(provide check-copy-equal? check-pdfkit? make-doc)
@ -11,7 +11,7 @@
(define (this->control this) (path-add-extension this #"" #" copy."))
(define (this->pdfkit-control this)
(string->path (string-replace (path->string this) "rkt." ".")))
(string->path (string-replace ((if (string? this) values path->string) this) "rkt." ".")))
(module+ test
(require rackunit)
@ -27,18 +27,12 @@
(define-syntax-rule (check-pdfkit? this)
(check-equal? (file-size this) (file-size (this->pdfkit-control this))))
(define (make-doc ps compress? [proc (λ (doc) doc)] #:test [test? #t] #:pdfkit [pdfkit? #t])
(define (make-doc ps [compress? #false] [proc (λ (doc) doc)] #:test [test? #t] #:pdfkit [pdfkit? #t])
(define doc (make-object PDFDocument (hash 'compress compress?)))
(send doc pipe (open-output-file ps #:exists 'replace))
(proc doc)
(send doc end)
(when test?
(check-copy-equal? ps)
(check-pdfs-equal? ps (this->control ps))
(when pdfkit?
(check-pdfkit? ps))))
(module reader syntax/module-reader
#:language 'pitfall/pdftest
#:read read
#:read-syntax read-syntax)
(check-pdfs-equal? ps (this->pdfkit-control ps)))))

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -27,7 +27,7 @@ endobj
<<
/Producer (PDFKit)
/Creator (PDFKit)
/CreationDate (D:20170519204252Z)
/CreationDate (D:20181120220342Z)
>>
endobj
2 0 obj

@ -1,8 +1,8 @@
#lang racket/base
(require pitfall/pdftest)
(define-runtime-path this "test0rkt.pdf")
(make-doc this #f)
(define-runtime-path pdf "test0rkt.pdf")
(make-doc pdf)
(define-runtime-path that "test0crkt.pdf")
(make-doc that #t)
(define-runtime-path pdfc "test0crkt.pdf")
(make-doc pdfc 'compress)

Binary file not shown.

Binary file not shown.

@ -0,0 +1,63 @@
%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
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
>>
endobj
3 0 obj
<<
/Length 18
>>
stream
1 0 0 -1 0 792 cm
endstream
endobj
6 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 7
0000000000 65535 f
0000000395 00000 n
0000000346 00000 n
0000000186 00000 n
0000000119 00000 n
0000000015 00000 n
0000000254 00000 n
trailer
<<
/Size 7
/Root 2 0 R
/Info 6 0 R
>>
startxref
452
%%EOF

@ -54,7 +54,7 @@ endobj
<<
/Producer (PDFKit)
/Creator (PDFKit)
/CreationDate (D:20170519210746Z)
/CreationDate (D:20181120215403Z)
>>
endobj
2 0 obj

@ -27,7 +27,7 @@ endobj
<<
/Producer (PDFKit)
/Creator (PDFKit)
/CreationDate (D:20170519210746Z)
/CreationDate (D:20181120215403Z)
>>
endobj
2 0 obj

@ -0,0 +1,76 @@
%PDF-1.3
%ÿÿÿÿ
6 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 <<
/Gs1 6 0 R
>>
>>
endobj
3 0 obj
<<
/Filter /FlateDecode
/Length 151
>>
stream
xœ]<5D>]
ƒ0„ß÷¹@ãî¬ûZ
¾÷
Áþ@-”@Ïï&• C2ó #ŽíœÄ®p†3}I˜<49>tìæ¢`êM¨ª¹N¿WœnãÅÅDô°pŠjÆ$îèNPss&d%^‡.ôjˆ*sS$åà{i¡¡<è>¦+Ï|Y¡z71¬<Þ¦¨|ìc¨¼çaûÖÖÈaÏ´E=
endstream
endobj
7 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 8
0000000000 65535 f
0000000622 00000 n
0000000573 00000 n
0000000258 00000 n
0000000163 00000 n
0000000059 00000 n
0000000015 00000 n
0000000481 00000 n
trailer
<<
/Size 8
/Root 2 0 R
/Info 7 0 R
>>
startxref
679
%%EOF

@ -0,0 +1,91 @@
%PDF-1.3
%ÿÿÿÿ
6 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 <<
/Gs1 6 0 R
>>
>>
endobj
3 0 obj
<<
/Length 294
>>
stream
1 0 0 -1 0 792 cm
q
100 150 m
100 250 l
200 250 l
/DeviceRGB cs
1 0.2 0 scn
/Gs1 gs
f
230 200 m
230 172.385763 252.385763 150 280 150 c
307.614237 150 330 172.385763 330 200 c
330 227.614237 307.614237 250 280 250 c
252.385763 250 230 227.614237 230 200 c
h
/DeviceRGB cs
0.4 0 1 scn
/Gs1 gs
f
endstream
endobj
7 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 8
0000000000 65535 f
0000000744 00000 n
0000000695 00000 n
0000000258 00000 n
0000000163 00000 n
0000000059 00000 n
0000000015 00000 n
0000000603 00000 n
trailer
<<
/Size 8
/Root 2 0 R
/Info 7 0 R
>>
startxref
801
%%EOF
Loading…
Cancel
Save