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.

Fri Mar 06, 2020 2:00 am

Hello,

I using Spire.XLS 10.3.0.

When converting .xltx to PDF, I am facing an issue with incorrect scaling.
In the Excel template used, Scale to Fit is Scale = 100%, Width = Automatic, Height = Automatic.
It fits on one page in MS Excel print preview, but when converted to PDF with Spire.XLS, it is split into four pages instead of one.
See the attached file for details.

The following code was used when converting to PDF.
Code: Select all
using (var workbook = new Workbook())
{
    workbook.LoadTemplateFromFile("src.xltx");
    workbook.SaveToFile("out.pdf", FileFormat.PDF);
}


If you lower the value of Scale To Fit, it will fit on one page even if converted to PDF.
However, we need a PDF that fits on one page while maintaining 100% scaling.

Is there a solution for this problem?

Thanks in advance.
Attachments
20200306_00.zip
(40.37 KiB) Downloaded 168 times

nf64
 
Posts: 24
Joined: Fri Aug 17, 2018 1:45 am

Fri Mar 06, 2020 6:22 am

Hello,

Thanks for your inquiry.
I have reproduced your issue and posted it to our Dev team with the ticket SPIREXLS-2168 for further investigation. We will let you know once there is any update. Sorry for the inconvenience caused.
Besides, as a temporary workaround, you could set the property "SheetFitToPage" to true to make the sheet contents appear on only one page. Below is the corresponding code for reference.
Code: Select all
    using (var workbook = new Workbook())
    {
        workbook.LoadTemplateFromFile("src.xltx");
        workbook.ConverterSetting.SheetFitToPage = true;
        workbook.SaveToFile("out.pdf", FileFormat.PDF);
    }


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Mar 17, 2020 6:03 am

Hello,

Hope you are doing well.
Regarding the pagination issue, I learned from our Dev team that it is mainly due to the calculation of the width and height of our products are inconsistent. Since we cannot obtain the same calculation rules of width and height as Microsoft Excel, for your document, there is only one page in Microsoft Excel print preview, but the width and height calculated by our product is slightly larger than the actual width and height in Microsoft Excel, so the output PDF is four pages.
We are sorry that we don't have a good solution to improve this issue at present. In your case, I’m afraid using the temporary workaround I provided previously is the better solution for you. Hope you can understand.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Mar 27, 2020 1:55 am

Hello,
Sorry for the late reply.

I understand that fixing this problem is difficult.
However, in our project, SheetFitToPage cannot be used because we want to enable page breaks specified in Excel.

We will consider other methods.
Thank you.

nf64
 
Posts: 24
Joined: Fri Aug 17, 2018 1:45 am

Fri Mar 27, 2020 2:49 am

Hello,

Thanks for your understanding and apologize for the inconvenience caused.
If there is anything else we can do for you, please feel free to contact us. We are always here to help.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.XLS