Missing two columns in PDF result file

excel.zip (464.9 KB)
Hi,

I am using Aspose.Cells with Java Version 21.2
I converted one Excel file to PDF. In the result PDF I am missing the last two columns.
Can you please help fixing this issue?

excel.zip file contains source file (.xlsx) and PDF file (result file)

java code:
public static String convertCells2PDF(String sourceFile, String outputFile) {
Workbook workbook;
try {
workbook = new Workbook(sourceFile);

		workbook.calculateFormula();
		PdfSaveOptions opts = new PdfSaveOptions();
		opts.setOnePagePerSheet(false);
		opts.setAllColumnsInOnePagePerSheet(true);
		
		// Save the document in PDF format
		workbook.save(outputFile, opts);
		return outputFile;
		}
	catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}

Regards,WLSR-379_INV_Ironman-2.xlsm.pdf (252.3 KB)

@elie.kach,

We have evaluated your issue and found there is specific printable area (i.e., A1:L150) set for the sheet “Output_PackSlip” (in MS Excel, open Page Setup dialog and check Print area which does not cover all the data range of the sheet). That’s why when you render either by MS Excel or via Aspose.Cells, it just renders specific area only and misses certain columns or data of the sheet (mind you, both Aspose.Cells and MS Excel renders to PDF based on what is shown in the print preview of the sheet). To fix the issue, please either remove the printable area manually (in MS Excel) to re-save the file or set/remove the area to cover the whole range before rendering to PDF. You can do that either by using MS Excel or via Aspose.Cells in code. See the sample lines of code for your reference.
e.g.
Sample code:

    Workbook workbook = new Workbook(sourceFile);
//......
//your code goes here.
//.......
    Worksheet sheet = doc.getWorksheets().get("Output_PackSlip");
    // remove the printable area
    sheet.getPageSetup().setPrintArea("");
    workbook.save("out1.pdf", SaveFormat.PDF);

Let us know if you still find any issue.

Thank you.
We can close this ticket.

@elie.kach,

Good to know that your issue is resolved by the suggested code segment. In the event of further queries or issue, feel free to write us back.