From 3322c016e4e8906ccc483983166f3b3f00239716 Mon Sep 17 00:00:00 2001 From: KB Bot Date: Tue, 6 Aug 2024 11:10:43 +0000 Subject: [PATCH 1/3] Added new kb article preserve-font-boldness-pdf-export-radspreadprocessing --- ...boldness-pdf-export-radspreadprocessing.md | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md diff --git a/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md b/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md new file mode 100644 index 00000000..f2dbb033 --- /dev/null +++ b/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md @@ -0,0 +1,54 @@ +--- +title: Preserving the Font in PDF Export from Excel +description: Learn how to preserve the bold text when converting Excel documents to PDF using RadSpreadProcessing. +type: how-to +page_title: How to Keep Text Boldness in PDF Conversion with RadSpreadProcessing +slug: preserve-font-boldness-pdf-export-radspreadprocessing +tags: spreadprocessing, document, processing, pdf export, font, registration, bold, text +res_type: kb +ticketid: 1659898 +--- + +## Environment + +| Version | Product | Author | +| --- | --- | ---- | +| .NET Framework| RadSpreadProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)| + +## Description + +When converting Excel documents in .NET Framework applications to PDF using RadSpreadProcessing, the bold text in the Excel file might not appear bold in the exported PDF. The font also may be changed in the exported PDF. This issue often arises due to the PDF export process using a different font than the one specified in the Excel document. For instance, the PDF export might default to using "Arial" font, while the original Excel document uses "Aptos Narrow". + +This KB article also answers the following questions: +- How to ensure text boldness is preserved in PDF exports? +- How to register custom fonts for PDF export in RadSpreadProcessing? +- How to handle font discrepancies between Excel documents and PDF exports? + +## Solution + +To preserve the font and the bold text when exporting an Excel document to PDF, it is necessary to register the font used in the Excel document if it is not part of the [standard fonts]({%slug radpdfprocessing-concepts-fonts%}) supported by the PDF export process. Follow these steps to register a custom font: + +1. **Read the font** from the file system. Ensure you include both the regular and bold versions of the font if applicable. + +2. **Create a `FontFamily`** instance for the custom font. + +3. **Register the font** with the `FontsRepository`. Ensure to register both the regular and bold variations of the font to cover all text styles in the document. + +```csharp + // Read the font file + byte[] fontDataAptos = File.ReadAllBytes(@"..\..\..\fonts\Aptos-Narrow.ttf"); + byte[] fontDataAptosBold = File.ReadAllBytes(@"..\..\..\fonts\Aptos-Narrow-Bold.ttf"); + + System.Windows.Media.FontFamily fontFamilyAptos = new System.Windows.Media.FontFamily("Aptos Narrow"); + + // Register the font + Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.RegisterFont(fontFamilyAptos, System.Windows.FontStyles.Normal, System.Windows.FontWeights.Normal, fontDataAptos); + Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.RegisterFont(fontFamilyAptos, System.Windows.FontStyles.Normal, System.Windows.FontWeights.Bold, fontDataAptosBold); +``` + +By following these steps, the exported PDF document will correctly display text in bold that was bold in the original Excel document, using the custom font. If other fonts are used in the Excel document, they also should be registered in a similar way. + +## See Also + +- [Fonts in RadPdfProcessing]({%slug radpdfprocessing-concepts-fonts%}) +- [Registering a Font](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/concepts/fonts#registering-a-font) From 955572e1357a02f06efa0b70bc90eedc2cb2e462 Mon Sep 17 00:00:00 2001 From: Desislava Yordanova Date: Tue, 27 Aug 2024 17:24:27 +0300 Subject: [PATCH 2/3] adding links --- .../preserve-font-boldness-pdf-export-radspreadprocessing.md | 5 +++-- libraries/radpdfprocessing/concepts/fonts.md | 1 + .../formats-and-conversion/pdf/pdfformatprovider.md | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md b/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md index f2dbb033..f740b5c5 100644 --- a/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md +++ b/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md @@ -17,7 +17,7 @@ ticketid: 1659898 ## Description -When converting Excel documents in .NET Framework applications to PDF using RadSpreadProcessing, the bold text in the Excel file might not appear bold in the exported PDF. The font also may be changed in the exported PDF. This issue often arises due to the PDF export process using a different font than the one specified in the Excel document. For instance, the PDF export might default to using "Arial" font, while the original Excel document uses "Aptos Narrow". +When converting Excel documents in .NET Framework applications to PDF format using [RadSpreadProcessing]({%slug radspreadprocessing-overview%}), the bold text in the Excel file might not appear bold in the exported PDF. The font also may be changed in the exported PDF. This issue often arises due to the PDF export process using a different font than the one specified in the Excel document. For instance, the PDF export might default to using "Arial" font, while the original Excel document uses "Aptos Narrow". This KB article also answers the following questions: - How to ensure text boldness is preserved in PDF exports? @@ -32,7 +32,7 @@ To preserve the font and the bold text when exporting an Excel document to PDF, 2. **Create a `FontFamily`** instance for the custom font. -3. **Register the font** with the `FontsRepository`. Ensure to register both the regular and bold variations of the font to cover all text styles in the document. +3. [Register the font](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/concepts/fonts#registering-a-font) with the `FontsRepository`. Ensure to register both the regular and bold variations of the font to cover all text styles in the document. ```csharp // Read the font file @@ -52,3 +52,4 @@ By following these steps, the exported PDF document will correctly display text - [Fonts in RadPdfProcessing]({%slug radpdfprocessing-concepts-fonts%}) - [Registering a Font](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/concepts/fonts#registering-a-font) +- [Using PdfFormatProvider]({%slug radspreadprocessing-formats-and-conversion-pdf-pdfformatprovider%}) diff --git a/libraries/radpdfprocessing/concepts/fonts.md b/libraries/radpdfprocessing/concepts/fonts.md index 18cfb05f..22aec158 100644 --- a/libraries/radpdfprocessing/concepts/fonts.md +++ b/libraries/radpdfprocessing/concepts/fonts.md @@ -137,4 +137,5 @@ You can create fonts that are not explicitly registered. Creating a font that is * [Cross-Platform Support for Fonts]({%slug radpdfprocessing-cross-platform-fonts%}) * [FontsRepository](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.html) * [TextFragment]({%slug radpdfprocessing-model-textfragment%}) + * [Preserving the Font in PDF Export from Excel]({%slug preserve-font-boldness-pdf-export-radspreadprocessing%}) diff --git a/libraries/radspreadprocessing/formats-and-conversion/pdf/pdfformatprovider.md b/libraries/radspreadprocessing/formats-and-conversion/pdf/pdfformatprovider.md index 25b6a56a..49ae097a 100644 --- a/libraries/radspreadprocessing/formats-and-conversion/pdf/pdfformatprovider.md +++ b/libraries/radspreadprocessing/formats-and-conversion/pdf/pdfformatprovider.md @@ -72,4 +72,5 @@ The result from the export method is a document that can be opened in any applic - [How to Eliminate Formatting Issues when Exporting XLSX to PDF Format]({%slug exporting-xlsx-to-pdf-formatting-issues%}) - [Import/Load and Export/Save RadSpreadProcessing Workbook]({%slug import-export-save-load-workbook%}) - [Export Worksheet to image]({%slug spreadprocessing-export-worksheet-to-image-netstandard%}) +- [Preserving the Font in PDF Export from Excel]({%slug preserve-font-boldness-pdf-export-radspreadprocessing%}) From aea90231427f5e5becf059ae31163fcdde6f20e8 Mon Sep 17 00:00:00 2001 From: Desislava Yordanova Date: Wed, 4 Sep 2024 18:09:30 +0300 Subject: [PATCH 3/3] addressed feedback --- ...preserve-font-boldness-pdf-export-radspreadprocessing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md b/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md index f740b5c5..5c2d8373 100644 --- a/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md +++ b/knowledge-base/preserve-font-boldness-pdf-export-radspreadprocessing.md @@ -2,9 +2,9 @@ title: Preserving the Font in PDF Export from Excel description: Learn how to preserve the bold text when converting Excel documents to PDF using RadSpreadProcessing. type: how-to -page_title: How to Keep Text Boldness in PDF Conversion with RadSpreadProcessing +page_title: How to Preserve Text Boldness in PDF Conversion with RadSpreadProcessing slug: preserve-font-boldness-pdf-export-radspreadprocessing -tags: spreadprocessing, document, processing, pdf export, font, registration, bold, text +tags: spreadprocessing, document, processing, pdf export, font, registration, bold, text, pdf, export res_type: kb ticketid: 1659898 --- @@ -17,7 +17,7 @@ ticketid: 1659898 ## Description -When converting Excel documents in .NET Framework applications to PDF format using [RadSpreadProcessing]({%slug radspreadprocessing-overview%}), the bold text in the Excel file might not appear bold in the exported PDF. The font also may be changed in the exported PDF. This issue often arises due to the PDF export process using a different font than the one specified in the Excel document. For instance, the PDF export might default to using "Arial" font, while the original Excel document uses "Aptos Narrow". +When converting Excel documents in .NET Framework applications to PDF format using [RadSpreadProcessing]({%slug radspreadprocessing-overview%}), the bold text in the Excel file might not appear bold in the exported PDF. The font also may be changed in the exported PDF. This issue often arises due to the PDF export process using a different font than the one specified in the Excel document. For instance, the PDF export might default to using "Arial" font, while the original Excel document uses "Aptos Narrow". This KB article also answers the following questions: - How to ensure text boldness is preserved in PDF exports?