Saving To PDF document size is increasing

Questions, comments and suggestions concerning VintaSoft PDF .NET Plug-in.

Moderator: Alex

Post Reply
IntegraMike
Posts: 56
Joined: Mon Dec 02, 2019 11:19 pm

Saving To PDF document size is increasing

Post by IntegraMike »

Hello, I'm running into a strange issue that I'm hoping there might be a quick answer for. In a released version of our product, which currently uses version 9.1.2.23 of the Imaging library we're seeing files increase in size by about 400kb per PdfFreeTextAnnotation that is being added when we save.

The save code is just doing ImageViewer.Images.SaveSync(destinationFile, pdfEncoder).

Interestingly your demo application does not appear to have this problem, but does seem to be using the same save as well as encoder settings. Do you have any idea why this might be? Looking at the resulting document in a text editor it looks like the issue is embedding fonts, is there a way to remove embedded fonts?

Specifically I think that entries like this (followed by a bunch of ASCII) are the issue, but I'm unsure where they're coming from.

Code: Select all

<</Type/Font/Subtype/Type0/BaseFont/CourierNewPSMT/DescendantFonts[35 0 R]/Encoding/Identity-H/ToUnicode 36 0 R>>
endobj
35 0 obj
<</Type/Font/Subtype/CIDFontType2/BaseFont/CourierNewPSMT/FontDescriptor 33 0 R/CIDSystemInfo<</Registry(Adobe)/Ordering(Identity)/Supplement 0>>/CIDToGIDMap/Identity/W[0[600 0] 2 3761 600 3762[600]]>>
endobj
36 0 obj
<</Filter/FlateDecode/Length 8849>>
Any help you can provide would be much appreciated!
Alex
Site Admin
Posts: 2045
Joined: Thu Jul 10, 2008 2:21 pm

Re: Saving To PDF document size is increasing

Post by Alex »

Hello Mike,

For understanding the problem we need to reproduce the problem on our side. Please send us (to support@vintasoft.com) a small console project, which allows to reproduce the problem.

Best regards, Alexander
IntegraMike
Posts: 56
Joined: Mon Dec 02, 2019 11:19 pm

Re: Saving To PDF document size is increasing

Post by IntegraMike »

In trying to build you a demo project I may have figured out what's going on. I will be spending a little more time on that, but I wanted to give you an update. What it looks like is happening is that when a system font is used it is automatically added to the PDF, which is increasing the size. It might also be getting added for each annotation (I haven't had time to determine this yet).

That being said, is there a good way to remove fonts from a pdf when I save?
Alex
Site Admin
Posts: 2045
Joined: Thu Jul 10, 2008 2:21 pm

Re: Saving To PDF document size is increasing

Post by Alex »

Hello Mike,

When you create instance of PdfFreeTextAnnotation class, you need to specify PDF font for drawing the annotation text. PDF font can be get or set using the PdfFreeTextAnnotation.Font property.

If you have several instances of PdfFreeTextAnnotation, you need to create single instance of PDF font and use the same PDF font for all instances of PdfFreeTextAnnotation. This will prevent duplication of PDF fonts.

If you forgot to use the same PDF font for all annotations, you can delete duplicate resources from PDF document using the PdfDocumentCleanupCommand class with enabled PdfDocumentCleanupCommand.RemoveDuplicateResources property. Also instead of PdfDocumentCleanupCommand class you can use the PdfDocument.RemoveDuplicateResources method.

Best regards, Alexander
Post Reply