We have two Excel test files exceltestfiles.7z (477,1 KB)
(forum doesn’t support XLSX upload, so I zip them into 7z) , and we are testing excel2pdf function. Here is our code
Workbook workbook = new Workbook(“guntherexcel.xlsx”);
workbook.save(“gunther-excel-Output.pdf”);
Workbook workbook2 = new Workbook(“guntherexcel2.xlsx”);
workbook2.save(“gunther-excel-Output2.pdf”);
However the visual effect of PDF is not good. gunther-excel-Output.pdf (240,7 KB) I can only upload one PDF result, and the other one PDF result has 17MB size so I can not upload it due to forum limitation. In this 17MB PDF result, there are more than 7,100 empty pages! Yes, the 17MB PDF result contains totally 7,122 pages!
So I can only upload a screenshot of this 7,122 pages PDF result. image.png (79,6 KB)
I have tried following SaveOption and apply it to both test files
final com.aspose.cells.PdfSaveOptions options = new PdfSaveOptions();
options.setOnePagePerSheet(true);
options.setCompliance(PdfCompliance.PDF_A_1_A);
Two PDF result files get a little bit better, however still not really good, lots of empty pages…
@zwei
By using sample files for testing, we can reproduce the issue. Found bad visual effect and many blank pages in the result file when saving the file to PDF.
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-45642: The result file has many blank pages when saving the file to PDF
CELLSJAVA-45643: Bad visual effect of PDF result when saving file to pdf
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.
If you printview your source files in Excel, you will also find that there are lots of empty pages. This is because of lots of blank cells which only have borders or white background color.
You can set a proper printarea to exclude some blank cells, take worksheet “fp-Connector - Pers.Daten” in source file “01_Fachkonzept_forpeople_KUNDEN_ANPASSEN.xlsx” for example:
Workbook wb = new Workbook("01_Fachkonzept_forpeople_KUNDEN_ANPASSEN.xlsx");
//set a proper printarea
wb.getWorksheets().get("fp-Connector - Pers.Daten").getPageSetup().setPrintArea("A1:AW72");
wb.save("output.pdf");
You can also set proper printarea for other worksheets to exclude more empty pages.