This is a migrated thread and some comments may be shown as answers.

RadFlowDocument to PDF - ArialNarrow font issues

4 Answers 517 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 03 Nov 2015, 09:02 PM

Hello,

I have a RadFlowDocument that I am exporting to PDF via the standard flow PDFFormatProvider. If the document has some text that used the Arial Narrow font that is either bold, italicized or both the PDF output is always showing just plain Arial Narrow. This seems to be the only font that is having this problem.

Has anyone else encountered this or have any suggestions on how to fix it?

Thanks,

-Tom

4 Answers, 1 is accepted

Sort by
0
Accepted
Deyan
Telerik team
answered on 06 Nov 2015, 11:12 AM
Hello Tom,

Thank you for contacting us about this issue.

PdfProcessing uses internally Typeface.TryGetGlyphTypeface method in order to access font files installed on the machine. However, while debugging the issue I have noticed that there is a bug in this method and it always returns the normal "Arial Narrow" font file path even when we require the bold or italic version of this font. A similar issue with this font is discussed in this MSDN forum post.

You can easily workaround this issue by simply register the correct font files before doing the PDF export. I am attaching a demo project that shows how exactly this can be achieved. A few words about this demo:
  • It is a console application.
  • Before exporting the PDF the RegisterWrongFontPaths method is executed. This method basically gets the bytes of the correct font files and registers them for the corresponding font properties.
  • Alternatively, you can embed the font files in you project and access the embedded font file bytes. This way you will not access the fonts from the file system and the program will be working even on machines where the "Arial Narrow" font files are not installed. 
  • When the demo program finishes, it opens the exported PDF file, so that you can view the result.

I hope this information is helpful. If you have any other questions or concerns please do not hesitate to contact us again.

Regards,
Deyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tom
Top achievements
Rank 1
answered on 06 Nov 2015, 07:34 PM

Hi Deyan,

 Thank you for your reply. This approach works perfectly. Thanks!

-Tom

0
Jozef
Top achievements
Rank 1
answered on 14 Jun 2019, 12:19 PM
Hello, we are implementing a solution to generate PDF files from DOCX documents filled with database data, using Progress Telerik UI for WPF R1 2019 libraries. Input documents uses Arial Narrow as a default font. PDF files are generated correctly except for Bold text is changed to Normal text.

Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider _docxFormatProvider = new Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider();
Telerik.Windows.Documents.Model.RadDocument radDocument = _docxFormatProvider.Import(System.IO.File.ReadAllBytes("input.docx"));
Telerik.Windows.Documents.FormatProviders.Pdf.PdfFormatProvider _pdfFormatProvider = new Telerik.Windows.Documents.FormatProviders.Pdf.PdfFormatProvider();
System.IO.File.WriteAllBytes("output.pdf", _pdfFormatProvider.Export(radDocument));

We have tried to use Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider, but some parts of document wasn't formatted correctly (position of a table, ..), so we need a solution for Telerik.Windows.Documents.FormatProviders.Pdf.PdfFormatProvider.
0
Georgi
Telerik team
answered on 19 Jun 2019, 12:12 PM
Hello Jozef,

The internal implementation of the PdfFormatoProvider used in the demo project Deyan has provided uses the PdfProcessing library when exporting to PDF. The mechanism to register fonts in the PdfProcessing library, provides custom implementation allowing to map them by name, weight and style. However, the PdfFormatoProvider, part of the RadRichTextBox control, has different implementation and the mechanism for font registration is built and dependent on the .NET framework. For this reason, the solution from the demo project wouldn't work for this format provider. This issue has already been discussed in the forum, however, since it's related to the .NET framework implementation, I am afraid that we couldn't find any workaround to provide you with.

Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
PdfProcessing
Asked by
Tom
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Tom
Top achievements
Rank 1
Jozef
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or