PDF Make Example style body min height 800px style script src https cdnjs cloudflare com ajax libs pdfmake 0 1 56 pdfmake min js script script src https cdnjs cloudflare com ajax libs pdfmake 0 1 56 vfs_fonts js script script var vfs1 pdfMake vfs script script src https notebook xbdev net var resources vfs_fonts_times js script script var vfs2 pdfMake vfs script script src https cdn jsdelivr net npm pdfjs dist 2 0 385 build pdf min js script script pdfMake vfs vfs1 vfs2 pdfMake fonts Roboto normal Roboto Regular ttf bold Roboto Medium ttf italics Roboto Italic ttf bolditalics Roboto Italic ttf All 4 components must be defined TimesNewRoman normal Times Regular ttf bold Times Bold ttf italics Times Italic ttf bolditalics Times BoldItalic ttf 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 font TimesNewRoman text This is a sample text fontSize 50 font Roboto text This is a sample text fontSize 50 color orange margin 0 0 0 0 absolutePosition x 0 y 0 canvas type polyline lineWidth 3 closePath true lineColor green dash length 5 space 10 points x 72 y 72 x 72 7 y 72 x 72 7 y 72 10 x 72 y 72 10 defaultStyle font TimesNewRoman 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
polyline lineWidth 3 closePath true lineColor green dash length 5 space 10 points x 72 y 72 x 72 7 y 72 x 72 7 y 72 10 x 72 y 72 10 defaultStyle font TimesNewRoman 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