-
Notifications
You must be signed in to change notification settings - Fork 528
Expand file tree
/
Copy pathtest.js
More file actions
28 lines (23 loc) · 786 Bytes
/
test.js
File metadata and controls
28 lines (23 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const test = require('tape')
const pdf = require('../../')
const path = require('path')
const fs = require('fs')
test('allows custom html and css', function (t) {
t.plan(3)
const template = path.join(__dirname, 'businesscard.html')
const filename = template.replace('.html', '.pdf')
let templateHtml = fs.readFileSync(template, 'utf8')
const image = path.join('file://', __dirname, 'image.png')
templateHtml = templateHtml.replace('{{image}}', image)
const options = {
width: '50mm',
height: '90mm'
}
pdf
.create(templateHtml, options)
.toFile(filename, function (err, pdf) {
t.error(err)
t.assert(pdf.filename, 'Returns the filename')
t.assert(fs.existsSync(pdf.filename), 'Saves the file to the desired destination')
})
})