PDF Make Example script type text javascript src https cdnjs cloudflare com ajax libs pdfmake 0 1 56 pdfmake min js script script type text javascript src https cdnjs cloudflare com ajax libs pdfmake 0 1 56 vfs_fonts js script script type text javascript async function downloadPdf const logop await fetch https notebook xbdev net var images test512 png const logo await logop arrayBuffer var docDefinition content text This is a sample text image logo absolutePosition x 200 y 200 width 200 height 100 opacity 0 1 defaultStyle pdfMake createPdf docDefinition open console log ready script button onclick downloadPdf PDF with your code button PDF Make Example style body min height 800px style script type text javascript src https cdnjs cloudflare com ajax libs pdfmake 0 1 56 pdfmake min js script script type text javascript src https cdnjs cloudflare com ajax libs pdfmake 0 1 56 vfs_fonts js script script src https cdn jsdelivr net npm pdfjs dist 2 0 385 build pdf min js script script type text javascript var docDefinition content text This is a sample text defaultStyle function renderPDF url canvasContainer options options options scale 1 4 function renderPage page const viewport page getViewport options scale const div document createElement div document body appendChild div div style width 500px const canvas document createElement canvas canvas style width 100 canvas style height 100 div appendChild canvas const ctx canvas getContext 2d const renderContext canvasContext ctx viewport viewport canvas height viewport height canvas width viewport width page render renderContext function renderPages pdfDoc for let num 1 num pdfDoc numPages num pdfDoc getPage num then renderPage PDFJS disableWorker true PDFJS getDocument url then renderPages pdfMake createPdf docDefinition getDataUrl dataURL renderPDF dataURL document getElementById canvas console log ready script
javascript var docDefinition content text This is a sample text defaultStyle function renderPDF url canvasContainer options options options scale 1 4 function renderPage page const viewport page getViewport options scale const div document createElement div document body appendChild div div style width 500px const canvas document createElement canvas canvas style width 100 canvas style height 100 div appendChild canvas const ctx canvas getContext 2d const renderContext canvasContext ctx viewport viewport canvas height viewport height canvas width viewport width page render renderContext function renderPages pdfDoc for let num 1 num pdfDoc numPages num pdfDoc getPage num then renderPage PDFJS disableWorker true PDFJS getDocument url then renderPages pdfMake createPdf docDefinition getDataUrl dataURL renderPDF dataURL document getElementById canvas console log ready script