|
|
@ -56,10 +56,10 @@ app.get('/Invoice', async (req, res) => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
async function printPDF() { |
|
|
|
async function printPDF(id) { |
|
|
|
const browser = await puppeteer.launch({ headless: true }); |
|
|
|
const browser = await puppeteer.launch({ headless: true }); |
|
|
|
const page = await browser.newPage(); |
|
|
|
const page = await browser.newPage(); |
|
|
|
await page.goto('http://localhost:9091/Invoice?id=2', { waitUntil: 'networkidle0' }); |
|
|
|
await page.goto(`http://localhost:${port}/Invoice?id=${id}`, { waitUntil: 'networkidle0' }); |
|
|
|
const pdf = await page.pdf({ |
|
|
|
const pdf = await page.pdf({ |
|
|
|
format: 'A4', displayHeaderFooter: true, |
|
|
|
format: 'A4', displayHeaderFooter: true, |
|
|
|
headerTemplate: ``, |
|
|
|
headerTemplate: ``, |
|
|
@ -76,8 +76,8 @@ async function printPDF() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
app.get('/getAmazonInvoicePDF', async (req, res) => { |
|
|
|
app.get('/getAmazonInvoicePDF', async (req, res) => { |
|
|
|
let file = [{ url: "http://localhost:9091/Invoice?id=2", name: 'AmazonInvoice.pdf' }]; |
|
|
|
let file = [{ url: `http://localhost:${port}/Invoice?id=${req.query.id}`, name: 'AmazonInvoice.pdf' }]; |
|
|
|
printPDF().then(pdf => { |
|
|
|
printPDF(req.query.id).then(pdf => { |
|
|
|
res.set({ 'Content-Type': 'application/pdf', 'Content-Length': pdf.length }) |
|
|
|
res.set({ 'Content-Type': 'application/pdf', 'Content-Length': pdf.length }) |
|
|
|
res.send(pdf) |
|
|
|
res.send(pdf) |
|
|
|
}) |
|
|
|
}) |
|
|
|