New in 2022. When converting Excel worksheet to PDF or to images (Tiff, jpg, etc), jOfficeConvert will use by default the paper size and orientation defined in Excel spreadsheet for the output PDF page size and orientation.

It is possible to overwrite the 2 page properties using the ExcelConvertOptions, here is some sample Java code on how to do so below

// create new ExcelConvertOptions object
ExcelConvertOptions options = new ExcelConvertOptions();
 
//The page size override Dimension's parameters must be specified in 1/72 inch sized points.
final int PPI = 72;
// Legal is 8.5" wide by 14" height. To convert to points multiple inches by PPI (72).
options.setPageSizeOverride(new Dimension((int) (8.5 * PPI), 14 * PPI));
 
// print in landscape. i.e. the output pages will actually be 14 inches wide and 8.5 inches height.
options.setPageOrientationOverride(PageOrientation.Landscape);
 
// Load the document
ExcelDocument ed = new ExcelDocument(in, options);
 
// Save the document as a PDF file
ed.saveAsPDF("legalLandscape.pdf");
 
//Many standard pages size dimensions are specified in milimeters rather than inches
//For example A4 is defined as 210 mm wide by 297 mm high.
// we can define a conversion factor from Points Per Inch to Points Per Milimeter as:
final float PPMM = 72 / 25.4f;
// then set the A4 dimension like so (might be a good idea to round rather than simply truncate to an int):
options.setPageSizeOverride(new Dimension(Math.round(210 * PPMM), Math.round(297 * PPMM)));
 
// open the Excel document with options	
ed = new ExcelDocument(in, options);
 
// Convert and save it as PDF
ed.saveAsPDF("A4Landscape.pdf");
 
//Also there is an enum type in ExcelConvertOptions that defines some standard paper sizes.
// These enum values can be used for convenience to obtain the corresponding Dimension instance,
// rather than having to enter the width and height explicitly.
//For example, to specify an page size override of Letter:
options.setPageSizeOverride(PageSize.Letter.toDimension());
 
// open the Excel document with new options
ed = new ExcelDocument(in, options);
 
// Convert and save it as PDF
ed.saveAsPDF("letterLandscape.pdf");

Note that by default the override page size and override page orientation values are set to null.

To get the page dimension for standard page formats, use the “toDimension” method of the PageSize enumeration:

Dimension pageLetterDim = PageSize.Letter.toDimension();
Dimension pageLetterSmallDim = PageSize.LetterSmall.toDimension();
Dimension pageTabloidDim = PageSize.Tabloid.toDimension();
Dimension pageLedgerDim = PageSize.Ledger.toDimension();
Dimension pageLegalDim = PageSize.Legal.toDimension();
Dimension pageStatementDim = PageSize.Statement.toDimension();
Dimension pageExecutiveDim = PageSize.Executive.toDimension();
Dimension pageA3Dim = PageSize.A3.toDimension();
Dimension pageA4Dim = PageSize.A4.toDimension();
Dimension pageA4SmallDim = PageSize.A4Small.toDimension();
Dimension pageA5Dim = PageSize.A5.toDimension();
Dimension pageB4Dim = PageSize.B4.toDimension();
Dimension pageB5Dim = PageSize.B5.toDimension();