Fit All Worksheet Columns on Single PDF Page

Fit Worksheet Columns on Single PDF Page

PdfSaveOptions.AllColumnsInOnePagePerSheet 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.AllColumnsInOnePagePerSheet property to render a large worksheet of 100 columns.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create and initialize an instance of Workbook
Workbook book = new Workbook(dataDir + "TestBook.xlsx");
// Create and initialize an instance of PdfSaveOptions
PdfSaveOptions saveOptions = new PdfSaveOptions();
// Set AllColumnsInOnePagePerSheet to true
saveOptions.AllColumnsInOnePagePerSheet = true;
// Save Workbook to PDF fromart by passing the object of PdfSaveOptions
dataDir = dataDir+ "output.out.pdf";
book.Save(dataDir, saveOptions);