File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77[ Example Receipt] ( http://public.admintools.ch/gh/html-pdf/order.pdf )
88
9+ ## Installation
910
10- ## Example
11+ Install the html-pdf utility via [ npm] ( http://npmjs.org/ ) :
12+
13+ ```
14+ $ npm install -g html-pdf
15+ ```
16+
17+ ## Command-line example
18+
19+ ```
20+ $ htmlpdf test/businesscard.html businesscard.pdf
21+ ```
22+
23+ ## Code example
1124``` javascript
1225var fs = require (' fs' );
1326var pdf = require (' html-pdf' );
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ var fs = require ( 'fs' ) ;
4+ var pdf = require ( '../' ) ;
5+
6+ var args = process . argv . slice ( 2 ) ;
7+
8+ if ( args . length >= 2 ) {
9+ htmlpdf ( args [ 0 ] , args [ 1 ] ) ;
10+ } else {
11+ help ( ) ;
12+ }
13+
14+ function help ( ) {
15+ var help = 'Usage: htmlpdf input.html output.pdf' ;
16+ console . log ( help ) ;
17+ }
18+
19+ function htmlpdf ( input , output ) {
20+ var html = fs . readFileSync ( input , 'utf8' ) ;
21+
22+ pdf . create ( html ) . toFile ( output , function ( err , res ) {
23+ if ( err ) return console . log ( err ) ;
24+ } ) ;
25+ }
Original file line number Diff line number Diff line change 66 "directories" : {
77 "test" : " test"
88 },
9+ "bin" : {
10+ "htmlpdf" : " cli/index.js"
11+ },
912 "scripts" : {
1013 "test" : " coffee --compile --output lib/ src/ && coffee test/index.coffee -n"
1114 },
You can’t perform that action at this time.
0 commit comments