Skip to content

Commit 586ac82

Browse files
committed
updating examples, bundling lib
1 parent 58a0ab7 commit 586ac82

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

Readme.md

+33-34
Original file line numberDiff line numberDiff line change
@@ -54,40 +54,39 @@
5454

5555
</script>
5656
### node.js -
57-
var sys = require('sys');
58-
var pdf = require('./lib/pdf').pdf;
59-
var fs = require('fs');
60-
61-
var today = new Date().getTime();
62-
63-
var doc = new pdf();
64-
doc.text(20, 20, 'hello, I am a PDF file.');
65-
doc.text(20, 30, 'i was created using node.js version: ' + process.version);
66-
doc.text(20, 40, 'It allows for meta data. This Page has a title, subject, author, keywords and a creator.');
67-
doc.text(20, 50, 'sup mang');
68-
69-
// Optional - set properties on the document
70-
doc.setProperties({
71-
title: 'A sample document created by pdf.js',
72-
subject: 'PDFs are kinda cool, i guess',
73-
author: 'Marak Squires',
74-
keywords: 'pdf.js, javascript, Marak, Marak Squires',
75-
creator: 'pdf.js'
76-
});
77-
78-
79-
doc.addPage();
80-
81-
doc.setFontSize(22);
82-
doc.text(20, 20, 'This is a title');
83-
84-
doc.setFontSize(16);
85-
doc.text(20, 30, 'This is some normal sized text underneath.');
86-
87-
fs.writeFile('test.pdf', doc.output(), function(err, data){
88-
sys.puts('file written');
89-
});
90-
57+
var sys = require('sys');
58+
var fs = require('fs');
59+
var pdf = require('./lib/pdf').pdf;
60+
61+
/* create the PDF document */
62+
63+
var doc = new pdf();
64+
doc.text(20, 20, 'hello, I am PDF.');
65+
doc.text(20, 30, 'i was created using node.js version: ' + process.version);
66+
doc.text(20, 40, 'i can also be created from the browser');
67+
68+
/* optional - set properties on the document */
69+
doc.setProperties({
70+
title: 'A sample document created by pdf.js',
71+
subject: 'PDFs are kinda cool, i guess',
72+
author: 'Marak Squires',
73+
keywords: 'pdf.js, javascript, Marak, Marak Squires',
74+
creator: 'pdf.js'
75+
});
76+
doc.addPage();
77+
78+
doc.setFontSize(22);
79+
doc.text(20, 20, 'This is a title');
80+
81+
doc.setFontSize(16);
82+
doc.text(20, 30, 'This is some normal sized text underneath.');
83+
84+
var fileName = "testFile"+new Date().getSeconds()+".pdf";
85+
86+
fs.writeFile(fileName, doc.output(), function(err, data){
87+
sys.puts(fileName +' was created! great success!');
88+
});
89+
9190
## Authors
9291
#### Marak Squires and Matthew Bergman
9392
Heavily inspired by James Hall's jsPDF

0 commit comments

Comments
 (0)