Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to EcmaScript (ES6+) #859

Merged
merged 40 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6ccaaff
remove stream extension from reference
CorvusCorrax Sep 8, 2017
f19b455
Fix font
CorvusCorrax Sep 8, 2017
fd4392d
Use buffer instead of multiple writes
CorvusCorrax Sep 13, 2017
98c4489
use buffer concat only once
CorvusCorrax Sep 19, 2017
797a160
Create embed tag name using a deterministic algorithm based on font id
blikblum Aug 7, 2018
569b53f
Add integration tests (check for generated pdf). Covers examples dist…
blikblum Aug 8, 2018
d75fdea
Add tests for tables, watermark and qrcode pdfmake demos
blikblum Aug 8, 2018
9e5b9a3
Remove tests dir from .gitignore
blikblum Aug 11, 2018
8e1aae2
Implement saving pdf files when test snapshot is updated/added. Write…
blikblum Aug 11, 2018
e101e47
Do not compress pages
blikblum Aug 12, 2018
9d7a1b7
Fix removing changed pdf
blikblum Aug 12, 2018
81e1dd8
Add eslint dependency
blikblum Aug 12, 2018
aac4065
Extract PDFFont.open class method to PDFFontFactory to break circular…
blikblum Aug 13, 2018
716ae74
Break circular reference between PDFObject and PDFReference
blikblum Aug 13, 2018
fed0e5c
Merge memory leak fixes (PR #729)
blikblum Aug 18, 2018
0449871
Update test snapshots
blikblum Aug 18, 2018
9067903
decaffeinate: Rename abstract_reference.coffee and 24 other files fro…
blikblum Aug 18, 2018
d4f32d2
decaffeinate: Convert abstract_reference.coffee and 24 other files to JS
blikblum Aug 18, 2018
2018e2b
decaffeinate: Run post-processing cleanups on abstract_reference.coff…
blikblum Aug 18, 2018
b4dba45
Fix import issues and remove constructor hack
blikblum Aug 18, 2018
e61498f
Do not try to set length property of reference buffer (Buffer instance)
blikblum Aug 19, 2018
20e3f19
Add missing var in svg test
blikblum Aug 19, 2018
ba902b0
Add dependencies and script to build
blikblum Aug 19, 2018
1e31c34
Cleanup unnecessary code generated by decaffeinate
blikblum Aug 24, 2018
9332f17
Add tests for fonts, svg path and more pdfmake demos (toc, page refer…
blikblum Aug 24, 2018
190169c
Convert document mixins to ES imports
blikblum Aug 24, 2018
07da3a3
Convert demo to EcmaScript
blikblum Aug 24, 2018
12ec776
Remove IIFE from normalizeColor method
blikblum Aug 25, 2018
c30f838
Do not bind PDFReference.finalize
blikblum Aug 25, 2018
3f170b3
Create bound _line method only once per document
blikblum Aug 25, 2018
0d3ceaa
Remove return value from flatten (list method)
blikblum Aug 25, 2018
9b420f2
Convert docs generation scripts to js
blikblum Aug 30, 2018
f057180
Ignore .vscode and coverage folders
blikblum Aug 30, 2018
114d501
Optimize toHex to accept only one argument
blikblum Aug 30, 2018
a0083c0
Create separate builds for node, browser/es5 and browser/esnext using…
blikblum Aug 30, 2018
48658fd
Fix creating browser demo bundle
blikblum Aug 30, 2018
7a09212
Add missing npm build scripts and remove makefile
blikblum Aug 30, 2018
04e7be8
Removed unused devDependencies
blikblum Aug 30, 2018
f7e4f00
Remove .babelrc file
blikblum Aug 30, 2018
8534633
Ignore irrelevant files for npm package
blikblum Aug 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "eslint:recommended"
}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
lib/font/tables/.DS_Store
.DS_Store
/node_modules/
/tests/
node-zlib/
src/
playground/
build/
js/
demo/bundle.js
*.html
!demo/browser.html
!demo/browser.html
.vscode
coverage
9 changes: 8 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ src/
lib/
docs/
playground/
index.js
.vscode/
coverage/
tests/
index.js
index.html
yarn.lock
rollup.config.js
.eslintrc
30 changes: 0 additions & 30 deletions Makefile

This file was deleted.

Binary file modified demo/out.pdf
Binary file not shown.
92 changes: 0 additions & 92 deletions demo/test.coffee

This file was deleted.

80 changes: 80 additions & 0 deletions demo/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
var PDFDocument = require('../');
var tiger = require('./tiger');
var fs = require('fs');

// Create a new PDFDocument
var doc = new PDFDocument;

doc.pipe(fs.createWriteStream('out.pdf'));

// Set some meta data
doc.info['Title'] = 'Test Document';

doc.info['Author'] = 'Devon Govett';

// Register a font name for use later
doc.registerFont('Palatino', 'fonts/PalatinoBold.ttf');

// Set the font, draw some text, and embed an image
doc.font('Palatino').fontSize(25).text('Some text with an embedded font!', 100, 100).fontSize(18).text('PNG and JPEG images:').image('images/test.png', 100, 160, {
width: 412
}).image('images/test.jpeg', 190, 400, {
height: 300
});

// Add another page
doc.addPage().fontSize(25).text('Here is some vector graphics...', 100, 100);

// 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.scale(0.6).translate(470, -380).path('M 250,75 L 323,301 131,161 369,161 177,301 z').fill('red', 'even-odd').restore(); // render an SVG path // fill using the even-odd winding rule

var loremIpsum = '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.';

// Draw some text wrapped to 412 points wide
doc.text('And here is some wrapped text...', 100, 300).font('Helvetica', 13).moveDown().text(loremIpsum, { // move down 1 line
width: 412,
align: 'justify',
indent: 30,
paragraphGap: 5
});

// Add another page, and set the font back
doc.addPage().font('Palatino', 25).text('Rendering some SVG paths...', 100, 100).translate(220, 300);

var i, len, part;
// Render each path that makes up the tiger image
for (i = 0, len = tiger.length; i < len; i++) {
part = tiger[i];
doc.save();
doc.path(part.path); // render an SVG path
if (part['stroke-width']) {
doc.lineWidth(part['stroke-width']);
}
if (part.fill !== 'none' && part.stroke !== 'none') {
doc.fillAndStroke(part.fill, part.stroke);
} else {
if (part.fill !== 'none') {
doc.fill(part.fill);
}
if (part.stroke !== 'none') {
doc.stroke(part.stroke);
}
}
doc.restore();
}

// Add some text with annotations
doc.addPage().fillColor("blue").text('Here is a link!', 100, 100, {
link: 'http://google.com/',
underline: true
});


// Add a list with a font loaded from a TrueType collection file
doc.fillColor('#000').font('fonts/Chalkboard.ttc', 'Chalkboard', 16).list(['One', 'Two', 'Three'], 100, 150);

doc.end();
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You can also read the guide in PDF form, in this directory or [online](http://pd

Both the website and the PDF guide are generated from the Literate CoffeeScript (runnable Markdown) files
in this directory. The examples are actually run when generating the PDF in order to show the results inline.
The `generate.coffee` file in this directory is actually quite short. It parses the markdown files into a
The `generate.js` file in this directory is actually quite short. It parses the markdown files into a
tree structure using [markdown-js](https://github.com/evilstreak/markdown-js), syntax highlights the code
examples using [codemirror](https://github.com/marijnh/codemirror), compiles and runs the code examples and puts the results
inline, and generates the PDF using PDFKit. You can read the generator script source code to get a feeling for
Expand Down
Loading