start test2
parent
3d2676221c
commit
967b33aef5
@ -1 +1 @@
|
|||||||
../../../../../../usr/local/lib/node_modules/pdfkit
|
../../../../../../../usr/local/lib/node_modules/pdfkit
|
@ -0,0 +1,70 @@
|
|||||||
|
PDFDocument = require 'pdfkit'
|
||||||
|
fs = require 'fs'
|
||||||
|
|
||||||
|
# Create a new PDFDocument
|
||||||
|
doc = new PDFDocument({compress: no})
|
||||||
|
doc.pipe(fs.createWriteStream('test2.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.path('M 0,20 L 100,160 Q 130,200 150,120 C 190,-40 200,200 300,150 L 400,90').stroke()
|
||||||
|
|
||||||
|
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()
|
@ -0,0 +1,165 @@
|
|||||||
|
%PDF-1.3
|
||||||
|
%ÿÿÿÿ
|
||||||
|
6 0 obj
|
||||||
|
<<
|
||||||
|
/Type /ExtGState
|
||||||
|
/ca 0.8
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
7 0 obj
|
||||||
|
<<
|
||||||
|
/Type /ExtGState
|
||||||
|
/ca 1
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
8 0 obj
|
||||||
|
<<
|
||||||
|
/Type /ExtGState
|
||||||
|
/CA 1
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
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]
|
||||||
|
/ExtGState <<
|
||||||
|
/Gs1 6 0 R
|
||||||
|
/Gs2 7 0 R
|
||||||
|
/Gs3 8 0 R
|
||||||
|
>>
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<<
|
||||||
|
/Length 979
|
||||||
|
>>
|
||||||
|
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
|
||||||
|
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
|
||||||
|
<<
|
||||||
|
/Producer (PDFKit)
|
||||||
|
/Creator (PDFKit)
|
||||||
|
/CreationDate (D:20170515173303Z)
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<<
|
||||||
|
/Type /Catalog
|
||||||
|
/Pages 1 0 R
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<<
|
||||||
|
/Type /Pages
|
||||||
|
/Count 1
|
||||||
|
/Kids [5 0 R]
|
||||||
|
>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 10
|
||||||
|
0000000000 65535 f
|
||||||
|
0000001541 00000 n
|
||||||
|
0000001492 00000 n
|
||||||
|
0000000370 00000 n
|
||||||
|
0000000253 00000 n
|
||||||
|
0000000149 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000061 00000 n
|
||||||
|
0000000105 00000 n
|
||||||
|
0000001400 00000 n
|
||||||
|
trailer
|
||||||
|
<<
|
||||||
|
/Size 10
|
||||||
|
/Root 2 0 R
|
||||||
|
/Info 9 0 R
|
||||||
|
>>
|
||||||
|
startxref
|
||||||
|
1598
|
||||||
|
%%EOF
|
@ -0,0 +1,89 @@
|
|||||||
|
#lang pitfall/pdftest
|
||||||
|
(define-runtime-path this "test2rkt.pdf")
|
||||||
|
|
||||||
|
(check-true
|
||||||
|
(let ([doc (new PDFDocument)])
|
||||||
|
(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])
|
||||||
|
|
||||||
|
|
||||||
|
;; curved path as svg path
|
||||||
|
(send* doc
|
||||||
|
[path "M 020 L 100160 Q 130200 150120 C 190-40 200200 300150 L 40090"]
|
||||||
|
[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)
|
Loading…
Reference in New Issue