Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Jan 24, 2024 6:09 am

Hi. I convert a pdf file using spire and the result is one page, if saved via excel, then the correct three pages are obtained. Attached an archive with files.
Attachments
excel_scrin.PNG
excel_scrin.PNG (67.67 KiB) Viewed 3715 times
spire_scrin.PNG
spire_scrin.PNG (78.99 KiB) Viewed 3715 times
question.rar
(278.65 KiB) Downloaded 519 times

Kostegan
 
Posts: 6
Joined: Wed Sep 01, 2021 8:09 am

Wed Jan 24, 2024 6:59 am

Hello,

Thank you for your inquiry.
Regarding your question about achieving consistent results between PDFs generated by Spire.Xls and Microsoft Excel, if you want the output PDFs to have the same effect, please remove the line of code "workbook.getConverterSetting().setSheetFitToPage(true);" from your code. This line of code is responsible for fitting a sheet into one page when converting it to PDF.
Code: Select all
Workbook workbook = new Workbook();
workbook.loadFromFile("input/PR_ex3.xlsx");
workbook.saveToFile("output/ExcelToPdf4.pdf", FileFormat.PDF);

By removing this line, the conversion process will retain the original layout of the sheet, which may result in multiple pages in the PDF if the content exceeds one page.
If you have any further questions or need assistance with anything else, please feel free to ask.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS