style body min height 900px style script src https github com devongovett pdfkit releases download v0 10 0 pdfkit standalone js script script src https github com devongovett blob stream releases download v0 1 3 blob stream js script script const doc new PDFDocument size A4 pipe the document to a blob const stream doc pipe blobStream add your content to the document here as usual doc fontSize 25 text Some text with standard font 100 100 Add another page doc addPage fontSize 25 text Here is some vector graphics 100 100 Draw a triangle doc save moveTo 100 150 lineTo 100 250 lineTo 200 250 fill FF3300 Apply some transforms and render an SVG path with the even odd fill rule doc scale 0 6 translate 470 380 path M 250 75 L 323 301 131 161 369 161 177 301 z fill red even odd restore Add some text with annotations doc addPage fillColor orange text Here is a link 100 100 underline 100 100 160 27 color 0000FF link 100 100 160 27 http notebook xbdev net let pageN doc addPage pageN rect 0 0 doc page width doc page height fill 302ed6 Passing size to the addPage function let page0 doc addPage size A3 page0 fontSize 45 fillColor green text Hello PDF 10 10 lineBreak false page0 fontSize 65 fillColor red text Cont same lineBreak false page0 fontSize 120 fillColor blue moveTo 0 0 text RED 10 10 lineBreak false continued false get a blob when you re done doc end const a document createElement a document body appendChild a a style display none let blob function download if blob return var url window URL createObjectURL blob a href url a download test pdf a click window URL revokeObjectURL url stream on finish function get a blob you can do whatever you like with blob stream toBlob application pdf or get a blob URL for display in the browser const url stream toBlobURL application pdf const iframe document querySelector iframe iframe src url console log ready script div PDF Output button onclick download Download button div iframe width 95 height 800px iframe
ght fill 302ed6 Passing size to the addPage function let page0 doc addPage size A3 page0 fontSize 45 fillColor green text Hello PDF 10 10 lineBreak false page0 fontSize 65 fillColor red text Cont same lineBreak false page0 fontSize 120 fillColor blue moveTo 0 0 text RED 10 10 lineBreak false continued false get a blob when you re done doc end const a document createElement a document body appendChild a a style display none let blob function download if blob return var url window URL createObjectURL blob a href url a download test pdf a click window URL revokeObjectURL url stream on finish function get a blob you can do whatever you like with blob stream toBlob application pdf or get a blob URL for display in the browser const url stream toBlobURL application pdf const iframe document querySelector iframe iframe src url console log ready script div PDF Output button onclick download Download button div iframe width 95 height 800px iframe