Reduce PDF file size in itext (java)

I am creating a web-based label printing system. There must be a single s / n for each label. Therefore, when the user decided to create 1000 tags (with the same data), all of them should have a unique s / n, so there will be 1000 pages in pdf, which increases the file size.

My problem is that the user decided to create more copies, the file size will become larger.

Is there a way to reduce pdf file size using Itext? Or can I create a PDF file and display it in a browser without saving it on the server / client hard drive?

Thanks for the help!

0
source share
2 answers

In merge mode, file compression is used. It must be highly compressible.

(I assume that you should be able to create PDF files on the server side without writing them to disk, although you could use a lot of memory / Java in this process. I don’t think that you can deliver the PDF to the browser without the file going to the client PC’s hard drive in one form or another.)

0
source

If everything except s / n is the same for thousands of shortcuts, you only need to add the same things once as a template and put the text s / n in it.

Check out the PDFTemplate in itext. If I remember correctly what XObject creates for a repeating drawing / label / image .... and this is exactly the same object every time you use it.

Even with thousands of shortcuts, the only thing that increases the size of your document is s / n (and each page), but the graphics or text β€œtags” are added only once. This should reduce the size of your file.

0
source

All Articles