Implement Custom Paper Size of Worksheet for Rendering with Node.js via C++

Possible Usage Scenarios

There is no direct option available to create custom paper sizes in Microsoft Excel; however, you can set a custom paper size for your desired worksheets when rendering an Excel file to PDF format. This document explains how to set a custom paper size for a worksheet using Aspose.Cells APIs.

Implement Custom Paper Size of Worksheet for Rendering

Aspose.Cells allows you to implement your desired paper size for the worksheet. You may use the PageSetup.customPaperSize(number, number) method of the PageSetup class to specify a custom page size. The following sample code illustrates how to specify a custom paper size for the first worksheet in the workbook. Please also see the output PDF generated with the following code for reference.

Screenshot

todo:image_alt_text

Sample Code

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");

// Create workbook object
const wb = new AsposeCells.Workbook();

// Access first worksheet
const ws = wb.getWorksheets().get(0);

// Set custom paper size in units of inches
ws.getPageSetup().customPaperSize(6, 4);

// Access cell B4
const b4 = ws.getCells().get("B4");

// Add the message in cell B4
b4.putValue("Pdf Page Dimensions: 6.00 x 4.00 in");

// Save the workbook in pdf format
wb.save(path.join(dataDir, "outputCustomPaperSize.pdf"));