PDF Export with option fit page

Hi, we use aspose.cells to generate ondemand document preview. at the moment we generate images with the option “fit sheet to page”. now we need pdf export for an alternative viewer with the same range. is it possible to configure PdfSaveOptions to get the same result for sheets having more than 1000 rows.
kind regards, josef

private void forumexample() throws Exception {
	Workbook book = new Workbook("c:/temp/xls.xlsx");
	
	for (int sheetIndex = 0; sheetIndex < book.getWorksheets().getCount(); sheetIndex++) {
		Worksheet worksheet = (Worksheet) book.getWorksheets().get(sheetIndex);
		if (worksheet.isVisible()) {
			
			ImageOrPrintOptions options = new ImageOrPrintOptions();
			options.setImageFormat(ImageFormat.getJpeg());
			
			PageSetup pageSetup = worksheet.getPageSetup();
			pageSetup.setPaperSize(PaperSizeType.PAPER_A_4);
			
			pageSetup.setPercentScale(false);
			pageSetup.setFitToPagesTall(1);
			pageSetup.setFitToPagesWide(1);
			
			SheetRender sr = new SheetRender(worksheet, options);
			for (int pageIndex = 0; pageIndex < sr.getPageCount(); pageIndex++) {
				sr.toImage(pageIndex, "c:/temp/sheet" + sheetIndex + "_" + pageIndex + ".jpg");
			}
		}
	}
}

@dvtdaten,

Thanks for the sample code with some details.

I am not sure about your issue or requirements. When you save the file to PDF (you may add a line at the bottom using Workbook.Save() method to save to PDF), it will give you same output as per your PageSetup settings or as per your images you generated. Do you find any issue and the output PDF is not the same as per the rendered images? If you need to render simple rendering without using the options like fit to pages tall/wide options, you may just set both fit to pages tall and wide options to empty/null so these options should be taken when rendering to PDF file.

While printing there is are scaling options, one of them is “fitsheetonpage”:

3000_rows_settings.png (62.2 KB)

For generating images, we get exactly the same result as we would use this option in excel.

How do we have to set up PdfSaveOptions to get the same result?

King regards, Josef

sample files: 3000rows3sheets.zip (64.1 KB)

@dvtdaten,

It means your output images (by Aspose.Cells APIs) are fine tuned using your code segment in the first post, is not it?
If I am correct in understanding, you do not need any PdfSaveOptions to be configured, you may simply add a line at the bottom (of your code) using Workbook.Save() method to save to PDF, it should give you same output (it will render different PDF pages accordingly) as per your PageSetup settings or as per your output images you generated. See the sample line of code:
e.g
Sample code:

...........
book.Save("c:/temp/out1.pdf");

Does the above line of code (placed at the bottom) does not give you same output PDF as per your rendered images?

Let us know if you find any issue.