Embedded fonts lost when saving to PDF

Hello,

From what I found in your forum, Aspose.Words does not currently support embedded fonts when saving to PDF. I understand this is issue #7626 in your database.

Are there any known workarounds, or an estimated date for solving this issue?

Thanks.

Hi

Thanks for your request. Unfortunately, embedded fonts are still not supported upon converting to PDF and it is very difficult to provide you any reliable estimate regarding this issue at the current stage.

Also, I cannot suggest you any workaround. The only thing you can do is avoiding using embedded fonts in your documents and installing these fonts on PC where you perform conversion.

Best regards.

Is the lack of support for embedded fonts in contradiction to the API help manual ?

The Aspose.PDF chm has this information:

Font Embedding while Word2Pdf Conversion

While converting a Word document containing custom font information into Pdf, we must call SetUnicode(); in order to set all fonts in the doucment to unicode and this method should be called before saving the Pdf file. Please refer to following code snippet.


Followed by this:


We can also set the property value pdf1.TextInfo.IsFontEmbedded = true; instead of calling SetUnicode() As a result it will embed the whole font description into resultant Pdf and it may increase the size of Pdf.


The fonts I need to use are installed on the PC where the conversion is being done, but as this is served up by a webserver and the fonts are licensed there is no way we can put them on the client where the PDF is being viewed even if it would help.

Hi

Thanks for your request. Fonts are embedded into PDF document by default. Please see the following link for more information:

Best regards.

Hi,

My original question was about reading embedded fonts from a Word document. I think your example concerns writing embedded fonts to a PDF document.

My understanding is that you cannot read any fonts you have embedded in a Word document but don’t have installed in the server that’s running Aspose.

On the other hand however, you can embed any fonts you do have installed in the resulting PDF document to ensure it displays correctly in any client machines.

Hi

Yes, you are right, Aspose.Words cannot read fonts embedded into Word documents. However, fonts installed on your PC can be embedded into the resulting PDF document.

Best regards.

Thanks for your reply Alexy, but I am not any closer to a working solution.

I have tried using Aspose.Words 6.3.0 and 6.4.0.

Version 6.4.0 simply times out. It never returns from methods called on the Document object (including save(), savetopdf(), and even accessing attributes such as PageCount). Is this a known problem ? I have seen one other post where someone reported something similar.

Setting the attributes as suggested in your example did not embed the fonts in the PDF document. I could also confirm this from the PDF properties in Adobe Reader. None of the non-standard fonts in the original word document were reported as being used in the PDF.

The fonts are installed on the machine where the conversion is taking place, which is also where the PDF is being viewed.

Hi

Thanks for your inquiry. Could you please attach the document that causes the problems? Also, you can attach fonts, which are used in your document.

I will check them on my side and provide you more information.

Best regards.

Attached is the word document generated by the server application before conversion to PDF.
Also attached is a zip file containing the fonts used.
Please note these are licensed fonts. Also, the word document is produced from a “template” which is created and maintained by the system admin. Data is merged into the template from a database. The application (on the server) does not “know” which fonts will be used in what part of the document, so the font can not be set dynamically at run time.

Thanks and Regards,
Andrew

Hi

Thank you for additional information. For some reason, I cannot convert your document to PDF. Aspose.Words just eats 100% of CPU and never finishes conversion. I will notify you as soon as this problem is fixed.

Best regards.

I am also having an issue with Words saving as PDF with embedded fonts that are lost.

I have tried a number of differnt options found in your forums and nothing seems to work.

I have tried the code lsited below with every possible combination in between, skipping lines etc. and checking each file before and after the save and nothing seems to work. The font I am using is: IDAutomationHC39S. Attached is the font and test.doc that I am using.

I am currently using the latest version of Aspose.NET.Total, so any solution involving all your products would be great.

Here is thesample code.

Document doc = new Document("test.doc");
Aspose.Words.Rendering.PdfOptions pdfOptions = new Aspose.Words.Rendering.PdfOptions();
pdfOptions.IsEmbedTrueTypeFontsForAsciiChars = true;
doc.SaveToPdf(0, doc.PageCount, "test.pdf", pdfOptions);
// Save the doc in a xml file that can be handled by Aspose.Pdf.
doc.Save("test.xml", SaveFormat.AsposePdf);
doc.Save("test.pdf", SaveFormat.Pdf);
doc.Save("test.pdf");
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML("test.xml", null);
pdf.SetUnicode();
pdf.TextInfo.IsFontEmbedded = true;
pdf.IsAutoFontAdjusted = true;
pdf.IsTruetypeFontMapCached = true;
pdf.TruetypeFontMapPath = Path.GetTempPath();
pdf.Save("test.pdf");

Please Help as this is a big issue for our release.

Thanks

Graham Marko

I’ve got a very simple document, 1 line of text, using Inconsolata (a free font), and the latest total.net – doc.SaveToPDF() fails to embed the font in the document. It’s an OTF. If I save the word document to another location, or clone it, the font is still used, but not in the PDF.

This code actually worked:

Document doc = new Document("test.doc");
doc.Save("test.xml", SaveFormat.AsposePdf);
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML("test.xml", null);
pdf.SetUnicode();
pdf.TextInfo.IsFontEmbedded = true;
pdf.Save("test.pdf");

Hi

Graham, Thank you for additional information. Using the latest version of Aspose.Words (6.5.0), which was release few hours ago, I can successfully convert your document to PDF. I can see, the following fonts are using in your document:

Times New Roman
Futura Std Condensed Light
Futura Std ExtraBold
Futura Std Book
Verdana
Tahoma
Arial Narrow
Futura LT CondensedBold

I highlighted fonts that were not embedded. But they were not embedded because such fonts are not installed. I cannot find these fonts in the archive you have attached. So, please make sure the fonts are installed.

Mark, please attach your document and font here for testing. I will check your issue and provide you more information.

Best regards.

Thanks Alexey - that is the same problem I see using Words 6.4.0

It is not just saving/converting that causes it to eat CPU and not finished. Even accessing the value of an attribute (Eg. PageCount) will cause this to happen.

I have had to resort to using the legacy method of saving as AsposePDF (XML), binding to that, and then loading it into a Pdf object. I had been doing that using Words 5.2.2 !!

This font is licensed by our customer, and being able to use it is a critical issue for their compliance and marketing people.

Hi Andrew,

Thank you for additional information. Conversion to PDF works fine with the latest version of Aspose.Words (6.5.0). You can download it from here:

Also, please attach your document here for testing.

Best regards.

Thanks Alexey.

I have had to download a temporary license for 6.5.0 (our subscription just missed it, but I will be renewing in the next few days).
I was able to use 6.5.0 with the temporary license OK, but I still don’t see the embedded fonts in the PDF document.
I have attached the sample document again FYI. Can you confirm you can embed the fonts in the generated PDF and attach the pdf please ?

Hi Andrew,

Thanks for your request. Please attach also the following fonts:

  • Futura Std Condensed Light
  • Futura Std ExtraBold
  • Futura Std Book
  • Futura LT CondensedBold

Best regards.

Hi Alexey.

These were in a file I attached previously, but I have attached them again as requested.

Cheers,
Andrew

Hi

Thank you for additional information. I managed to reproduce the problem with Futura Std fonts. You will be notified as soon as the problem is resolved.

Best regards