We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
If you became a customer of the Syncfusion Reporting Platform or the Report Viewer, Report Designer, or Report Writer components before October 2019 and have questions related to those products, you can request support through our forum system. However, please note that this support system is only for existing customers who are still using the Syncfusion Reporting Platform or its components and not for new customers looking for reporting products from Syncfusion.

For new customers or those with general reporting questions, we recommend contacting our support team at https://support.boldreports.com/, which is a separate brand created by Syncfusion for its reporting solutions. Our team will be happy to assist you with any questions you may have.

Thank you for choosing Syncfusion for your reporting needs.

Add custom font - Problem when exporting to PDF

Hi, I've been using the report tools for .net core and currently I'm trying to add a custom font (Arial) when the user export my reports as PDF. I'm using the following code in the reporting API for accomplishing this:

  1. // Method will be called to initialize the report information to load the report with ReportHelper for processing.
  2. public void OnInitReportOptions(ReportViewerOptions reportOption)
  3. {
  4. string basePath = _hostingEnvironment.WebRootPath;

  5. // Here, we have loaded the sales-order-detail.rdl report from application the folder wwwroot\Resources. sales-order-detail.rdl should be there in wwwroot\Resources application folder.
  6. FileStream reportStream = new FileStream(basePath + @"\reports\"
  7. + reportOption.ReportModel.ReportPath, FileMode.Open, FileAccess.Read);

  8. reportOption.ReportModel.Stream = reportStream;

  9. IList customers = new List() { 
  10. new Customer() { Name = "Name1", Age = 25},
  11. new Customer() { Name = "Name2", Age = 22},
  12. new Customer() { Name = "Name3", Age = 23}, 
  13. new Customer() { Name = "Name4", Age = 26}
  14. };

  15. reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "DSTCustomers", Value = customers });

  16. string resourceName = "ReportTests.Resources.Arial.ttf";

  17. if (reportOption.ReportModel.PDFOptions == null)
  18. {
  19. reportOption.ReportModel.PDFOptions = new Syncfusion.Reporting.Writer.PDFOptions();
  20. }

  21. if (reportOption.ReportModel.PDFOptions.Fonts == null)
  22. {
  23. reportOption.ReportModel.PDFOptions.Fonts =

  24. new Dictionary(StringComparer.OrdinalIgnoreCase);
  25. }

  26. reportOption.ReportModel.PDFOptions.Fonts.Add("Arial",
  27. Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName));
  28. }

This code works but when the user exports the report multiple times this happens eventually:

For tests, I wrapped the resource stream in a class that doesn't close the stream under any situation (something like "NonClosingStreamWrapper"). This way the problem doesn't seem to happen.

How can I fix this?

Regards, Wendell.

5 Replies

VS Vinoth Srinivasan Syncfusion Team August 5, 2019 12:26 PM UTC

Hi Wendell, 
Thanks for your interest in Syncfusion products. 
We have validated the reported problem at our end, but the custom font has been working fine. So, it is possible for you to share your report and font file (ttf file) with us and it will be helpful for us to provide the solution at the earliest. 
Vinoth S. 

WG Wendell Gasparoni August 5, 2019 06:01 PM UTC

Hi, I have attached the project with the report + font.

Regards, Wendell.

Attachment: ReportTests_d91315d.zip

VS Vinoth Srinivasan Syncfusion Team August 6, 2019 12:28 PM UTC

Hi Wendell, 

We were able to reproduce this issue and logged a defect report on this. It will be included in our upcoming releases. You can track this issue from the below feedback portal system. 

Vinoth S. 

WG Wendell Gasparoni August 6, 2019 02:22 PM UTC

Ok, thank you.

Regards, Wendell.

VS Vinoth Srinivasan Syncfusion Team August 6, 2019 02:34 PM UTC

Hi Wendell, 

Thanks for your update. Please let us know if you require further assistance on this. 

Vinoth S. 

Live Chat Icon For mobile
Up arrow icon