|
| 1 | +--- |
| 2 | +title: How to Eliminate Formatting Issues when Exporting XLSX to PDF Format |
| 3 | +description: This article provides a solution to formatting difficulties when exporting an XLSX file to PDF using the RadSpreadProcessing library. |
| 4 | +type: troubleshooting |
| 5 | +page_title: How to Eliminate Formatting Issues when Exporting XLSX to PDF Format |
| 6 | +slug: exporting-xlsx-to-pdf-formatting-issues |
| 7 | +tags: excel, pdf, font, width, column, standard |
| 8 | +res_type: kb |
| 9 | +--- |
| 10 | + |
| 11 | +##Environment |
| 12 | +| Version | Product | Author | |
| 13 | +| --- | --- | ---- | |
| 14 | +| .NET Standard | RadSpreadProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)| |
| 15 | + |
| 16 | +## Description |
| 17 | +This article demonstrates how to deal with formatting difficulties when exporting an XLSX file to PDF using the RadSpreadProcessing library in .NET Standard. |
| 18 | + |
| 19 | +The most common scenario is: |
| 20 | +1. Export an XLSX file to PDF using the RadSpreadProcessing library. |
| 21 | +2. Observe the resulting PDF file with truncated columns or different font. |
| 22 | + |
| 23 | +## Solution |
| 24 | +The limitations of .NET Standard may cause differences in font and text size (text measuring) when converting to PDF format. |
| 25 | + |
| 26 | +1.To address the issue with the size discrepancy, set a `SpreadFixedTextMeasurer` to handle the problem with the size: |
| 27 | +```csharp |
| 28 | +SpreadTextMeasurerBase fixedTextMeasurer = new SpreadFixedTextMeasurer(); |
| 29 | +SpreadExtensibilityManager.TextMeasurer = fixedTextMeasurer; |
| 30 | +``` |
| 31 | + |
| 32 | +2. Implement a `FontsProvider` to handle differences in fonts. This class provides a mechanism to read the fonts used in the document: |
| 33 | +```csharp |
| 34 | +public class FontsProvider : Telerik.Windows.Documents.Extensibility.FontsProviderBase |
| 35 | +{ |
| 36 | + public override byte[] GetFontData(Telerik.Windows.Documents.Core.Fonts.FontProperties fontProperties) |
| 37 | + { |
| 38 | + //...implementation details... |
| 39 | + } |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +3. Update the `FontsProvider` implementation to include the necessary fonts and their corresponding font files. |
| 44 | + |
| 45 | +Please refer to the attached sample project for a complete implementation. Test the solution on your end to verify if it resolves the formatting issue. |
| 46 | + |
| 47 | +## Notes |
| 48 | +It is important to note that the limitations of .NET Standard may still result in slight differences in font and text size when converting to PDF format. |
| 49 | + |
| 50 | +## See Also |
| 51 | +- [RadSpreadProcessing Documentation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) |
| 52 | +- [Troubleshooting Exporting XLSX to PDF in RadSpreadProcessing](https://www.telerik.com/support/kb/document-processing/details/exporting-xlsx-to-pdf-formatting-issues) |
0 commit comments