Page numbers style body min height 900px style iframe width 95 height 800px iframe 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 async var doc new PDFDocument size 5 72 8 72 72 per inch margins top 10 left 10 right 10 bottom 10 bufferPages true let pageNumber 0 doc on pageAdded pageNumber Add page number to the bottom of the every page doc fontSize 18 fillColor deeppink text pageNumber 72 72 var stream doc pipe blobStream doc text text x y height doc page height doc text 20 10 20 doc text 50 10 50 doc text 80 10 80 doc text 110 10 110 doc text 131 10 131 doc rect 200 20 90 90 fillAndStroke orange black let text Some text with standard font doc fontSize 5 fillColor black text text repeat 50 width 200 10 const logop await fetch https notebook xbdev net var images test512 png const logo await logop arrayBuffer doc opacity 0 2 image logo 10 200 width 150 height 150 doc opacity 1 0 image logo 200 400 width 50 height 50 doc fontSize 8 opacity 1 0 font Helvetica lineGap 2 fillColor green text text repeat 200 align justify 0 0 align left Global Edits to All Pages Header Footer etc let pages doc bufferedPageRange for let i 0 i pages count i doc switchToPage i doc fontSize 20 fillColor blue moveTo 0 0 text Page i 1 of pages count 10 10 lineBreak false continued false Footer Add page number let oldBottomMargin doc page margins bottom doc page margins bottom 0 Dumb Have to remove bottom margin in order to write into it doc moveTo 0 0 text Page i 1 of pages count 0 doc page height oldBottomMargin 2 Centered vertically in bottom margin align center doc page margins bottom oldBottomMargin ReProtect bottom margin get a blob when you re done doc end var blob 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
400 width 50 height 50 doc fontSize 8 opacity 1 0 font Helvetica lineGap 2 fillColor green text text repeat 200 align justify 0 0 align left Global Edits to All Pages Header Footer etc let pages doc bufferedPageRange for let i 0 i pages count i doc switchToPage i doc fontSize 20 fillColor blue moveTo 0 0 text Page i 1 of pages count 10 10 lineBreak false continued false Footer Add page number let oldBottomMargin doc page margins bottom doc page margins bottom 0 Dumb Have to remove bottom margin in order to write into it doc moveTo 0 0 text Page i 1 of pages count 0 doc page height oldBottomMargin 2 Centered vertically in bottom margin align center doc page margins bottom oldBottomMargin ReProtect bottom margin get a blob when you re done doc end var blob 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