tango-app-api-payment-subscription 3.1.5 → 3.1.7

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.5",
3
+ "version": "3.1.7",
4
4
  "description": "paymentSubscription",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,6 +24,7 @@
24
24
  "jsdom": "^24.0.0",
25
25
  "mongodb": "^6.4.0",
26
26
  "nodemon": "^3.1.0",
27
+ "puppeteer": "^22.9.0",
27
28
  "swagger-ui-express": "^5.0.0",
28
29
  "tango-api-schema": "^2.0.92",
29
30
  "tango-app-api-middleware": "^3.1.7",
@@ -17,7 +17,8 @@ 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
- import htmlpdf from 'html-pdf-node';
20
+ // import htmlpdf from 'html-pdf-node';
21
+ import puppeteer from 'puppeteer';
21
22
  export const addBilling = async ( req, res ) => {
22
23
  try {
23
24
  let params = {
@@ -2411,24 +2412,45 @@ export const invoiceDownload = async ( req, res ) => {
2411
2412
  const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/invoicePdf.hbs', 'utf8' );
2412
2413
  const template = Handlebars.compile( templateHtml );
2413
2414
  const html = template( { ...invoiceData } );
2414
- let file = {
2415
- content: html,
2416
- };
2417
- let options = {
2418
- path: `../../invoice/test.pdf}`,
2419
- format: 'A4', margin: {
2420
- top: '0.5in',
2421
- right: '0.5in',
2422
- bottom: '0.5in',
2423
- left: '0.5in',
2415
+ // let file = {
2416
+ // content: html,
2417
+ // };
2418
+ const browser = await puppeteer.launch( {
2419
+ headless: true, // Set to false if you need to debug
2420
+ args: [ '--no-sandbox', '--disable-setuid-sandbox' ],
2421
+ } );
2422
+ const page = await browser.newPage();
2423
+ await page.setContent( html, { timeout: 60000 } );
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',
2424
2432
  },
2425
- printBackground: true, preferCSSPageSize: true,
2426
- };
2427
- htmlpdf.generatePdf( file, options ).then( async function( pdfBuffer ) {
2428
- res.set( 'Content-Disposition', 'attachment; filename="generated-pdf.pdf"' );
2429
- res.set( 'Content-Type', 'application/pdf' );
2430
- res.send( pdfBuffer );
2431
2433
  } );
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
+ // } );
2432
2454
  }
2433
2455
 
2434
2456