We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF layout differs from Excel

Dear Aspose Team,

we found a problem with the layout of our generated pdf files.
Aspose.Cells is used in our webapplication to save an Excel
Workbook to pdf.
In the evaluation phase we compared pdf files generated by Excel
with those generated by Aspose.Cells and they were nearly identical.
Now we found on a certain laptop (Windows 7 64 bit)
that the column widths in the Aspose generated pdf are remarkably
bigger than in Excel.
What can be the reason for that?

I added the generated pdfs as attachments.

Thank you very much in Advance,
Stefan Sixt.

Hi Stefan,

Thank you for contacting Aspose support.

I have checked your provided PDF files and I have noticed the following 2 points.

  1. You are using Aspose.Cells for .NET, that is quite old revision because latest version at this moment is Aspose.Cells for .NET 8.7.0.
  2. Number of pages are different in the 2 PDF files, where your current version of the API is generating one extra page.

I have also checked fonts used in both PDF files that are from Arial font family, therefore the problem does not seem to be related to the availability of the required fonts however, behaviour could be due to some problem in your current version of the API, that you can rule out by upgrading to latest version.

That said, if the problem persists even after upgrading to 8.7.0 then we need your sample spreadsheet (from which you have generated the PDF file) along with your executable code (used for the conversion) to properly investigate the matter on our side.

Hi Babar,

I am sorry to tell you that the new version has the same problem.
Please find in the attachments a generated pdf and the Excel file from which the pdf
was generated.
The code that generates the pdf is:

PdfSaveOptions opt = new PdfSaveOptions();
opt.PrintingPageType = PrintingPageType.IgnoreBlank;
opt.CalculateFormula = true;
xlsWorkbook.Save(pdfFile, opt);

xlsWorkbook is of type Workbook.

Thank you very much,

Hi Stefan,

Thank you for sharing the sample spreadsheet.

I have reevaluated the scenario while using Aspose.Cells for .NET (latest at the moment and attached to this post) and I am not able to observe the problem as shown in the PDF shared by you. Please note, in your provided PDF the contents on the pages 5, 8 & 11 are getting spanned over to the next pages. As a result you are getting 13 PDF pages as compared to 11 pages generated by Excel application. This problem isn’t reproducible with Aspose.Cells for .NET as I am getting 10 PDF pages (resultant file attached). Please give the latest revision a try on your end as well to feed us back.

Hi Babar,

I am sorry, but also the latest version has this issue.

Thank you very much,

Hi Stefan,

We are sorry you know that you are still facing the issue. In order to further investigate the matter, could you please provide us the PDF generated against the latest revision of the Aspose.Cells for .NET Could you please also check the resultant PDF attached to my previous response and comment if it is OK or you can see some problem in it?

Thank you for your cooperation.

Hi Babar,

the output.pdf of you was ok.
Please find the requested files in the attachment.

Thank you,

Hi Stefan,

Thank you for the samples. I have retested the scenario and I am still getting the correct results (attached). Could you please provide more information as follow?

  • Operating system version & architecture
  • Target .NET Framework version
  • Locale of your machine
  • Display size (please check attached snapshot for reference)

Hi Babar,

here the answers to your questions:
Windows 7 Professional SP1 64bit
.NET 4.0
en-us for Format, else german

I noted that the text size on this PC is set to medium (125%).
Maybe this makes a difference.

Best regards,

Hi Stefan,


I noted that the text size on this PC is set to medium (125%).
Maybe this makes a difference.

I believe yes, the display size is causing the said issue. Could you please retest the scneario by setting the CellsHelper.DPI to 96 at the start of your test application? It should fix the problem.

Hi Babar,

How do I get access to the class instance of CellsHelper to set the property?
Maybe you could provide me a piece of code for that?

Thank you, Stefan.


Thanks for your posting and using Aspose.Cells.

CellsHelper class is a static class and a utility class. You do not need to create its instance just use its static methods.


CellsHelper.FontDir = “C:\tempFonts”;
CellsHelper.DPI = 96;

Please see this section to check how to work with CellsHelper class.

( http://www.aspose.com/docs/display/cellsnet/Working+with+CellsHelper+Methods )

Hi Babar,

I am sorry to tell you that, the code change did not solve the problem.
Also switching the PC to 100% textsize had no effect.

Best regards, Stefan.

Hi Stefan,

This is to update you that I am finally able to replicate the said problem while using the latest version of Aspose.Cells for .NET 8.7.2 on Windows 7 Home Premium x64 by setting the Display size to 125%. Moreover, I have noticed that the issue does not occur when Display size is set to 100%. I have logged an investigative ticket with Id CELLSNET-44327 to look further into this matter.

Attached to this post is a sample application that allowed me to observe the said problem. The archive also contains the resultant PDF files generated by setting the Display size to 100% & 125%.

Hi Babar,

are there new findings on this issue?
We have some customers complaining about this problem.

Thank you, Stefan.

Hi Stefan,

I have requested the concerned member of the product team to share the latest updates regarding the ticket CELLSNET-44327. We will shortly get back with some news in this regard.

Hi again,

Please try the following piece of code against the latest version of Aspose.Cells for .NET Please note, the problem is caused due to the 125% display size set on your machine. In such cases, the Aspose.Cells APIs calculate the column widths different than Excel application and consequently the number of rendered PDF pages and their layout may differ. In order to tackle this situation, CellsHelper class offers the DPI property which has to be set immediately after the license setting statements and before creating an instance of Workbook class.

Moreover, if you change the text size of your machine, it is best that you should restart it so that new settings are applicable for all processes/applications.


var file = “AcceptanceReport.xlsm”;
Aspose.Cells.CellsHelper.DPI = 96;
new Aspose.Cells.Workbook(file).Save(file + “_DPI.pdf”, new Aspose.Cells.PdfSaveOptions()
CalculateFormula = true,
PrintingPageType = Aspose.Cells.PrintingPageType.IgnoreBlank