Fit All Worksheet Columns on Single PDF Page

Fit Worksheet Columns on Single PDF Page

PdfSaveOptions.all_columns_in_one_page_per_sheet ensures that all columns in a worksheet are rendered to a single PDF page, although rows may expand to several pages depending on the data in worksheet.

The sample code below shows how to use PdfSaveOptions.all_columns_in_one_page_per_sheet property to render a large worksheet of 100 columns.

from aspose.cells import PdfSaveOptions, SaveFormat, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create and initialize an instance of Workbook
book = Workbook(dataDir + "TestBook.xlsx")
# Create and initialize an instance of PdfSaveOptions
saveOptions = PdfSaveOptions(SaveFormat.PDF)
# Set AllColumnsInOnePagePerSheet to true
saveOptions.all_columns_in_one_page_per_sheet = True
# Save Workbook to PDF fromart by passing the object of PdfSaveOptions
dataDir = dataDir + "output.out.pdf"
book.save(dataDir, saveOptions)