pdfkit 0.9.1 → 0.12.1

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.
package/js/virtual-fs.js CHANGED
@@ -1,44 +1,45 @@
1
1
  'use strict';
2
2
 
3
- var classCallCheck = function (instance, Constructor) {
4
- if (!(instance instanceof Constructor)) {
5
- throw new TypeError("Cannot call a class as a function");
6
- }
7
- };
8
-
9
- var VirtualFileSystem = function () {
3
+ var VirtualFileSystem = /*#__PURE__*/function () {
10
4
  function VirtualFileSystem() {
11
- classCallCheck(this, VirtualFileSystem);
12
-
13
5
  this.fileData = {};
14
6
  }
15
7
 
16
- VirtualFileSystem.prototype.readFileSync = function readFileSync(fileName) {
17
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8
+ var _proto = VirtualFileSystem.prototype;
9
+
10
+ _proto.readFileSync = function readFileSync(fileName, options) {
11
+ if (options === void 0) {
12
+ options = {};
13
+ }
18
14
 
19
15
  var encoding = typeof options === 'string' ? options : options.encoding;
20
16
  var virtualFileName = normalizeFilename(fileName);
21
-
22
17
  var data = this.fileData[virtualFileName];
18
+
23
19
  if (data == null) {
24
- throw new Error('File \'' + virtualFileName + '\' not found in virtual file system');
20
+ throw new Error("File '" + virtualFileName + "' not found in virtual file system");
25
21
  }
26
22
 
27
23
  if (encoding) {
28
24
  // return a string
29
- return typeof data === 'string' ? data : data.toString();
25
+ return typeof data === 'string' ? data : data.toString(encoding);
30
26
  }
31
27
 
32
- return new Buffer(data, typeof data === 'string' ? 'base64' : undefined);
28
+ return Buffer.from(data, typeof data === 'string' ? 'base64' : undefined);
33
29
  };
34
30
 
35
- VirtualFileSystem.prototype.writeFileSync = function writeFileSync(fileName, content) {
31
+ _proto.writeFileSync = function writeFileSync(fileName, content) {
36
32
  this.fileData[normalizeFilename(fileName)] = content;
37
33
  };
38
34
 
39
- VirtualFileSystem.prototype.bindFileData = function bindFileData() {
40
- var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
41
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
35
+ _proto.bindFileData = function bindFileData(data, options) {
36
+ if (data === void 0) {
37
+ data = {};
38
+ }
39
+
40
+ if (options === void 0) {
41
+ options = {};
42
+ }
42
43
 
43
44
  if (options.reset) {
44
45
  this.fileData = data;
package/out.pdf ADDED
@@ -0,0 +1,105 @@
1
+ %PDF-1.3
2
+ %����
3
+ 7 0 obj
4
+ <<
5
+ /Type /Page
6
+ /Parent 1 0 R
7
+ /MediaBox [0 0 612 792]
8
+ /Contents 5 0 R
9
+ /Resources 6 0 R
10
+ >>
11
+ endobj
12
+ 6 0 obj
13
+ <<
14
+ /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
15
+ /Font <<
16
+ /F1 8 0 R
17
+ >>
18
+ >>
19
+ endobj
20
+ 5 0 obj
21
+ <<
22
+ /Length 99
23
+ /Filter /FlateDecode
24
+ >>
25
+ stream
26
+ x�e�!
27
+ �@F�>��/���3
28
+ �A�`��I��q�M�� �TI���M��F�P�\Tc�����m�E��4�C����͈��:K����Vz?��
29
+ endstream
30
+ endobj
31
+ 10 0 obj
32
+ (PDFKit)
33
+ endobj
34
+ 11 0 obj
35
+ (PDFKit)
36
+ endobj
37
+ 12 0 obj
38
+ (D:20190612002759Z)
39
+ endobj
40
+ 9 0 obj
41
+ <<
42
+ /Producer 10 0 R
43
+ /Creator 11 0 R
44
+ /CreationDate 12 0 R
45
+ >>
46
+ endobj
47
+ 8 0 obj
48
+ <<
49
+ /Type /Font
50
+ /BaseFont /Helvetica
51
+ /Subtype /Type1
52
+ /Encoding /WinAnsiEncoding
53
+ >>
54
+ endobj
55
+ 4 0 obj
56
+ <<
57
+ >>
58
+ endobj
59
+ 3 0 obj
60
+ <<
61
+ /Type /Catalog
62
+ /Pages 1 0 R
63
+ /Names 2 0 R
64
+ >>
65
+ endobj
66
+ 1 0 obj
67
+ <<
68
+ /Type /Pages
69
+ /Count 1
70
+ /Kids [7 0 R]
71
+ >>
72
+ endobj
73
+ 2 0 obj
74
+ <<
75
+ /Dests <<
76
+ /Names [
77
+ ]
78
+ >>
79
+ >>
80
+ endobj
81
+ xref
82
+ 0 13
83
+ 0000000000 65535 f
84
+ 0000000719 00000 n
85
+ 0000000776 00000 n
86
+ 0000000657 00000 n
87
+ 0000000636 00000 n
88
+ 0000000208 00000 n
89
+ 0000000119 00000 n
90
+ 0000000015 00000 n
91
+ 0000000539 00000 n
92
+ 0000000464 00000 n
93
+ 0000000378 00000 n
94
+ 0000000403 00000 n
95
+ 0000000428 00000 n
96
+ trailer
97
+ <<
98
+ /Size 13
99
+ /Root 3 0 R
100
+ /Info 9 0 R
101
+ /ID [<473a27fbe87c355367d0e2025702a8da> <473a27fbe87c355367d0e2025702a8da>]
102
+ >>
103
+ startxref
104
+ 823
105
+ %%EOF
package/package.json CHANGED
@@ -9,57 +9,63 @@
9
9
  "document",
10
10
  "vector"
11
11
  ],
12
- "version": "0.9.1",
12
+ "version": "0.12.1",
13
13
  "homepage": "http://pdfkit.org/",
14
14
  "author": {
15
15
  "name": "Devon Govett",
16
16
  "email": "devongovett@gmail.com",
17
17
  "url": "http://badassjs.com/"
18
18
  },
19
+ "license": "MIT",
19
20
  "repository": {
20
21
  "type": "git",
21
22
  "url": "https://github.com/foliojs/pdfkit.git"
22
23
  },
23
24
  "bugs": "https://github.com/foliojs/pdfkit/issues",
24
25
  "devDependencies": {
25
- "babel-core": "^6.26.3",
26
- "babel-jest": "^23.6.0",
27
- "babel-plugin-external-helpers": "^6.22.0",
28
- "babel-preset-env": "^1.7.0",
26
+ "@babel/core": "^7.11.6",
27
+ "@babel/plugin-external-helpers": "^7.10.4",
28
+ "@babel/preset-env": "^7.11.5",
29
+ "babel-jest": "^26.3.0",
29
30
  "blob-stream": "^0.1.2",
30
- "brace": "^0.2.1",
31
- "brfs": "~2.0.1",
32
- "browserify": "^16.2.3",
33
- "codemirror": "~3.20.0",
34
- "eslint": "^5.3.0",
35
- "iconv-lite": "^0.4.13",
36
- "jade": "~1.1.5",
37
- "jest": "^23.4.2",
31
+ "brace": "^0.11.1",
32
+ "brfs": "~2.0.2",
33
+ "browserify": "^16.5.0",
34
+ "canvas": "^2.6.1",
35
+ "codemirror": "~5.49.2",
36
+ "eslint": "^7.8.1",
37
+ "gh-pages": "^3.1.0",
38
+ "iconv-lite": "^0.5.0",
39
+ "jest": "^26.4.2",
40
+ "jest-screenshot": "^0.3.1",
38
41
  "markdown": "~0.5.0",
39
- "prettier": "1.15.3",
40
- "rollup": "^0.65.0",
41
- "rollup-plugin-babel": "^3.0.7",
42
- "rollup-plugin-cpy": "^1.0.0"
42
+ "pdfjs-dist": "^2.4.456",
43
+ "prettier": "1.19.1",
44
+ "pug": "^2.0.4",
45
+ "rollup": "^1.27.0",
46
+ "rollup-plugin-babel": "^4.3.3",
47
+ "rollup-plugin-cpy": "^2.0.1"
43
48
  },
44
49
  "dependencies": {
45
- "crypto-js": "^3.1.9-1",
46
- "fontkit": "^1.0.0",
47
- "linebreak": "^0.3.0",
48
- "png-js": ">=0.1.0",
49
- "saslprep": "1.0.1"
50
+ "crypto-js": "^3.3.0",
51
+ "fontkit": "^1.8.1",
52
+ "linebreak": "^1.0.2",
53
+ "png-js": "^1.0.0"
50
54
  },
51
55
  "scripts": {
52
56
  "prepublishOnly": "npm run build",
53
- "build": "rollup -c",
57
+ "build": "rollup -c && browserify --standalone PDFDocument --ignore iconv-lite js/pdfkit.js > js/pdfkit.standalone.js",
54
58
  "demo": "cd demo && node test.js",
55
59
  "browser-demo": "browserify demo/browser.js > demo/bundle.js",
56
60
  "pdf-guide": "node docs/generate.js",
57
61
  "website": "node docs/generate_website.js",
62
+ "publish-website": "node docs/publish_website.js",
58
63
  "docs": "npm run pdf-guide && npm run website && npm run browser-demo",
64
+ "lint": "eslint {lib,tests}/**/*.js",
59
65
  "prettier": "prettier {lib,tests,demo,docs}/**/*.js",
60
66
  "test": "jest -i",
61
- "test:integration": "jest integration/ -i",
62
- "test:unit": "jest unit/ -i"
67
+ "test:visual": "jest visual/ -i",
68
+ "test:unit": "jest unit/"
63
69
  },
64
70
  "main": "js/pdfkit.js",
65
71
  "module": "js/pdfkit.es5.js",
@@ -77,6 +83,13 @@
77
83
  "/node_modules/",
78
84
  "<rootDir>/demo/"
79
85
  ],
80
- "testURL": "http://localhost/"
86
+ "testURL": "http://localhost/",
87
+ "setupFilesAfterEnv": [
88
+ "<rootDir>/tests/unit/setupTests.js"
89
+ ],
90
+ "reporters": [
91
+ "default",
92
+ "jest-screenshot/reporter"
93
+ ]
81
94
  }
82
- }
95
+ }
package/resultx.pdf ADDED
Binary file
package/.babelrc DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "presets": [["env", {"modules": false, "targets": {"node": "6.10"}}]],
3
- "env": {
4
- "test": {
5
- "presets": [["env", {"targets": {"node": "6.10"}}]]
6
- }
7
- }
8
- }
@@ -1,21 +0,0 @@
1
- ---
2
- name: Bug Report
3
- about: Report runtime errors or wrong PDF output
4
- ---
5
-
6
- # Bug Report
7
-
8
-
9
- ## Description of the problem
10
-
11
-
12
- ## Code sample
13
- <!-- Post code or a link to a live example (can fork from https://repl.it/@blikblum/minimal-pdfkit) that reproduces the issue -->
14
-
15
-
16
- ## Your environment
17
-
18
- * pdfkit version:
19
- * Node version:
20
- * Browser version (if applicable):
21
- * Operating System:
@@ -1,11 +0,0 @@
1
- ---
2
- name: Feature Request
3
- about: Request new features
4
- ---
5
-
6
- # Feature Request
7
-
8
- ## Feature description
9
- <!-- How the feature should work? -->
10
-
11
- <!-- You have examples or an idea how it can be implemented? -->
@@ -1,20 +0,0 @@
1
- ---
2
- name: Question
3
- about: Ask about pdfkit
4
- ---
5
-
6
- # Question
7
-
8
- ## Description
9
-
10
- <!--- Provide your question or other information that will help in solving here -->
11
-
12
- ## Code sample
13
- <!-- Post code or a link to a live example (can fork from https://repl.it/@blikblum/minimal-pdfkit) -->
14
-
15
- ## Your environment
16
-
17
- * pdfkit version:
18
- * Node version:
19
- * Browser version (if applicable):
20
- * Operating System:
@@ -1,35 +0,0 @@
1
- <!--
2
- Please make sure you are familiar with and follow the instructions in the
3
- contributing guidelines (found in the CONTRIBUTING.md file).
4
-
5
- Please fill out the information below to expedite the review and (hopefully)
6
- merge of your pull request!
7
- -->
8
-
9
- <!-- Is it a Bug fix, feature, docs update, ... -->
10
-
11
- **What kind of change does this PR introduce?**
12
-
13
- <!-- You can also link to an open issue here -->
14
-
15
- **What is the current behavior?**
16
-
17
- <!-- if this is a feature change -->
18
-
19
- **What is the new behavior?**
20
-
21
- <!-- Have you done all of these things? -->
22
-
23
- **Checklist**:
24
-
25
- <!-- add "N/A" to the end of each line that's irrelevant to your changes -->
26
- <!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
27
-
28
- - [ ] Tests (preference for unit tests)
29
- - [ ] Documentation
30
- - [ ] Update CHANGELOG.md
31
- - [ ] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
32
-
33
- <!-- feel free to add additional comments -->
34
-
35
- <!-- Thank you for contributing! -->
package/.prettierrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "singleQuote": true
3
- }
package/CONTRIBUTING.md DELETED
@@ -1,83 +0,0 @@
1
- # Contributing to pdfkit
2
-
3
- ## Table of Contents
4
-
5
- - [Contributing to pdfkit](#contributing-to-pdfkit)
6
- - [Table of Contents](#table-of-contents)
7
- - [Code Organization](#code-organization)
8
- - [Setting Up the project locally](#setting-up-the-project-locally)
9
- - [Running and writing tests](#running-and-writing-tests)
10
- - [Submitting a Pull Request](#submitting-a-pull-request)
11
-
12
-
13
- ## Code Organization
14
-
15
- pdfkit is organized in the following folders:
16
-
17
- - `lib`: The actual source code.
18
- - `js`: The built / distributable code.
19
- - `docs`: Code and artifacts to generate documentation.
20
- - `demo`: Node and browser demos.
21
- - `tests/unit`: Tests behavior of specific classes / methods.
22
- - `tests/integration`: Compare the pdf output against a reference.
23
-
24
- **Working on your first Pull Request?** You can learn how from this _free_ series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
25
-
26
- ## Setting Up the project locally
27
-
28
- To install the project you need to have `node`
29
-
30
- 1. [Fork](https://help.github.com/articles/fork-a-repo/) the project, clone your fork:
31
-
32
- ```
33
- # Clone your fork
34
- git clone https://github.com/<your-username>/pdfkit.git
35
-
36
- # Navigate to the newly cloned directory
37
- cd pdfkit
38
- ```
39
-
40
- 2. `npm install` to install dependencies
41
- 3. `npm run build` to build the library
42
- 4. `npm run demo` to run the demo (check demo/out.pdf)
43
- 5. `npm run demo-browser` to run the browser demo (check demo/browser.html)
44
-
45
- > Tip: Keep your `master` branch pointing at the original repository and make
46
- > pull requests from branches on your fork. To do this, run:
47
- >
48
- > ```
49
- > git remote add upstream https://github.com/foliojs/pdfkit.git
50
- > git fetch upstream
51
- > git branch --set-upstream-to=upstream/master master
52
- > ```
53
- >
54
- > This will add the original repository as a "remote" called "upstream,"
55
- > then fetch the git information from that remote, then set your local `master`
56
- > branch to use the upstream master branch whenever you run `git pull`.
57
- > Then you can make all of your pull request branches based on this `master`
58
- > branch. Whenever you want to update your version of `master`, do a regular
59
- > `git pull`.
60
-
61
- ## Running and writing tests
62
-
63
- Tests are run using [Jest](http://jestjs.io/) and are categorized as integration and unit tests.
64
-
65
- Integration tests check the pdf output against a reference stored as snapshots. While is served well to avoid regressions it has some disadvantages like small (correct) changes requiring to update all snapshots
66
-
67
- Unit tests checks behavior os specific classes / methods isolatedly. It covers relatively small portion of code but is preferred way of writing new tests going forward
68
-
69
- Tests commands
70
- * `npm run test`: Run all tests
71
- * `npm run test:unit`: Run unit tests
72
- * `npm run test:integration`: Run integration tests
73
-
74
- To write new tests, look for the *.spec.js files at `test/unit` and `test/integration` as examples
75
-
76
-
77
- ## Submitting a Pull Request
78
-
79
- Please go through existing issues and pull requests to check if somebody else is already working on it.
80
-
81
- Also, make sure to run the tests and lint the code before you commit your changes.
82
-
83
- **Preferentially, tests should be added to check the changed behavior even if is a bug fix. Unit tests are preferred over integration ones**