I am trying to convert Excel to PDF but my output PDF has rows that overlap with each other. Sheet name is also printed on top of every page which i don’t want to.
Here is the code used to perform conversion:
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setAllColumnsInOnePagePerSheet(true);
saveOptions.setOptimizationType(PdfOptimizationType.STANDARD);
saveOptions.setTextCrossType(TextCrossType.DEFAULT);
saveOptions.setCalculateFormula(true);
saveOptions.setCheckWorkbookDefaultFont(true);
saveOptions.setIgnoreError(true);
excelFile.save(output, saveOptions);
Input excel and output PDF files are also attachedexcelToPdf.zip (229.8 KB)
@ahmedtariq,
I did test your scenario/case with your file using our latest version/fix: Aspose.Cells for Java v22.5. It works fine with it using your sample. Please find attached the output PDF file generated on my end, it is fine tuned.
out1.pdf (126.8 KB)
Your issue might be related to missing font on your end. I checked different fonts are used in your output PDF file which caused your mentioned issue. Please make sure that the underlying fonts (.ttf files) files (used in the workbook) are installed. In your case, “Arial” and “TimesNewRoman” should be installed on your machine (where you are processing the code). So, you may give it a try again after installing the required fonts. Moreover, please check the document on how to configure fonts for rendering spreadsheets.
@ahmedtariq
This is because you set it in Header in the source file. If you don’t want it, you can clear it with the following code:
Workbook excelFile = new Workbook("excel1.xls");
//Page setup of first sheet
PageSetup pageSetup = excelFile.getWorksheets().get(0).getPageSetup();
//clear center header
pageSetup.setHeader(1, null);
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setAllColumnsInOnePagePerSheet(true);
saveOptions.setOptimizationType(PdfOptimizationType.STANDARD);
saveOptions.setTextCrossType(TextCrossType.DEFAULT);
saveOptions.setCalculateFormula(true);
saveOptions.setCheckWorkbookDefaultFont(true);
saveOptions.setIgnoreError(true);
excelFile.save("output.pdf", saveOptions);
I have the fonts installed on my machine (Arial.ttf and TimesNewRoman.ttf) and i am also using the latest aspose-cell v22.5. However, i still get the same output PDF file with text overlapped. I am using Ubuntu 20.04 LTS. When i export the excel file to PDF i get the correct output but not with my Aspose function.
Also, is there a way i can keep font .ttf file in my project and use those files for conversion?
Thank you for your response. That worked for me
@ahmedtariq,
It looks like your issue is sorted out now. Feel free to write us back if you still have any issue or queries, we will be happy to assist you soon.
Thank you for response. It’s working