XLSX to PDF: Wrong text format and font

I have some problem when print a excel file to pdf using aspose.cell :

  1. Text style in a cell is wrong alignment, spacing between words, line spacing.
  2. Font problem: font is too strong than source in MS-excel, can’t print multi font.
    i use font “Times New Roman” for nomal text, “Wingdings” for checkbox

p/s: sorry about my english skill, hope you understand and help me. Thank all !!!
aspose cell version 21.5: Aspose Repository Browser /java/repo/com/aspose/aspose-cells/

excel.png (5.1 KB)
pdf.png (10.5 KB)

@thaolt1,
Please share your sample file and code snippet with us for our testing. We will reproduce the problem and provide our feedback after analysis.

@ahsaniqbalsidiqui
This is my code:

Workbook workbook = new Workbook("src/main/resources/templates/excel.xlsx");
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
workbook.save(outputStream, pdfSaveOptions);
writeBinaryFile("src/main/resources/templates/pdf.pdf", outputStream.toByteArray());

public static void writeBinaryFile(String filepath, byte[] data) {
    try (FileOutputStream fos = new FileOutputStream(filepath)) {
        fos.write(data);
    } catch (Exception e) {
        log.error("", e);
    }
}

and sample file, hope receive your support soon !
sample-file.zip (29.4 KB)

@thaolt1,

It seems your issue is due to missing fonts on your end. Please make sure that TimesNewRoman, Arial and Wingdings fonts (.ttf or .ttc) are installed on your system and fonts folder is accessible seamlessly, so Aspose.Cells for Java could use it for rendering to PDF feature. See the attached output PDF that is generated on my pc.
out1.pdf (62.8 KB)

PS. I am using latest fix, so please try it:
aspose-cells-21.5.6-java.zip (7.3 MB)

1 Like

@Amjad_Sahi
Thank you so much, it works !!!

@thaolt1,

Good to know that your issue is resolved now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.