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KAAK,OAAO,aAAa,EAAK,IAAI,KAC5D,EAAK,KAAK,EACZ,CAEA,OAAO,QAAQ,QAAQ,GACpB,MAAK,eAAe,GAElB,aADM,EAAQ,QACP,CACV,IAAG,WAAW,EAClB,CApFA,OAAO,QAsFP,OAAO,QAAQ,YAAc,YAC7B,OAAO,QAAQ,aAAe","file":"/npm/html-pdf-node2@1.0.7/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/html-pdf-node2@1.0.7/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const puppeteer = require('puppeteer');\nvar Promise = require('bluebird');\nconst hb = require('handlebars')\n\nmodule.exports\nasync function generatePdf(file, options, callback) {\n  // we are using headless mode\n  let args = [\n    '--no-sandbox',\n    '--disable-setuid-sandbox',\n  ];\n  let executablePath = options.executablePath;\n  if(options.args) {\n    args = options.args;\n    delete options.args;\n  }\n\n  const browser = await puppeteer.launch({\n    args: args,\n    executablePath: executablePath\n  });\n  const page = await browser.newPage();\n\n  if(file.content) {\n    console.log(\"Compiling the template with handlebars\")\n    // we have compile our code with handlebars\n    const template = hb.compile(file.content, { strict: true });\n    const result = template(file.content);\n    const html = result;\n\n    // We set the page content as the generated html by handlebars\n    await page.setContent(html);\n  } else {\n    await page.goto(file.url, {\n      waitUntil: 'networkidle0', // wait for page to load completely\n    });\n  }\n\n  return Promise.props(page.pdf(options))\n    .then(async function(data) {\n       await browser.close();\n\n       return Buffer.from(Object.values(data));\n    }).asCallback(callback);\n}\n\nasync function generatePdfs(files, options, callback) {\n  // we are using headless mode\n  let args = [\n    '--no-sandbox',\n    '--disable-setuid-sandbox',\n  ];\n  if(options.args) {\n    args = options.args;\n    delete options.args;\n  }\n  let executablePath = options.executablePath;\n  const browser = await puppeteer.launch({\n    args: args,\n    executablePath: executablePath\n  });\n  let pdfs = [];\n  const page = await browser.newPage();\n  for(let file of files) {\n    if(file.content) {\n      console.log(\"Compiling the template with handlebars\")\n      // we have compile our code with handlebars\n      const template = hb.compile(file.content, { strict: true });\n      const result = template(file.content);\n      const html = result;\n      // We set the page content as the generated html by handlebars\n      await page.setContent(html);\n    } else {\n      await page.goto(file.url, {\n        waitUntil: 'networkidle0', // wait for page to load completely\n      });\n    }\n    let pdfObj = JSON.parse(JSON.stringify(file));\n    delete pdfObj['content'];\n    pdfObj['buffer'] = Buffer.from(Object.values(await page.pdf(options)));\n    pdfs.push(pdfObj);\n  }\n\n  return Promise.resolve(pdfs)\n    .then(async function(data) {\n       await browser.close();\n       return data;\n    }).asCallback(callback);\n}\n\nmodule.exports.generatePdf = generatePdf;\nmodule.exports.generatePdfs = generatePdfs;\n"]}