pdfkit 0.12.2 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/package.json +2 -2
  2. package/examples/attachment.js +0 -42
  3. package/examples/attachment.pdf +0 -0
  4. package/examples/browserify/browser.html +0 -54
  5. package/examples/browserify/browser.js +0 -97
  6. package/examples/browserify/bundle.js +0 -91259
  7. package/examples/fonts/Chalkboard.ttc +0 -0
  8. package/examples/fonts/DejaVuSans.ttf +0 -0
  9. package/examples/fonts/GoodDog.ttf +0 -0
  10. package/examples/fonts/Helvetica.dfont +0 -0
  11. package/examples/fonts/Montserrat-Bold.otf +0 -0
  12. package/examples/fonts/PalatinoBold.ttf +0 -0
  13. package/examples/form.js +0 -85
  14. package/examples/form.pdf +0 -0
  15. package/examples/images/dice.png +0 -0
  16. package/examples/images/fish.png +0 -0
  17. package/examples/images/interlaced-grayscale-8bit.png +0 -0
  18. package/examples/images/interlaced-pallete-8bit.png +0 -0
  19. package/examples/images/interlaced-rgb-16bit.png +0 -0
  20. package/examples/images/interlaced-rgb-8bit.png +0 -0
  21. package/examples/images/interlaced-rgb-alpha-8bit.png +0 -0
  22. package/examples/images/pngsuite-gray-transparent-white.png +0 -0
  23. package/examples/images/pngsuite-rgb-transparent-white.png +0 -0
  24. package/examples/images/straight.png +0 -0
  25. package/examples/images/test.jpeg +0 -0
  26. package/examples/images/test.png +0 -0
  27. package/examples/images/test2.png +0 -0
  28. package/examples/images/test3.png +0 -0
  29. package/examples/kitchen-sink-accessible.js +0 -255
  30. package/examples/kitchen-sink-accessible.pdf +0 -0
  31. package/examples/kitchen-sink.js +0 -115
  32. package/examples/kitchen-sink.pdf +0 -0
  33. package/examples/text-link.js +0 -26
  34. package/examples/text-link.pdf +0 -0
  35. package/examples/tiger.js +0 -1742
  36. package/examples/webpack/README.md +0 -14
  37. package/examples/webpack/package.json +0 -21
  38. package/examples/webpack/webpack.config.js +0 -84
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "document",
10
10
  "vector"
11
11
  ],
12
- "version": "0.12.2",
12
+ "version": "0.12.3",
13
13
  "homepage": "http://pdfkit.org/",
14
14
  "author": {
15
15
  "name": "Devon Govett",
@@ -91,4 +91,4 @@
91
91
  "jest-screenshot/reporter"
92
92
  ]
93
93
  }
94
- }
94
+ }
@@ -1,42 +0,0 @@
1
- const PDFDocument = require('../');
2
- const fs = require('fs');
3
- const path = require('path');
4
-
5
- const doc = new PDFDocument({ pdfVersion: '1.4' });
6
-
7
- doc.pipe(fs.createWriteStream('attachment.pdf'));
8
-
9
- doc.info['Title'] = 'Attachment Test';
10
-
11
- // add an embedded file from file system
12
- doc.file(path.join(__dirname, 'images', 'test.png'), {
13
- name: 'test.png',
14
- type: 'image/png',
15
- description: 'this is a test image'
16
- });
17
-
18
- // add some text
19
- doc.text(`This PDF contains three text files:
20
- Two file attachment annotations and one embedded file.
21
- If you can see them (not every PDF viewer supports embedded files),
22
- hover over the paperclip to see its description!`);
23
-
24
- // add a file attachment annotation
25
- // first, declare the file to be attached
26
- const file = {
27
- src: Buffer.from('buffered input!'),
28
- name: 'embedded.txt',
29
- creationDate: new Date(2020, 3, 1)
30
- };
31
- // then, add the annotation
32
- doc.fileAnnotation(100, 150, 10, doc.currentLineHeight(), file);
33
-
34
- // declared files can be reused, but they will show up separately in the PDF Viewer's attachments panel
35
- // we're going to use the paperclip icon for this one together with a short description
36
- // be aware that some PDF Viewers may not render the icon correctly — or not at all
37
- doc.fileAnnotation(150, 150, 10, doc.currentLineHeight(), file, {
38
- Name: 'Paperclip',
39
- Contents: 'Paperclip attachment'
40
- });
41
-
42
- doc.end();
Binary file
@@ -1,54 +0,0 @@
1
- <!doctype html>
2
- <html>
3
-
4
- <head>
5
- <meta charset="utf-8">
6
- <style>
7
- body {
8
- width: 1230px;
9
- margin: 20px auto;
10
- font-family: Georgia;
11
- }
12
-
13
- h1 {
14
- margin: 0;
15
- }
16
-
17
-
18
- a {
19
- color: blue;
20
- }
21
-
22
- #editor {
23
- width: 600px;
24
- height: 775px;
25
- margin-right: 20px;
26
- display: inline-block;
27
- }
28
-
29
- iframe {
30
- border: 1px solid black;
31
- }
32
- </style>
33
- </head>
34
-
35
- <body>
36
- <h1>PDFKit Browser Demo</h1>
37
- <p>Bundled with Browserify</p>
38
- <p><a href="http://pdfkit.org/">Website</a> | <a href="http://github.com/foliojs/pdfkit">Github</a></p>
39
- <div id="editor"></div>
40
- <iframe width="600" height="775"></iframe>
41
- <script src="bundle.js"></script>
42
- <script>
43
- (function (i, s, o, g, r, a, m) {
44
- i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
45
- (i[r].q = i[r].q || []).push(arguments)
46
- }, i[r].l = 1 * new Date(); a = s.createElement(o),
47
- m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
48
- })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
49
- ga('create', 'UA-48340245-1', 'pdfkit.org');
50
- ga('send', 'pageview');
51
- </script>
52
- </body>
53
-
54
- </html>
@@ -1,97 +0,0 @@
1
- var PDFDocument = require('../..');
2
- var blobStream = require('blob-stream');
3
- var ace = require('brace');
4
- require('brace/mode/javascript');
5
- require('brace/theme/monokai');
6
-
7
- var lorem =
8
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam in suscipit purus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus nec hendrerit felis. Morbi aliquam facilisis risus eu lacinia. Sed eu leo in turpis fringilla hendrerit. Ut nec accumsan nisl. Suspendisse rhoncus nisl posuere tortor tempus et dapibus elit porta. Cras leo neque, elementum a rhoncus ut, vestibulum non nibh. Phasellus pretium justo turpis. Etiam vulputate, odio vitae tincidunt ultricies, eros odio dapibus nisi, ut tincidunt lacus arcu eu elit. Aenean velit erat, vehicula eget lacinia ut, dignissim non tellus. Aliquam nec lacus mi, sed vestibulum nunc. Suspendisse potenti. Curabitur vitae sem turpis. Vestibulum sed neque eget dolor dapibus porttitor at sit amet sem. Fusce a turpis lorem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;\nMauris at ante tellus. Vestibulum a metus lectus. Praesent tempor purus a lacus blandit eget gravida ante hendrerit. Cras et eros metus. Sed commodo malesuada eros, vitae interdum augue semper quis. Fusce id magna nunc. Curabitur sollicitudin placerat semper. Cras et mi neque, a dignissim risus. Nulla venenatis porta lacus, vel rhoncus lectus tempor vitae. Duis sagittis venenatis rutrum. Curabitur tempor massa tortor.';
9
-
10
- function makePDF(PDFDocument, blobStream, lorem, iframe) {
11
- // create a document and pipe to a blob
12
- var doc = new PDFDocument();
13
- var stream = doc.pipe(blobStream());
14
-
15
- // draw some text
16
- doc.fontSize(25).text('Here is some vector graphics...', 100, 80);
17
-
18
- // some vector graphics
19
- doc
20
- .save()
21
- .moveTo(100, 150)
22
- .lineTo(100, 250)
23
- .lineTo(200, 250)
24
- .fill('#FF3300');
25
-
26
- doc.circle(280, 200, 50).fill('#6600FF');
27
-
28
- // an SVG path
29
- doc
30
- .scale(0.6)
31
- .translate(470, 130)
32
- .path('M 250,75 L 323,301 131,161 369,161 177,301 z')
33
- .fill('red', 'even-odd')
34
- .restore();
35
-
36
- // and some justified text wrapped into columns
37
- doc
38
- .text('And here is some wrapped text...', 100, 300)
39
- .font('Times-Roman', 13)
40
- .moveDown()
41
- .text(lorem, {
42
- width: 412,
43
- align: 'justify',
44
- indent: 30,
45
- columns: 2,
46
- height: 300,
47
- ellipsis: true
48
- });
49
-
50
- // end and display the document in the iframe to the right
51
- doc.end();
52
- stream.on('finish', function() {
53
- iframe.src = stream.toBlobURL('application/pdf');
54
- });
55
- }
56
-
57
- var editor = ace.edit('editor');
58
- editor.setTheme('ace/theme/monokai');
59
- editor.getSession().setMode('ace/mode/javascript');
60
- editor.setValue(
61
- makePDF
62
- .toString()
63
- .split('\n')
64
- .slice(1, -1)
65
- .join('\n')
66
- .replace(/^ /gm, '')
67
- );
68
- editor
69
- .getSession()
70
- .getSelection()
71
- .clearSelection();
72
-
73
- var iframe = document.querySelector('iframe');
74
- makePDF(PDFDocument, blobStream, lorem, iframe);
75
-
76
- let debounceTimeout;
77
-
78
- editor.getSession().on('change', function() {
79
- try {
80
- if (debounceTimeout) {
81
- clearTimeout(debounceTimeout);
82
- }
83
- var fn = new Function(
84
- 'PDFDocument',
85
- 'blobStream',
86
- 'lorem',
87
- 'iframe',
88
- editor.getValue()
89
- );
90
- debounceTimeout = setTimeout(() => {
91
- fn(PDFDocument, blobStream, lorem, iframe);
92
- debounceTimeout = undefined;
93
- }, 100);
94
- } catch (e) {
95
- console.log(e);
96
- }
97
- });