Skip to content

Commit 9e12b1a

Browse files
Yujith IsuraYujith Isura
Yujith Isura
authored and
Yujith Isura
committed
first commit
0 parents  commit 9e12b1a

File tree

8 files changed

+1137
-0
lines changed

8 files changed

+1137
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
documents/index.js
3+
.DS_Store
4+
.DS_STORE
5+
.DS_Store

documents/.DS_Store

6 KB
Binary file not shown.

documents/header-logo.jpg

122 KB
Loading

index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const express = require('express');
2+
const bodyParser = require('body-parser');
3+
const pdf = require('html-pdf');
4+
const cors = require('cors');
5+
6+
const pdfTemplate = require('./documents');
7+
8+
const app = express();
9+
10+
const port = process.env.PORT || 5000;
11+
12+
app.use(cors());
13+
app.use(bodyParser.urlencoded({extended: true}));
14+
app.use(bodyParser.json());
15+
16+
app.post('/create-pdf', (req, res) => {
17+
console.log("hhhhhhhhhhh",res);
18+
pdf.create(pdfTemplate(req.body), {}).toFile('result.pdf', (err) => {
19+
if(err) {
20+
res.send(Promise.reject());
21+
}
22+
23+
res.send(Promise.resolve());
24+
});
25+
});
26+
27+
app.get('/fetch-pdf', (req, res) => {
28+
res.sendFile(`${__dirname}/result.pdf`)
29+
})
30+
31+
app.listen(port, () => console.log(`Listening on port ${port}`));

0 commit comments

Comments
 (0)