RTF to PDF full Embedded fonts

Hi,

I am evaluating Aspose.Word and, even if I set

PdfSaveOptions options = new PdfSaveOptions();
options.EmbedFullFonts = true;

The converted pdf only include “subset” of the fonts.

What shoud be done to ensure all fonts are fully embedded, not only a subset ?

Thanks in advance.

N. Fortin

Hi Nicolas,

Thanks for your query. Please use the latest version of Aspose.Words for .NET. If you still face problem, please share your RTF file for investigation purposes.

PdfSaveOptions.EmbedFullFonts

The default value is false, which means the fonts are subsetted before embedding. Subsetting is useful if you want to keep the output file size smaller. Subsetting removes all unused glyphs from a font. When this value 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).

Hi,

the last version doesn’t help but maybe there is a error on the usage example. According to the article here https://docs.aspose.com/words/net/convert-a-document-to-pdf/

the code should only be :

// Load the document to render.
Document doc = new Document(MyDir + "Rendering.doc");
// Aspose.Words embeds full fonts by default when EmbedFullFonts is set to true. The property below can be changed
// each time a document is rendered.
PdfSaveOptions options = new PdfSaveOptions();
options.EmbedFullFonts = true;
// The output PDF will be embedded with all fonts found in the document.
doc.Save(MyDir + "Rendering.EmbedFullFonts Out.pdf");

Remark that the created class PdfSaveOptions is not used in the Save call.

I than though the new operator on the PdfSaveOptions class may have returned a singleton instence but, if I create a secons object type PdfSaveOptions, just after setting EmbedFullFonts = true, the property is still false so, it isn’t a class singleton new operator.

Is there a error on the example ?

An example of rtf file (adn a converted pdf) are attached.

Thanks in advance

Hi Nicolas,

Thanks for your query. In documentation’s example, the PdfSaveOptions parameter is missing in save method. We will update the example code at following documentation link.

https://docs.aspose.com/words/net/convert-a-document-to-pdf/

Please use the following code snippet for your requirement. I have attached the output PDF file with this post.

// Load the document to render.
Document doc = new Document(MyDir + "HELLOWorld.rtf");
// Aspose.Words embeds full fonts by default when EmbedFullFonts is set to true. The property below can be changed
// each time a document is rendered.
PdfSaveOptions options = new PdfSaveOptions();
options.EmbedFullFonts = true;
// The output PDF will be embedded with all fonts found in the document.
doc.Save(MyDir + "Rendering.EmbedFullFonts Out.pdf", options);

We apologize for your inconvenience.

Hi Tahir,

thanks for your answer, that did the trick

The produced file are huge : is there a way to compact them otherwise than keeping fonts subsets ?

Thanks in advance

N. Fortin

Hi Nicolas,

Thanks for your query.

PdfSaveOptions.EmbedFullFonts

The default value is false, which means the fonts are subsetted before embedding. Subsetting is useful if you want to keep the output file size smaller. Subsetting removes all unused glyphs from a font. When this value 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).

Some fonts are large (several megabytes) and embedding them without subsetting will result in large output documents.

Size of PDF documents can be reduced only by doing the following:

  1. Decreasing size of images inside PDF (this can be done only be decreasing quality) : PdfSaveOptions.JpegQuality .
  2. Subseting fonts, which are embedded into the PDF documents. (Aspose.Words does this by default).
  3. Compression of text (Usually decreasing of size is not very big) : PdfSaveOptions.TextCompression

Please let us know if you have any more queries.

Hi,

thanks for your last answer.

I have a case here where I need your advise. I’ll find a zip file in this post containing four files.

-file fichier_source.rtf : which is the base file to convert;

-file conversion_scriptCPC_rtf_to_pdf.pdf : which is the base file, converted with font subsets (for reference only);

- file conversion_Ghostscript_pdf_to_pdf.pdf : which is an sample of the base file, converted with GhostScript / PsToEdit with full embedded fonts;

- file conversion_ASPOSE_rtf_to_pdf.pdf : which is the base file, converted with Aspose, with full embedded fonts.

Notice the size difference between conversion_Ghostscript_pdf_to_pdf.pdf and onversion_ASPOSE_rtf_to_pdf.pdf

I’d like to understand why there is a so big difference.

Thanks in advance.

N. Fortin

Hi Nicolas,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word do. File size depends on the fonts size embedded in documents. If you embed font in RTF document by using MS Word (WordOptions->Save->Embed fonts in file) and save the file, the file size is increased.

However, I will investigate this issue in more detail and will update you asap.

Hi Tahir,

Thanks for your answer.

I’m very glad to read this because I just cannot understand the size difference.

Thanks in advance.

N. Fortin

Hi Nicolas,

Thanks for your patience.

Please note that Aspose.Words mimics the same behavior as MS Word do. If you convert your document to PDF by using MS Word, the output PDF file size will be almost same. The value of PdfSaveOptions.EmbedStandardWindowsFonts is True by default and this increase the PDF file size. If you do not want to embed standard windows fonts Arial and Times New Roman, please use its value as false.

Document doc = new Document(MyDir + @"fichier_source.rtf");
PdfSaveOptions options = new PdfSaveOptions();
options.EmbedFullFonts = true;
options.EmbedStandardWindowsFonts = false;
doc.Save(MyDir + @"AsposeOut.pdf", options);

As I shared with you in my last post, the file size depends on the fonts size embedded in documents. If you embed font in RTF document by using MS Word (WordOptions->Save->Embed fonts in file) and save the file, the file size is increased.

Hope this answers your query. Please let us know if you have any more queries.

Hi Tahir,

I understand what you mean about what can increase and decrease pdf file size. But, how can you explain the size difference between the file conversion_Ghostscript_pdf_to_pdf.pdf (which is a sample of the base file, converted with GhostScript / PsToEdit with full embedded fonts) and the file conversion_ASPOSE_rtf_to_pdf.pdf (which is a sample of the base file, converted with aspose also with full embedded fonts) ?

Thanks in advance

N. Fortin

Hi Nicolas,

Thanks for your inquiry. As I share with you earlier that Aspose.Word tries to mimic the same behavior as MS Word.

nicolasfortin:

- file conversion_Ghostscript_pdf_to_pdf.pdf : which is an sample of the base file, converted with GhostScript / PsToEdit with full embedded fonts;

If you are converting PDF to PDF with embedded fonts, You can post such queries at Aspose.PDF forum.

Hope this answers your query. Please let us know if you have any more queries.

Hi,

I understand what you mean but that doesn’t explains the file size difference between the two tool.

I it possible to understand that ?

Thanks in advance.

N. Fortin

Hi Nicolas,

Thanks for your inquiry. Could you please attach your input file used for GhostScript / PsToEdit here for testing? It would be great if you please share the complete details how you convert PDF to PDF (conversion_Ghostscript_pdf_to_pdf.pdf) by using GhostScript. I will investigate the issue on my side and provide you more information.

Hi,

the file is attached in the post ID 422808 : https://forum.aspose.com/t/51135

Thanks in advance,

N. Fortin

Hi Nicolas,

Thanks for sharing the information. The shared PDF file is output PDF file by using GhostScript.

tahir.manzoor:

Could you please attach your input file used for GhostScript / PsToEdit here for testing? It would be great if you please share the complete details how you convert PDF to PDF (conversion_Ghostscript_pdf_to_pdf.pdf) by using GhostScript. I will investigate the issue on my side and provide you more information.

Can you please share the details how you convert a PDF to PDF with embedded fonts by using GhostScript?

Hi Tahir,

Maybe I didn’t understood your question ou was unclear. Maybe I don’t understand what you mean by the input file.

The process we’d like the be replaced with aspose is the full fonts embedding in an existing pdf.

In the zip, you have the file conversion_scriptCPC_rtf_to_pdf.pdf which was obtained from a the rtf file in the zip.

Now, this file is currently updated by a call to PsToEdit to force font embedding.

Our actual result of this is the file conversion_Ghostscript_pdf_to_pdf.pdf which is quite small, about ten time smaller than the file obtained by a conversion from aspose, which result file is conversion_ASPOSE_rtf_to_pdf.pdf.

So, if I understand well what you requested (the input file passed to PsToEdit), this is the file conversion_scriptCPC_rtf_to_pdf.pdf.

Is there a way for you to analyze / compare the full embedded font files, in term of size?

Thanks in advance for all your time.

N. Fortin

Hi Nicolas,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word not as PsToEdit/Ghostscript. It would be great if you please share complete details about PsToEdit. How you use this command in which software to generate an embedded PDF file? I have downloaded PsToEdit from following link.

http://www.pstoedit.net/pstoedit

Hi,

First, I was wrong about the usage of PsToEdit, the tool used is GhostScript.

The tool is called by using a simple command line.

The command used is :

gswin32c.exe -sOutputFile=“new_file.pdf” -dLOCALFONTS -sFONTPATH=“C:\WINDOWS\Fonts” -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE#pdfwrite -dCompatibilityLevel#1.4 -dPDFSETTINGS#/printer -dMaxSubsetPct#0 -dSubsetFonts#false -dEmbedAllFonts#true “input_file.pdf”

If you require more informations, feel free to get back to me.

Again, thanks for all your time.

N. Fortin

Hi Nicolas,

Thanks for sharing the additional information. These are two different approaches to generate PDF with embedded fonts. 1) By using Aspose.Words RTF to PDF 2) using GhostScript (PDF to PDF). I will check the GhostScript and will share my finding with you.

Thank you for your patience and understanding.