I am trying to create PDF/A file using PDFBOX and file genearation is done successfully but generated file is very large in size... Some times 500 MBs or even more. Is there any way to decrease file size while generation ?
As discussed in the comments: PDFont objects of a specific font should be constructed only once, and it can be reused in different pages of one PDF.
Fonts should be subsetted (i.e. that only the used glyphs are embedded), for that use PDType0Font.load()
.
The same applies to PDXObjectImage objects, e.g. for a company logo: the PDXObjectImage should be created once and be reused in different pages of one PDF.
PD objects shouldn't be used in different PDFs.
TrueTypeFont
font objects can be reused in several documents:
TrueTypeFont ttf = new TTFParser().parse(file);
PDFont font1 = PDType0Font.load(document1, ttf, true); // last parameter should be false if used for acroForm fields
PDFont font2 = PDType0Font.load(document2, ttf, true);
PDFont font3 = PDType0Font.load(document3, ttf, true);