This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

iText: Reduce size of PDFs generated from PDF forms

 
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
  • 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: 88
  • Mark post as helpful
  • send pies
  • 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
  • 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: 88
  • Mark post as helpful
  • send pies
  • 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.
 
What are your superhero powers? Go ahead and try them on this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!