consolidate test files

main
Matthew Butterick 8 years ago
parent 61e180b975
commit c99c47a2ed

@ -5,10 +5,5 @@
pitfall/test/test2
pitfall/test/test3
pitfall/test/test4
pitfall/test/test0c
pitfall/test/test1c
pitfall/test/test2c
pitfall/test/test3c
pitfall/test/test4c
pitfall/page-test
(submod pitfall/zlib test)))

@ -140,7 +140,7 @@
(define/contract (end this) ; called from source file to finish doc
(->m boolean?)
(->m void?)
(flushPages this)
(define _info (ref this))
(for ([(key val) (in-hash (· this info))])
@ -179,8 +179,7 @@
(define this-output-port (· this output-port))
(copy-port (open-input-bytes
(apply bytes-append (reverse (· this byte-strings)))) this-output-port)
(close-output-port this-output-port)
#t)
(close-output-port this-output-port))

@ -1,6 +1,6 @@
#lang pitfall/racket
(provide (all-from-out pitfall/racket))
(provide check-copy-equal? check-pdfkit?)
(provide check-copy-equal? check-pdfkit? make-doc)
(test-mode #t)
@ -24,6 +24,14 @@
(check-equal? (bytes-length (file->bytes this))
(bytes-length (file->bytes (this->pdfkit-control this)))))
(define (make-doc ps compress? [proc (λ (doc) doc)])
(define doc (make-object PDFDocument (hash 'compress compress?)))
(send doc pipe (open-output-file ps #:exists 'replace))
(proc doc)
(send doc end)
(check-copy-equal? ps)
(check-pdfkit? ps))
(module reader syntax/module-reader
#:language 'pitfall/pdftest

Binary file not shown.

@ -4,5 +4,8 @@ fs = require 'fs'
# Create a new PDFDocument
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test0.pdf'))
doc.end()
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test0c.pdf'))
doc.end()

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

@ -1,11 +1,7 @@
#lang pitfall/pdftest
(define-runtime-path this "test0rkt.pdf")
(check-true
(let ()
(define doc (make-object PDFDocument (hash 'compress #f)))
(send doc pipe (open-output-file this #:exists 'replace))
(send doc end)))
(define-runtime-path this "test0rkt.pdf")
(make-doc this #f)
(check-copy-equal? this)
(check-pdfkit? this)
(define-runtime-path that "test0crkt.pdf")
(make-doc that #t)

@ -1,10 +0,0 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# Create a new PDFDocument
# uncompressed obj order: 5 4 3 6 2 1
# compressed obj order: 5 4 6 2 1 3
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test0c.pdf'))
doc.end()

Binary file not shown.

@ -1,11 +0,0 @@
#lang pitfall/pdftest
(define-runtime-path this "test0crkt.pdf")
(check-true
(let ()
(define doc (make-object PDFDocument (hash 'compress #t)))
(send doc pipe (open-output-file this #:exists 'replace))
(send doc end)))
(check-copy-equal? this)
(check-pdfkit? this)

@ -1,18 +1,24 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# Create a new PDFDocument
make = (doc) ->
# Draw a triangle and a circle
doc.save()
.moveTo(100, 150)
.lineTo(100, 250)
.lineTo(200, 250)
.fill("#FF3300")
doc.circle(280, 200, 50)
.fill("#6600FF")
doc.end()
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test1.pdf'))
make doc
# Draw a triangle and a circle
doc.save()
.moveTo(100, 150)
.lineTo(100, 250)
.lineTo(200, 250)
.fill("#FF3300")
doc.circle(280, 200, 50)
.fill("#6600FF")
doc.end()
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test1c.pdf'))
make doc

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

@ -1,23 +1,21 @@
#lang pitfall/pdftest
(define-runtime-path this "test1rkt.pdf")
(check-true
(let ([doc (make-object PDFDocument (hash 'compress #f))])
(send doc pipe (open-output-file this #:exists 'replace))
(define (proc doc)
;; Draw a triangle and a circle
(send* doc
[save]
[moveTo 100 150]
[lineTo 100 250]
[lineTo 200 250]
[fill "#FF3300"])
;; Draw a triangle and a circle
(send* doc
[save]
[moveTo 100 150]
[lineTo 100 250]
[lineTo 200 250]
[fill "#FF3300"])
(send* doc
[circle 280 200 50]
[fill "#6600FF"]))
(send* doc
[circle 280 200 50]
[fill "#6600FF"])
(define-runtime-path this "test1rkt.pdf")
(make-doc this #f proc)
(send doc end)))
(define-runtime-path that "test1crkt.pdf")
(make-doc that #t proc)
(check-copy-equal? this)
(check-pdfkit? this)

@ -1,18 +0,0 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# Create a new PDFDocument
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test1c.pdf'))
# Draw a triangle and a circle
doc.save()
.moveTo(100, 150)
.lineTo(100, 250)
.lineTo(200, 250)
.fill("#FF3300")
doc.circle(280, 200, 50)
.fill("#6600FF")
doc.end()

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

@ -1,23 +0,0 @@
#lang pitfall/pdftest
(define-runtime-path this "test1crkt.pdf")
(check-true
(let ([doc (make-object PDFDocument (hash 'compress #t))])
(send doc pipe (open-output-file this #:exists 'replace))
;; Draw a triangle and a circle
(send* doc
[save]
[moveTo 100 150]
[lineTo 100 250]
[lineTo 200 250]
[fill "#FF3300"])
(send* doc
[circle 280 200 50]
[fill "#6600FF"])
(send doc end)))
(check-copy-equal? this)
(check-pdfkit? this)

@ -1,66 +1,74 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# Create a new PDFDocument
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test2.pdf'))
make = (doc) ->
doc.moveTo(0, 20)
.lineTo(100, 160)
.quadraticCurveTo(130, 200, 150, 120)
.bezierCurveTo(190, -40, 200, 200, 300, 150) # draw a bezier curve
.lineTo(400, 90) # draw another line
.stroke() # stroke the path
doc.translate(0, 200)
doc.polygon [100, 0], [50, 100], [150, 100]
doc.stroke()
doc.moveTo(0, 20)
.lineTo(100, 160)
.quadraticCurveTo(130, 200, 150, 120)
.bezierCurveTo(190, -40, 200, 200, 300, 150) # draw a bezier curve
.lineTo(400, 90) # draw another line
.stroke() # stroke the path
doc.save()
doc.translate(200, 0)
doc.circle(100, 50, 50)
.dash(5, space: 10)
.stroke()
doc.restore()
doc.translate(0, 200)
doc.save()
doc.translate(400, 0)
doc.circle(100, 50, 50)
.lineWidth(3)
.fillOpacity(0.8)
.fillAndStroke("red", "#900")
doc.restore()
doc.polygon [100, 0], [50, 100], [150, 100]
doc.stroke()
doc.translate(0, 200)
doc.save()
doc.translate(200, 0)
doc.circle(100, 50, 50)
.dash(5, space: 10)
.stroke()
doc.restore()
doc.save()
doc.translate(400, 0)
doc.circle(100, 50, 50)
.lineWidth(3)
.fillOpacity(0.8)
.fillAndStroke("red", "#900")
doc.restore()
# these examples are easier to see with a large line width
doc.lineWidth(25)
# line cap settings
doc.lineCap('butt')
.moveTo(50, 20)
.lineTo(100, 20)
.stroke()
doc.lineCap('round')
.moveTo(150, 20)
.lineTo(200, 20)
.stroke()
# square line cap shown with a circle instead of a line so you can see it
doc.lineCap('square')
.moveTo(250, 20)
.circle(275, 30, 15)
.stroke()
# line join settings
doc.lineJoin('miter')
.rect(50, 100, 50, 50)
.stroke()
doc.lineJoin('round')
.rect(150, 100, 50, 50)
.stroke()
doc.lineJoin('bevel')
.rect(250, 100, 50, 50)
.stroke()
doc.translate(0, 200)
doc.end()
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test2.pdf'))
make doc
# these examples are easier to see with a large line width
doc.lineWidth(25)
# line cap settings
doc.lineCap('butt')
.moveTo(50, 20)
.lineTo(100, 20)
.stroke()
doc.lineCap('round')
.moveTo(150, 20)
.lineTo(200, 20)
.stroke()
# square line cap shown with a circle instead of a line so you can see it
doc.lineCap('square')
.moveTo(250, 20)
.circle(275, 30, 15)
.stroke()
# line join settings
doc.lineJoin('miter')
.rect(50, 100, 50, 50)
.stroke()
doc.lineJoin('round')
.rect(150, 100, 50, 50)
.stroke()
doc.lineJoin('bevel')
.rect(250, 100, 50, 50)
.stroke()
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test2c.pdf'))
make doc
doc.end()

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

@ -1,78 +1,78 @@
#lang pitfall/pdftest
(define-runtime-path this "test2rkt.pdf")
(check-true
(let ([doc (make-object PDFDocument (hash 'compress #f))])
(send doc pipe (open-output-file this #:exists 'replace))
(define (proc doc)
;; curved path as bezier
(send* doc
[moveTo 0 20]
[lineTo 100 160]
[quadraticCurveTo 130 200 150 120]
[bezierCurveTo 190 -40 200 200 300 150]
[lineTo 400 90]
[stroke])
;; curved path as bezier
(send* doc
[moveTo 0 20]
[lineTo 100 160]
[quadraticCurveTo 130 200 150 120]
[bezierCurveTo 190 -40 200 200 300 150]
[lineTo 400 90]
[stroke])
(send* doc [translate 0 200])
(send* doc [translate 0 200])
;; triangle
(send* doc
[polygon '(100 0) '(50 100) '(150 100)]
[stroke])
;; triangle
(send* doc
[polygon '(100 0) '(50 100) '(150 100)]
[stroke])
;; dashed circle
(send* doc
[save]
[translate 200 0]
[circle 100 50 50]
[dash 5 (hash 'space 10)]
[stroke]
[restore])
;; dashed circle
(send* doc
[save]
[translate 200 0]
[circle 100 50 50]
[dash 5 (hash 'space 10)]
[stroke]
[restore])
;; filled circle
(send* doc
[save]
[translate 400 0]
[circle 100 50 50]
[lineWidth 3]
[fillOpacity 0.8]
[fillAndStroke "red" "#900"]
[restore])
;; filled circle
(send* doc
[save]
[translate 400 0]
[circle 100 50 50]
[lineWidth 3]
[fillOpacity 0.8]
[fillAndStroke "red" "#900"]
[restore])
(send* doc [translate 0 200])
(send* doc [translate 0 200])
;; these examples are easier to see with a large line width
(send* doc [lineWidth 25])
;; these examples are easier to see with a large line width
(send* doc [lineWidth 25])
;; line cap settings
(send* doc [lineCap 'butt]
[moveTo 50 20]
[lineTo 100 20]
[stroke]
[lineCap 'round]
[moveTo 150 20]
[lineTo 200 20]
[stroke])
;; line cap settings
(send* doc [lineCap 'butt]
[moveTo 50 20]
[lineTo 100 20]
[stroke]
[lineCap 'round]
[moveTo 150 20]
[lineTo 200 20]
[stroke])
;; square line cap shown with a circle instead of a line so you can see it
(send* doc [lineCap 'square]
[moveTo 250 20]
[circle 275 30 15]
[stroke])
;; square line cap shown with a circle instead of a line so you can see it
(send* doc [lineCap 'square]
[moveTo 250 20]
[circle 275 30 15]
[stroke])
;; line join settings
(send* doc [lineJoin 'miter]
[rect 50 100 50 50]
[stroke]
[lineJoin 'round]
[rect 150 100 50 50]
[stroke]
[lineJoin 'bevel]
[rect 250 100 50 50]
[stroke]))
;; line join settings
(send* doc [lineJoin 'miter]
[rect 50 100 50 50]
[stroke]
[lineJoin 'round]
[rect 150 100 50 50]
[stroke]
[lineJoin 'bevel]
[rect 250 100 50 50]
[stroke])
(send doc end)))
(check-copy-equal? this)
(check-pdfkit? this)
(define-runtime-path this "test2rkt.pdf")
(make-doc this #f proc)
(define-runtime-path that "test2crkt.pdf")
(make-doc that #t proc)

@ -1,66 +0,0 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# Create a new PDFDocument
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test2c.pdf'))
doc.moveTo(0, 20)
.lineTo(100, 160)
.quadraticCurveTo(130, 200, 150, 120)
.bezierCurveTo(190, -40, 200, 200, 300, 150) # draw a bezier curve
.lineTo(400, 90) # draw another line
.stroke() # stroke the path
doc.translate(0, 200)
doc.polygon [100, 0], [50, 100], [150, 100]
doc.stroke()
doc.save()
doc.translate(200, 0)
doc.circle(100, 50, 50)
.dash(5, space: 10)
.stroke()
doc.restore()
doc.save()
doc.translate(400, 0)
doc.circle(100, 50, 50)
.lineWidth(3)
.fillOpacity(0.8)
.fillAndStroke("red", "#900")
doc.restore()
doc.translate(0, 200)
# these examples are easier to see with a large line width
doc.lineWidth(25)
# line cap settings
doc.lineCap('butt')
.moveTo(50, 20)
.lineTo(100, 20)
.stroke()
doc.lineCap('round')
.moveTo(150, 20)
.lineTo(200, 20)
.stroke()
# square line cap shown with a circle instead of a line so you can see it
doc.lineCap('square')
.moveTo(250, 20)
.circle(275, 30, 15)
.stroke()
# line join settings
doc.lineJoin('miter')
.rect(50, 100, 50, 50)
.stroke()
doc.lineJoin('round')
.rect(150, 100, 50, 50)
.stroke()
doc.lineJoin('bevel')
.rect(250, 100, 50, 50)
.stroke()
doc.end()

Binary file not shown.

@ -1,78 +0,0 @@
#lang pitfall/pdftest
(define-runtime-path this "test2crkt.pdf")
(check-true
(let ([doc (make-object PDFDocument (hash 'compress #t))])
(send doc pipe (open-output-file this #:exists 'replace))
;; curved path as bezier
(send* doc
[moveTo 0 20]
[lineTo 100 160]
[quadraticCurveTo 130 200 150 120]
[bezierCurveTo 190 -40 200 200 300 150]
[lineTo 400 90]
[stroke])
(send* doc [translate 0 200])
;; triangle
(send* doc
[polygon '(100 0) '(50 100) '(150 100)]
[stroke])
;; dashed circle
(send* doc
[save]
[translate 200 0]
[circle 100 50 50]
[dash 5 (hash 'space 10)]
[stroke]
[restore])
;; filled circle
(send* doc
[save]
[translate 400 0]
[circle 100 50 50]
[lineWidth 3]
[fillOpacity 0.8]
[fillAndStroke "red" "#900"]
[restore])
(send* doc [translate 0 200])
;; these examples are easier to see with a large line width
(send* doc [lineWidth 25])
;; line cap settings
(send* doc [lineCap 'butt]
[moveTo 50 20]
[lineTo 100 20]
[stroke]
[lineCap 'round]
[moveTo 150 20]
[lineTo 200 20]
[stroke])
;; square line cap shown with a circle instead of a line so you can see it
(send* doc [lineCap 'square]
[moveTo 250 20]
[circle 275 30 15]
[stroke])
;; line join settings
(send* doc [lineJoin 'miter]
[rect 50 100 50 50]
[stroke]
[lineJoin 'round]
[rect 150 100 50 50]
[stroke]
[lineJoin 'bevel]
[rect 250 100 50 50]
[stroke])
(send doc end)))
(check-copy-equal? this)
(check-pdfkit? this)

@ -1,10 +1,16 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# Create a new PDFDocument
make = (doc) ->
doc.text("Hello world")
doc.end()
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test3.pdf'))
make doc
doc.text("Hello world")
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test3c.pdf'))
make doc
doc.end()

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

@ -1,11 +1,11 @@
#lang pitfall/pdftest
(define (proc doc)
(send doc text "Hello world"))
(define-runtime-path this "test3rkt.pdf")
(make-doc this #f proc)
(check-true
(let ([doc (make-object PDFDocument (hash 'compress #f))])
(send doc pipe (open-output-file this #:exists 'replace))
(send doc text "Hello world")
(send doc end)))
(define-runtime-path that "test3crkt.pdf")
(make-doc that #t proc)
(check-copy-equal? this)
(check-pdfkit? this)

@ -1,10 +0,0 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# Create a new PDFDocument
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test3c.pdf'))
doc.text("Hello world")
doc.end()

Binary file not shown.

@ -1,11 +0,0 @@
#lang pitfall/pdftest
(define-runtime-path this "test3crkt.pdf")
(check-true
(let ([doc (make-object PDFDocument (hash 'compress #t))])
(send doc pipe (open-output-file this #:exists 'replace))
(send doc text "Hello world")
(send doc end)))
(check-copy-equal? this)
(check-pdfkit? this)

@ -1,65 +1,71 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# Create a new PDFDocument
make = (doc) ->
doc.font("Courier-Bold")
.fontSize(10)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Courier-BoldOblique")
.fontSize(11)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Courier-Oblique")
.fontSize(12)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Courier")
.fontSize(14)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica-Bold")
.fontSize(16)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica-BoldOblique")
.fontSize(18)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica-Oblique")
.fontSize(20)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica")
.fontSize(22)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Symbol")
.fontSize(24)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-Bold")
.fontSize(26)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-BoldItalic")
.fontSize(28)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-Italic")
.fontSize(30)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-Roman")
.fontSize(32)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("ZapfDingbats")
.fontSize(34)
.text("Hello", lineBreak: no)
doc.end()
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test4.pdf'))
make doc
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test4c.pdf'))
make doc
doc.font("Courier-Bold")
.fontSize(10)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Courier-BoldOblique")
.fontSize(11)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Courier-Oblique")
.fontSize(12)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Courier")
.fontSize(14)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica-Bold")
.fontSize(16)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica-BoldOblique")
.fontSize(18)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica-Oblique")
.fontSize(20)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica")
.fontSize(22)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Symbol")
.fontSize(24)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-Bold")
.fontSize(26)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-BoldItalic")
.fontSize(28)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-Italic")
.fontSize(30)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-Roman")
.fontSize(32)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("ZapfDingbats")
.fontSize(34)
.text("Hello", lineBreak: no)
doc.end()

@ -1,11 +1,7 @@
#lang pitfall/pdftest
(define-runtime-path this "test4rkt.pdf")
(check-true
(let ([doc (make-object PDFDocument (hash 'compress #f))])
(send doc pipe (open-output-file this #:exists 'replace))
(send* doc
(define (proc doc)
(send* doc
[font "Courier-Bold"]
[fontSize 10]
[text "Hello"]
@ -60,10 +56,11 @@
[translate -30 30]
[font "ZapfDingbats"]
[fontSize 34]
[text "Hello"])
[text "Hello"]))
(define-runtime-path this "test4rkt.pdf")
(make-doc this #f proc)
(send doc end)))
(define-runtime-path that "test4crkt.pdf")
(make-doc that #t proc)
(check-copy-equal? this)
(check-pdfkit? this)

@ -1,65 +0,0 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
# Create a new PDFDocument
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test4c.pdf'))
doc.font("Courier-Bold")
.fontSize(10)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Courier-BoldOblique")
.fontSize(11)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Courier-Oblique")
.fontSize(12)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Courier")
.fontSize(14)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica-Bold")
.fontSize(16)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica-BoldOblique")
.fontSize(18)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica-Oblique")
.fontSize(20)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Helvetica")
.fontSize(22)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Symbol")
.fontSize(24)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-Bold")
.fontSize(26)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-BoldItalic")
.fontSize(28)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-Italic")
.fontSize(30)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("Times-Roman")
.fontSize(32)
.text("Hello", lineBreak: no)
.translate(-30,30)
.font("ZapfDingbats")
.fontSize(34)
.text("Hello", lineBreak: no)
doc.end()

@ -1,69 +0,0 @@
#lang pitfall/pdftest
(define-runtime-path this "test4crkt.pdf")
(check-true
(let ([doc (make-object PDFDocument (hash 'compress #t))])
(send doc pipe (open-output-file this #:exists 'replace))
(send* doc
[font "Courier-Bold"]
[fontSize 10]
[text "Hello"]
[translate -30 30]
[font "Courier-BoldOblique"]
[fontSize 11]
[text "Hello"]
[translate -30 30]
[font "Courier-Oblique"]
[fontSize 12]
[text "Hello"]
[translate -30 30]
[font "Courier"]
[fontSize 14]
[text "Hello"]
[translate -30 30]
[font "Helvetica-Bold"]
[fontSize 16]
[text "Hello"]
[translate -30 30]
[font "Helvetica-BoldOblique"]
[fontSize 18]
[text "Hello"]
[translate -30 30]
[font "Helvetica-Oblique"]
[fontSize 20]
[text "Hello"]
[translate -30 30]
[font "Helvetica"]
[fontSize 22]
[text "Hello"]
[translate -30 30]
[font "Symbol"]
[fontSize 24]
[text "Hello"]
[translate -30 30]
[font "Times-Bold"]
[fontSize 26]
[text "Hello"]
[translate -30 30]
[font "Times-BoldItalic"]
[fontSize 28]
[text "Hello"]
[translate -30 30]
[font "Times-Italic"]
[fontSize 30]
[text "Hello"]
[translate -30 30]
[font "Times-Roman"]
[fontSize 32]
[text "Hello"]
[translate -30 30]
[font "ZapfDingbats"]
[fontSize 34]
[text "Hello"])
(send doc end)))
(check-copy-equal? this)
(check-pdfkit? this)

@ -1,16 +1,21 @@
PDFDocument = require 'pdfkit'
tiger = require './assets/tiger'
fs = require 'fs'
# Create a new PDFDocument
doc = new PDFDocument
doc.pipe fs.createWriteStream('test5.pdf')
make = (doc) ->
# Set the font, draw some text, and embed an image
doc.font('Times-Italic')
.fontSize(25)
.text('Some text with an embedded font!', 100, 100, lineBreak: no)
.image('assets/test.png', 100, 160, width: 412)
.image('assets/test.jpeg', 190, 400, height: 300)
doc.end()
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test5.pdf'))
make doc
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test5c.pdf'))
make doc
# Set the font, draw some text, and embed an image
doc.font('Times-Italic')
.fontSize(25)
.text('Some text with an embedded font!', 100, 100, lineBreak: no)
.image('assets/test.png', 100, 160, width: 412)
.image('assets/test.jpeg', 190, 400, height: 300)
doc.end()

@ -1,21 +1,16 @@
#lang pitfall/pdftest
(define-runtime-path this "test5rkt.pdf")
(check-true
(let ([doc (new PDFDocument)])
(send doc pipe (open-output-file this #:exists 'replace))
;; # Set the font, draw some text, and embed an image
(send* doc
(define (proc doc)
(send* doc
[font "Times-Italic"]
[fontSize 25]
[text "Some text with an embedded font!" 100 100 (hash 'lineBreak #f)]
[image "assets/test.png" 100 160 (hash 'width 412)]
[image "assets/test.jpeg" 190 400 (hash 'height 300)]
)
[image "assets/test.jpeg" 190 400 (hash 'height 300)]))
(define-runtime-path this "test5rkt.pdf")
(make-doc this #f proc)
(send doc end)))
(define-runtime-path that "test5crkt.pdf")
(make-doc that #t proc)
;(check-copy-equal? this)
;(check-pdfkit? this)

@ -1,21 +0,0 @@
#lang pitfall/pdftest
(define-runtime-path this "test5crkt.pdf")
(check-true
(let ([doc (make-object PDFDocument (hash 'compress #t))])
(send doc pipe (open-output-file this #:exists 'replace))
;; # Set the font, draw some text, and embed an image
(send* doc
[font "Times-Italic"]
[fontSize 25]
[text "Some text with an embedded font!" 100 100 (hash 'lineBreak #f)]
[image "assets/test.png" 100 160 (hash 'width 412)]
[image "assets/test.jpeg" 190 400 (hash 'height 300)]
)
(send doc end)))
;(check-copy-equal? this)
;(check-pdfkit? this)

@ -0,0 +1,26 @@
PDFDocument = require 'pdfkit'
fs = require 'fs'
make = (doc) ->
doc.text('Page 1')
.addPage()
.text('Page 2')
.addPage()
.text('Page 3')
.addPage()
.text('Page 4')
.addPage()
.text('Page 5')
.addPage()
.text('Page 6')
doc.end()
doc = new PDFDocument({compress: no})
doc.pipe(fs.createWriteStream('test6.pdf'))
make doc
doc = new PDFDocument({compress: yes})
doc.pipe(fs.createWriteStream('test6c.pdf'))
make doc

@ -0,0 +1,268 @@
%PDF-1.3
%ÿÿÿÿ
5 0 obj
<<
/Type /Page
/Parent 1 0 R
/MediaBox [0 0 612 792]
/Contents 3 0 R
/Resources 4 0 R
>>
endobj
4 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 6 0 R
>>
>>
endobj
3 0 obj
<<
/Length 106
>>
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
[<50> 40 <6167652031> 0] TJ
ET
Q
endstream
endobj
9 0 obj
<<
/Type /Page
/Parent 1 0 R
/MediaBox [0 0 612 792]
/Contents 7 0 R
/Resources 8 0 R
>>
endobj
8 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 6 0 R
>>
>>
endobj
7 0 obj
<<
/Length 106
>>
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
[<50> 40 <6167652032> 0] TJ
ET
Q
endstream
endobj
12 0 obj
<<
/Type /Page
/Parent 1 0 R
/MediaBox [0 0 612 792]
/Contents 10 0 R
/Resources 11 0 R
>>
endobj
11 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 6 0 R
>>
>>
endobj
10 0 obj
<<
/Length 106
>>
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
[<50> 40 <6167652033> 0] TJ
ET
Q
endstream
endobj
15 0 obj
<<
/Type /Page
/Parent 1 0 R
/MediaBox [0 0 612 792]
/Contents 13 0 R
/Resources 14 0 R
>>
endobj
14 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 6 0 R
>>
>>
endobj
13 0 obj
<<
/Length 106
>>
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
[<50> 40 <6167652034> 0] TJ
ET
Q
endstream
endobj
18 0 obj
<<
/Type /Page
/Parent 1 0 R
/MediaBox [0 0 612 792]
/Contents 16 0 R
/Resources 17 0 R
>>
endobj
17 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 6 0 R
>>
>>
endobj
16 0 obj
<<
/Length 106
>>
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
[<50> 40 <6167652035> 0] TJ
ET
Q
endstream
endobj
21 0 obj
<<
/Type /Page
/Parent 1 0 R
/MediaBox [0 0 612 792]
/Contents 19 0 R
/Resources 20 0 R
>>
endobj
20 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 6 0 R
>>
>>
endobj
19 0 obj
<<
/Length 106
>>
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
[<50> 40 <6167652036> 0] TJ
ET
Q
endstream
endobj
22 0 obj
<<
/Producer (PDFKit)
/Creator (PDFKit)
/CreationDate (D:20170519203858Z)
>>
endobj
6 0 obj
<<
/Type /Font
/BaseFont /Helvetica
/Subtype /Type1
/Encoding /WinAnsiEncoding
>>
endobj
2 0 obj
<<
/Type /Catalog
/Pages 1 0 R
>>
endobj
1 0 obj
<<
/Type /Pages
/Count 6
/Kids [5 0 R 9 0 R 12 0 R 15 0 R 18 0 R 21 0 R]
>>
endobj
xref
0 23
0000000000 65535 f
0000002374 00000 n
0000002325 00000 n
0000000208 00000 n
0000000119 00000 n
0000000015 00000 n
0000002228 00000 n
0000000558 00000 n
0000000469 00000 n
0000000365 00000 n
0000000912 00000 n
0000000822 00000 n
0000000715 00000 n
0000001267 00000 n
0000001177 00000 n
0000001070 00000 n
0000001622 00000 n
0000001532 00000 n
0000001425 00000 n
0000001977 00000 n
0000001887 00000 n
0000001780 00000 n
0000002135 00000 n
trailer
<<
/Size 23
/Root 2 0 R
/Info 22 0 R
>>
startxref
2465
%%EOF
Loading…
Cancel
Save