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 pageSize width 72 8 height 72 11 pageOrientation portrait pageMargins 72 72 72 72 content text This is a sample text fontSize 15 text This is a sample text fontSize 8 text This is a sample text fontSize 20 text This is a sample text fontSize 50 color orange margin 0 0 0 0 absolutePosition x 0 y 0 canvas type line lineWidth 3 lineColor red x1 72 y1 72 x2 72 y2 72 10 type line lineWidth 3 lineColor green x1 72 y1 72 x2 72 7 y2 72 type line lineWidth 3 lineColor blue x1 72 7 y1 72 x2 72 7 y2 72 10 type line lineWidth 3 lineColor ping x1 72 y1 72 10 x2 72 7 y2 72 10 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 div style height 700px 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
7 y2 72 10 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 div style height 700px 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