I’m encountering discrepancies in font size and appearance when converting an Excel file to PDF using aspose-cells-25.8.jar, compared to the output generated by Microsoft Print to PDF.
The Excel file uses the fonts MS Pゴシック and Arial.
Font Size Difference
Excel File: Font size is 8.1
Aspose-generated PDF: Font size is 7.97
Microsoft Print to PDF: Font size is 7.57
Font Appearance
Aspose-generated PDF: Font appears darker and bolder
Microsoft Print to PDF: Font appears lighter and softer
Could you please advise how I can achieve consistent font rendering—both in terms of size and appearance—in the PDFs generated by Aspose, matching the output of Microsoft Print to PDF or original excel?
I am referring the code which is used to convert pdf.
Workbook excelWorkbook = new Workbook("sample.xlsx");
String pdfFilePath = "sample_generated_by_aspose.pdf";
PdfSaveOptions saveOptions = new PdfSaveOptions();
workbook.save(pdfFilePath, saveOptions);
I’ve attached a ZIP archive containing the relevant files for your reference. allFiles.zip (1.5 MB)
To achieve consistent font rendering in your PDFs generated by Aspose.Cells, follow these steps:
Cause - Check Font Availability: Ensure that the fonts used in your Excel file (like MS Pゴシック and Arial) are installed on the system where the conversion occurs. Missing fonts can lead to substitutions, causing discrepancies in appearance and size.
Solution - Use PdfSaveOptions: Customize the PdfSaveOptions to control font handling during conversion. Set the WarningCallback to capture font substitution warnings, which will help identify issues.
Here’s a code snippet to implement this:
public class FontSubstitutionWarning implements IWarningCallback {
public void warning(WarningInfo info) {
if (info.getWarningType() == WarningType.FontSubstitution) {
System.out.println("WARNING: " + info.getDescription());
}
}
}
Workbook workbook = new Workbook("sample.xlsx");
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setWarningCallback(new FontSubstitutionWarning());
workbook.save("sample_generated_by_aspose.pdf", saveOptions);
Next Steps - Adjust Font Settings: If discrepancies persist, adjust the font settings in your Excel file or use the PdfASymbolicFontEncodingStrategy to fine-tune font encoding in the PDF.
Next Steps - Test Different Versions: If possible, test with the latest version of Aspose.Cells, as updates may include improvements in font rendering.
By following these steps, you will minimize discrepancies in font size and appearance between the Aspose-generated PDF and the output from Microsoft Print to PDF.
If you have any further questions or need additional assistance, feel free to ask!
@rakib786
By testing with sample code and files on the latest version v25.8, we can reproduce the issue. Font rendering has differences between the generated PDF and the PDF saved in Excel.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSJAVA-46464
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Generating a PDF using Aspose.Cells behaves identically to saving directly to PDF via Excel (File → Save As). In both cases, the result appears darker and bolder. See the attached file.CELLSJAVA-46464.zip (90.0 KB)
We guess you generated the PDF file via “File → Print → Microsoft Print to PDF.” Please note that there are some differences between the printing mechanism and saving directly to PDF, so the results may vary, which is normal.
As mentioned above, this should be compared to a PDF file generated directly from Excel.
Investigation has revealed that font size inconsistencies do exist, but resolving this issue without causing additional issues is difficult. A complete fix may require revising the text rendering logic, which would be time-consuming. We will incorporate this fix into future development plans. Therefore, we cannot provide a solution to this issue in the short term. We apologize for the inconvenience this may cause you. We will notify you as soon as we make progress.
@ duojie.yang
Have any way to keep same font size in generated pdf?
i mean font size in generated pdf should be same as excel.
In cell text, it is rendering correctly.
but it is not working in textbox. text font size is decreased in generated pdf.
@rakib786
As a temporary alternative, you can use images instead of textboxes. Sorry, there is currently no better solution available. At the same time, we cannot solve this problem in the short term. We deeply apologize for any inconvenience caused to you. If there are any updates, we will notify you promptly.
I wanted to kindly follow up regarding the issue we previously discussed. We’re currently blocked from using the library due to this unresolved matter. Would it be possible for you to share any updates or a tentative plan for resolution? Additionally, if you could provide an estimated timeline or likelihood of a fix, it would be greatly appreciated.
@rakib786
Thank you for your feedback. We are still dealing with your issue. This issue is quite complex, involving adjustments to all shapes, especially in terms of text rendering. We expect to fix this issue in the first quarter of 2026. We appreciate your patience in this regard. Sorry for any inconvenience caused to you.