Every line of 'javascript convert html to pdf source code' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
47 async function createPDF(html) { 48 let browser: any = null; 49 try { 50 browser = await getPuppeteer(); 51 const page = await browser.newPage(); 52 await page.setContent(html); 53 return await page.pdf(pdfOptions); 54 } catch (error) { 55 throw error; 56 } finally { 57 if (browser) { 58 await browser.close(); 59 } 60 } 61 }
214 function convertSamplePdf() { 215 hideError(); 216 id = 'samplePDF.pdf'; 217 clearFileUpload(); 218 fileExtension = 'pdf'; 219 220 $('.download--input-icon').attr('href', '/files/' + id + '?download=true'); 221 222 var displayPdf = '<div>' + 223 '' + 224 '' + '' + '</div>'; 225 226 $('._content--choose-output-format.active').removeClass('active'); 227 $('._content--output.active').removeClass('active'); 228 $('._content--choose-output-format').addClass('active'); 229 $('#display_input_doc').html(displayPdf); 230 $('.sample--list-item-tab.active').removeClass('active'); 231 $('.upload--container.active').removeClass('active'); 232 $('.format--list-item-tab.active').removeClass('active'); 233 $('.sample--list-item-tab:eq(2)').addClass('active'); 234 $('.code--output-code').empty(); 235 236 var top = document.getElementById('upload-your-document').offsetTop; 237 window.scrollTo(0, top); 238 }
71 public get pdfSrc() { 72 return this._src; 73 }
67 public set pdfSrc(_src: string | Blob | Uint8Array) { 68 this._src = _src; 69 }
4 function createPDF() { 5 var pdf = new jsPDF('p', 'pt', 'letter'); 6 7 source = $j('#content')[0]; 8 9 specialElementHandlers = { 10 11 '#bypassme': function (element, renderer) { 12 // true = "handled elsewhere, bypass text extraction" 13 return true; 14 } 15 }; 16 margins = { 17 top: 80, 18 bottom: 60, 19 left: 40, 20 width: 522 21 }; 22 23 pdf.fromHTML( 24 source, // HTML string or DOM elem ref. 25 margins.left, // x coord 26 margins.top, { // y coord 27 'width': margins.width, // max width of content on PDF 28 'elementHandlers': specialElementHandlers 29 }, 30 31 function (dispose) { 32 pdf.save('Test.pdf'); 33 }, margins); 34 }