We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Export Docx to PDF with embedded fonts generates big size PDF using .NET

Hi,

I am trying to convert a Docx to a PDF. Aspose generates a really large PDF file when embedded font option is enabled. Is there a reason for that? can we have a smaller PDF even with embedded fonts ?

Here is the code. I am using the latest Aspose.word DLL.
– With Embedded Fonts enabled

PdfSaveOptions options = new PdfSaveOptions();

options.EmbedFullFonts = true;

 Aspose.Words.Document doc = new Aspose.Words.Document("NDI.docx");            

 // Save the document in PDF format. 
 doc.Save("SaveDoc2Pdf.pdf", options);

I have attached 3 files:

  1. NDI.docx
  2. NDI_with_Embedded_fonts.pdf ( 28 MB ) - Unable to upload this due to file size.
  3. NDI_without_embedded_fonts.pdf (186 KB )

NDI_without_embedded_fonts.zip (216.6 KB)

@imran.khan1

You are facing the expected behavior of Aspose.Words. When the value of PdfSaveOptions.EmbedFullFonts property is set to true, a complete font file is embedded into PDF without subsetting. This will result in larger output files, but can be a useful option when you want to edit the resulting PDF later (e.g. add more text).

You can use PdfSaveOptions.FontEmbeddingMode property as shown below to reduce the PDF file size.

PdfSaveOptions options = new PdfSaveOptions(); 
options.FontEmbeddingMode = PdfFontEmbeddingMode.EmbedNone;

Is there a way to embed subset of fonts?

Also I have found this in the documentation, is this applicable here ?

OptimizationOptions.SubsetFonts Property

Thanks
Imran

@imran.khan1

When the value of PdfSaveOptions.EmbedFullFonts property is false, the fonts are subsetted before embedding.