Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to customize the paper size when converting Excel to PDF #62

Open
aiden-less opened this issue Jun 14, 2022 · 1 comment
Open

How to customize the paper size when converting Excel to PDF #62

aiden-less opened this issue Jun 14, 2022 · 1 comment

Comments

@aiden-less
Copy link

When excel is converted to PDF, the default paper size is A4. How can I realize the custom size (such as 15cm*5cm)?

@amjad-sahi
Copy link
Collaborator

Please use the PageSetup.customPaperSize() method with the most recent version/fix: Aspose.Cells for Java v22.6 for your needs. Please see the following code for your reference.
e.g.
Sample code:

//Create workbook
Workbook workbook = new Workbook("f:\\files\\Book1.xlsx");

//Access first worksheet
Worksheet ws = workbook.getWorksheets().get(0);


//Set custom paper size, you need to convert cm to inches
ws.getPageSetup().customPaperSize(1.97,5.9);

//Save it as pdf
workbook.save("out1.pdf");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants