1

I have a pdf of filesize 7.5MB and pages 4000

I wanted to add pagenumber at the bottom. So i have another blank pdf of pages 4000 with only pages numbers at the bottom. Its filesize 2MB

Now using pdftk option multistamp i am adding page number to the bottom

pdftk file_without_pagenumbers.pdf multistamp only_pagenumbers.pdf output file_with_pagenumbers.pdf

The file size of file_with_pagenumbers.pdf is 11MB. The file size increased almost 4MB for adding page numbers.

I feel the amount of text added due to pagenumbers will not be more than 0.5MB worth. i.e 1 to 4000 numbers may be another 10 pages of text.

So for additional 10 pages of text, increase of 4MB filesize looks unreasonable for me

Can any one help me how to reduce file size after multistamp while using pdftk

Santhosh
  • 9,965
  • 20
  • 103
  • 243

1 Answers1

0

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?.

  • How to customize the location of the page number in `pagecommand={\thispagestyle{fancy}}`. I am using `pdfjam --no-tidy --pagecommand '\thispagestyle{fancy}'`. Like the height from the bottom,left,right and top of the page – Santhosh Jul 25 '20 at 16:38