Free Support Forum - aspose.com

Page Setup Zoom Factor Creates Incorrect Number of Pages in PDF

Hello,

I am testing the PageSetup.Zoom property and I have noticed a difference in the number of pages generated between the output created by Excel (printing or Export to PDF) and that by Aspose.

Page counts for zoom levels below 200 seem OK, but zoom level 200, 300 and 400 create less pages than they should.

Zoom 200% - creates 25 pages, print preview and export PDF create 30.
Zoom 300% - creates 56 pages, print preview and export PDF create 105.
Zoom 400% - creates 144 pages, print preview and export PDF create 160.

Looking at the pages, there is an extra row in the PDF created by Aspose that is not on the exported PDF or the print preview of the worksheet, and it overwrites the bottom margin - see attached image: ZoomFactorPageMismatch.png (44.4 KB)

This is my Excel sample file: PageSetup-CommentsErrorsHeadingsNotesTitles.zip (10.0 KB)

I also noticed that the the row/column headers in the resulting PDF are not drawn properly at lower zoom 10, 50, and the higher zoom levels of 200, 300 and 400.

Thanks,

Sheri

@sheri_steeves

Thanks for using Aspose APIs.

This issue occurs because Microsoft Excel changes the Pdf page size while Aspose.Cells do not change it. Please see this screenshot for a reference.

We have logged this issue in our database for investigation and for a fix if possible. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

  • CELLSNET-46088 - Page Setup Zoom Factor creates incorrect number of pages in PDF

@shakeel.faiz

Thanks for looking into this. I’m confused as to why/how you are getting different page sizes.

In Excel, when I set the Page Setup Zoom (Scaling) to different levels, then do a print preview or Export to PDF, I still get an 8.5x11 page, both in the preview and in my resulting PDF.

ZoomFactorPageSetup.png (6.6 KB)

In my tests here, exporting to PDF from Excel using my sample file gives the results below:

  • Scale 10% - 1 page, 8.5x11
  • Scale 50% - 1 page, 8.5x11
  • Scale 100% - 4 pages, 8.5x11
  • Scale 200% - 30 pages, 8.5x11
  • Scale 300% - 105 pages, 8.5x11
  • Scale 400% - 160 pages, 8.5x11

Saving the same Excel file via Aspose and the Workbook.Save(PDF) also gives me 8.5x11 Letter sized pages.

This is the code I am using:

Aspose.Cells.PdfSaveOptions pdfSaveOptions = null;
pdfSaveOptions = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf)
{
    // set warning callback
    WarningCallback = wbWarningCallback,
    Compliance = Aspose.Cells.Rendering.PdfCompliance.None, // creates 1.4 PDF
    OptimizationType = Aspose.Cells.Rendering.PdfOptimizationType.MinimumSize,
};

foreach (Aspose.Cells.Worksheet wSheet in wBook.Worksheets)
{
    if (!wSheet.IsVisible) continue;
    wSheet.PageSetup.Zoom = 200;
}

wBook.Save(OUTPUT_DIR + OUTPUT_NAME, pdfSaveOptions);

Thanks,

Sheri

@sheri_steeves

Thanks for your further information. It will be helpful for looking into this issue and fixing it. Please spare us a week or two, hopefully, we will be able to fix this issue. Once, we will have some news for you, we will share it with you asap.

@sheri_steeves

This is to inform you that we have fixed your issue CELLSNET-46088 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

@sheri_steeves,

Could you try our latest version/fix: Aspose.Cells for .NET v18.4.6

Your issue should be fixed in it.

Let us know your feedback.

@shakeel.faiz and @Amjad_Sahi

Fix works, I’m getting the proper number of pages now.

@sheri_steeves,

Good to know that your issue is sorted out by the new fix/version. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSNET-46088) have been fixed in this update. Please also check the document/article for your reference: https://docs.aspose.com/display/cellsnet/Installation

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan