• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

iText: Reduce size of PDFs generated from PDF forms

 
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hej,

we are evaluating to use iText for invoice generation. Right now we have PDF forms that work as layout templates. Filling in and generating the PDFs works. But as soon as fields are filled in the generated PDFs get quite large, from a few kilobytes to megabytes. What is the best way to avoid this? The generated invoices do not need to have any form-related functionality; is it a bad idea to use forms as templates?

Thanks.
 
author
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hauke Ingmar Schmidt wrote:Hej,

we are evaluating to use iText for invoice generation. Right now we have PDF forms that work as layout templates. Filling in and generating the PDFs works. But as soon as fields are filled in the generated PDFs get quite large, from a few kilobytes to megabytes. What is the best way to avoid this? The generated invoices do not need to have any form-related functionality; is it a bad idea to use forms as templates?

Thanks.



Let me give you an example:

I have a datasheet that is 56.54 KB.
I want to use this template to create a document with 120 pages: one page per movie in my moviedatabase.
If I don't read the documentation, I end up with this document with file size 4.84 MB.
If I read the documentation, I end up with a document containing the same information and file size 304.36 KB.

In the first case, the document size consists of 120 times the size of the template + the size of the content of the fields + some necessary overhead. In the second case, the document size consists of 1 times the size of the template + the size of the content of the fields + some necessary overhead. Not using a template will result in a file with about the same size.

Is this more or less the problem you're experiencing?

If not, there are some other reasons why the filesize of a template that is filled in can get huge: are you adding high resolution images? Are you embedding complete fonts? (See the thread about optimization, more specifically about font subsets.)
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.

I am not the implementing this, so I will have to talk to the developer to get hard facts.

The document consists of different pages with different templates. The pages are merged into one document after processing. If I regenerate the PDFs as pure pages, i.e. if I print them with a PDF writer or let the media designer do some Adobe magic, the file size is much smaller than the files generated by iText. This lead me to the assumption that there is a form overhead that could be removed by a (simple?) conversion.
 
Bruno Lowagie
author
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hauke Ingmar Schmidt wrote:Thank you.

I am not the implementing this, so I will have to talk to the developer to get hard facts.

The document consists of different pages with different templates. The pages are merged into one document after processing. If I regenerate the PDFs as pure pages, i.e. if I print them with a PDF writer or let the media designer do some Adobe magic, the file size is much smaller than the files generated by iText. This lead me to the assumption that there is a form overhead that could be removed by a (simple?) conversion.



If fonts are the culprit, then the Adobe magic will beat iText. (You need better font management to solve this.)
If redundant templates and/or images are causing the problem, then the developer should use PdfSmartCopy instead of PdfCopy.
 
reply
    Bookmark Topic Watch Topic
  • New Topic