Skip to content

Commit f5fe191

Browse files
committed
Move the example directory to examples
1 parent 543a918 commit f5fe191

File tree

8 files changed

+25
-6
lines changed

8 files changed

+25
-6
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
*.pdf
2-
!example/businesscard.pdf
2+
!examples/businesscard.pdf
33
node_modules

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# node-html-pdf
22
## HTML to PDF converter that uses phantomjs
3-
![image](example/businesscard.png)
4-
[Example Business Card](example/businesscard.pdf)
5-
-> [and its Source file](example/businesscard.html)
3+
![image](examples/businesscard.png)
4+
[Example Business Card](examples/businesscard.pdf)
5+
-> [and its Source file](examples/businesscard.html)
66

77
[Example Receipt](http://imgr-static.s3-eu-west-1.amazonaws.com/order.pdf)
88

example/businesscard.pdf

-21.2 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/serve-http/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const fs = require('fs')
2+
const http = require('http')
3+
const pdf = require('../../')
4+
const tmpl = fs.readFileSync(require.resolve('../businesscard/businesscard.html'), 'utf8')
5+
6+
const server = http.createServer(function (req, res) {
7+
if (req.url === '/favicon.ico') return res.end('404')
8+
const html = tmpl.replace('{{image}}', `file://${require.resolve('../businesscard/image.png')}`)
9+
pdf.create(html, {width: '50mm', height: '90mm'}).toStream((err, stream) => {
10+
if (err) return res.end(err.stack)
11+
res.setHeader('Content-type', 'application/pdf')
12+
stream.pipe(res)
13+
})
14+
})
15+
16+
server.listen(8080, function (err) {
17+
if (err) throw err
18+
console.log('Listening on http://localhost:%s', server.address().port)
19+
})

test/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ test('pdf.create(html[, options]).toStream(callback)', function (t) {
9393
test('allows custom html and css', function (t) {
9494
t.plan(3)
9595

96-
var template = path.join(__dirname, '../example/businesscard.html')
96+
var template = path.join(__dirname, '../examples/businesscard/businesscard.html')
9797
var filename = template.replace('.html', '.pdf')
9898
var templateHtml = fs.readFileSync(template, 'utf8')
9999

100-
var image = path.join('file://', __dirname, '../example/image.png')
100+
var image = path.join('file://', __dirname, '../examples/businesscard/image.png')
101101
templateHtml = templateHtml.replace('{{image}}', image)
102102

103103
var options = {

0 commit comments

Comments
 (0)