-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathPDFServer.js
27 lines (20 loc) · 1.09 KB
/
PDFServer.js
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
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.writeHead(200, {'Content-Type': 'application/pdf'});
var hummus = require('hummus');
var pdfWriter = hummus.createWriter(new hummus.PDFStreamForResponse(res));
var page = pdfWriter.createPage(0,0,595,842);
pdfWriter.startPageContentContext(page).writeText('Hello ' + (req.query.id ? req.query.id : 'World'),
0,400,
{
font:pdfWriter.getFontForFile('../tests/TestMaterials/fonts/arial.ttf'),
size:50,
colorspace:'gray',
color:0x00
});
pdfWriter.writePage(page);
pdfWriter.end();
res.end();
});
app.listen(3000);