Add Margin to PDF File When Merging Using Pdftk or Similar

Alternative `pdftk multistamp` to `pdftk` once it's no longer available?

I started a Java port of pdftk a few months back; at this point it should have the same functionality as the C++ version but a lot more testing is needed. If you want to give it a try, check https://gitlab.com/pdftk-java/pdftk and file a bug report when it breaks.

pdftk: multistamp: [File size increase after multistamp] vs [total text added due to multistamp] looks unreasonable

I think it is not that unreasonable. There is quite a bit of overhead for each page in addition to the numbers: headers, dimensions, font selection, positioning... this can easily take 200 bytes per page, or close to 1MB. Include a font and that takes some more space.

When you use pdftk to overlay the files, you get even more overhead: now you have to record which page goes where, in which position, how to scale it, etc. Again, a few bytes per page, but when you have 4k pages it shows.

You may wonder how is it possible to have a 4k page PDF with only 7.5MB in size. Once you have all the headers of a page in place, the text contents can be compressed, and if it is a simple text-only PDF it will compress well.

Of course it is possible to add the page numbers directly to each page, by modifying the contents of the pages, and that will have a way lower overhead, maybe 20 bytes per page, but then you will need a more precise tool than pdftk, which needs the overhead in order to be generic.

Perhaps a middle ground is to use a tool like pdfjam, see this recent question: How to add footer to pdf with pdfjam or pdftk?.



Related Topics



Leave a reply



Submit