tango-app-api-payment-subscription 3.1.7 → 3.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-payment-subscription",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.8",
|
|
4
4
|
"description": "paymentSubscription",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,9 +24,8 @@
|
|
|
24
24
|
"jsdom": "^24.0.0",
|
|
25
25
|
"mongodb": "^6.4.0",
|
|
26
26
|
"nodemon": "^3.1.0",
|
|
27
|
-
"puppeteer": "^22.9.0",
|
|
28
27
|
"swagger-ui-express": "^5.0.0",
|
|
29
|
-
"tango-api-schema": "^2.0.
|
|
28
|
+
"tango-api-schema": "^2.0.94",
|
|
30
29
|
"tango-app-api-middleware": "^3.1.7",
|
|
31
30
|
"winston": "^3.12.0",
|
|
32
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -17,8 +17,7 @@ import path from 'path';
|
|
|
17
17
|
// import pdfMake from 'pdfmake';
|
|
18
18
|
// import htmlToPdfmake from 'html-to-pdfmake';
|
|
19
19
|
import axios from 'axios';
|
|
20
|
-
|
|
21
|
-
import puppeteer from 'puppeteer';
|
|
20
|
+
import htmlpdf from 'html-pdf-node';
|
|
22
21
|
export const addBilling = async ( req, res ) => {
|
|
23
22
|
try {
|
|
24
23
|
let params = {
|
|
@@ -2412,45 +2411,23 @@ export const invoiceDownload = async ( req, res ) => {
|
|
|
2412
2411
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/invoicePdf.hbs', 'utf8' );
|
|
2413
2412
|
const template = Handlebars.compile( templateHtml );
|
|
2414
2413
|
const html = template( { ...invoiceData } );
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
const pdfBuffer = await page.pdf( {
|
|
2425
|
-
format: 'A4',
|
|
2426
|
-
printBackground: true,
|
|
2427
|
-
margin: {
|
|
2428
|
-
top: '20px',
|
|
2429
|
-
right: '20px',
|
|
2430
|
-
bottom: '20px',
|
|
2431
|
-
left: '20px',
|
|
2414
|
+
let file = {
|
|
2415
|
+
content: html,
|
|
2416
|
+
};
|
|
2417
|
+
let options = {
|
|
2418
|
+
format: 'A4', margin: {
|
|
2419
|
+
top: '0.5in',
|
|
2420
|
+
right: '0.5in',
|
|
2421
|
+
bottom: '0.5in',
|
|
2422
|
+
left: '0.5in',
|
|
2432
2423
|
},
|
|
2424
|
+
printBackground: true, preferCSSPageSize: true,
|
|
2425
|
+
};
|
|
2426
|
+
htmlpdf.generatePdf( file, options ).then( async function( pdfBuffer ) {
|
|
2427
|
+
res.set( 'Content-Disposition', 'attachment; filename="generated-pdf.pdf"' );
|
|
2428
|
+
res.set( 'Content-Type', 'application/pdf' );
|
|
2429
|
+
res.send( pdfBuffer );
|
|
2433
2430
|
} );
|
|
2434
|
-
await browser.close();
|
|
2435
|
-
res.set( 'Content-Disposition', 'attachment; filename="generated-pdf.pdf"' );
|
|
2436
|
-
res.set( 'Content-Type', 'application/pdf' );
|
|
2437
|
-
res.send( pdfBuffer );
|
|
2438
|
-
|
|
2439
|
-
// let options = {
|
|
2440
|
-
// path: `../../invoice/test.pdf`,
|
|
2441
|
-
// format: 'A4', margin: {
|
|
2442
|
-
// top: '0.5in',
|
|
2443
|
-
// right: '0.5in',
|
|
2444
|
-
// bottom: '0.5in',
|
|
2445
|
-
// left: '0.5in',
|
|
2446
|
-
// },
|
|
2447
|
-
// printBackground: true, preferCSSPageSize: true,
|
|
2448
|
-
// };
|
|
2449
|
-
// htmlpdf.generatePdf( file, options ).then( async function( pdfBuffer ) {
|
|
2450
|
-
// res.set( 'Content-Disposition', 'attachment; filename="generated-pdf.pdf"' );
|
|
2451
|
-
// res.set( 'Content-Type', 'application/pdf' );
|
|
2452
|
-
// res.send( pdfBuffer );
|
|
2453
|
-
// } );
|
|
2454
2431
|
}
|
|
2455
2432
|
|
|
2456
2433
|
|