Search code examples
excelpdffontssyncfusion

Wrong fonts and wrong autofit when using Syncfusion's ExcelToPdfConverter


I am currently using Syncfusion's ExcelToPdfConverter to convert an XLSX document to a PDF.

I first create the XLSX document and then convert it to PDF with the following code:

var converter = new ExcelToPdfConverter(workbook);
//Intialize the PDFDocument
var pdfDoc = new PdfDocument();
//Intialize the ExcelToPdfconverterSettings
var settings = new ExcelToPdfConverterSettings();
//Assign the PDFDocument to the TemplateDocument property of ExcelToPdfConverterSettings
settings.TemplateDocument = pdfDoc;
settings.EmbedFonts = true;
//Convert Excel Document into PDF document
pdfDoc = converter.Convert(settings);
//Save the pdf file
pdfDoc.Save(PDFFullPath);

The resulting XLSX is correct and it looks like it should. The converted PDF isn't correct though. It's just like it's using wrong fonts and, as a consequence, those rows that have been autofitted with AutofitRow get truncated.

Has anyone else had this issue before? Is there any way to tell the PDFConverter to use the correct fonts? (Please note that I'm using Arial and Calibri and they're both installed in the system's fonts)

Regards.


Solution

  • This was actually a bug in Syncfusion XlsIO that has been fixed in a patch due out in February 2017. The above code is correct.