I'm using iText 7
library (v7.0.5.0). I create a PDF file (A-1B Conformance) from a RadDiagram
(Telerik library) in .Net
.
When the PDF file is generated, in its properties (Acrobat Reader > File > Properties > Fonts), there are a lot of brought fonts by the file, but only 4 master fonts, with variants (Arial, Segoe, Tahoma, TimesNewRoman).
I can see that there are a lot of duplicate fonts with the same name.
If I save the file from Acrobat Reader to "reduced PDF file", all of the duplicate fonts are purged, to keep only 1 font for each font names.
I search a solution to programatically remove these duplicate fonts because these duplicate fonts significantly increase the PDF file size. With the Acrobat Reader compression, the file size decrease from 2,2 Mo to 906 Ko (without quality loss).
You can find here an example of my PDF file.
This file has :
- 8 ArialMT
- 3 SegoeUI
This is an example, but sometimes, my files are very big, and for example, the compression decrease the size from 16 Mo to 1 Mo because there is a lot of duplicate fonts.
[EDIT] About my use case :
From RadDiagram
Telerik objects, I export them into a PDF file like an image. This PDF file (with only 1 page), is serialized to Bytes()
and saved into database. At a specific step, all of serialized PDF are concatened into a global PDF file.
Clearly, the problem is when I save each PDF file, because at each creation, I call this code :
_pdfFont = PdfFontFactory.CreateFont(FONT_PATH_ARIAL, PdfEncodings.IDENTITY_H, True)
Declarations :
Private Const FONT_PATH_ARIAL As String = "c:\windows\fonts\Arial.ttf"
Private _pdfFont As PdfFont
The _pdfFont
object is called at each SetFont()
method.
But the creation step is important because when I close de Document object, this one needs to know the font, which iwas created only for it.
A the end, this the same font (they have the same name), but each font is not merged, and so they are added, in the global PDF file.
[End Edit]
Thanks a lot.