Excel to PDF conversion in .NET Standard environment with Aspose.Cells

Hi,

We’ve used Aspose.Cells for many years with the last step in our process to produce a PDF document.

We’re currently using v17.1.0 on the full framework as this is the version that renders shapes correctly. We would dearly like to move to .NET Standard and so it would be great to get this bug resolved.

For example, the Excel Workbook updated and saved via Aspose.Cells looks like the below (this also renders correctly if I use 17.1.0 on the full framework):

ExcelTemplate.png (77.1 KB)

If I try and output the Excel using the latest version (v19+), I get something like (don’t worry about the colours - they get changed programmatically - its the positioning/size of the boxes that don’t match the Excel):
AsposePDF.png (167.0 KB)

Can you please look at this, as it is preventing us from upgrading our infrastructure.

Cheers,
Dave

@darcher,
Please share your sample files and runnable console application with us for our testing. We will reproduce the problem and provide our feedback after analysis.

Hi @ahsaniqbalsidiqui,

Please find the source code example here Sample Code

You can see below the differences in Performance Overview tab and equivalent PDF page:
perfOverviewTab.png (187.9 KB)

and

pdfEquiv.png (107.3 KB)

Cheers,
Dave

@darcher,
Thanks for the feedback. We will share our feedback soon.

@darcher,
I have tried your sample project but could not observe any issue. My environment is Windows 7, Visual Studio 2019, .NET Core 3.0. I tried using the libraries from both NuGet package manager and by manually adding the .NET standard version from the download section. Could you please provide us your environment details for our reference. We will try to reproduce the issue here and provide assistance accordingly.

Hi @ahsaniqbalsidiqui,

I’m using VS 2019 with .Net Core 3.0 on Windows 10. The libraries (Aspose) are from Nuget.

I downloaded the code from the link attached, compiled and ran, and the images are still wonky in the PDF (specifically, I’m looking at p10 titled performance overview). These images are dynamic shapes.

@darcher,
Could you please share output PDF file for our reference.

Hi @ahsaniqbalsidiqui,

Attached is both the Excel and PDF output. Please note the Performance Overview tab and PDF page as a reference to the issue.

Output

Cheers,
Dave

@darcher,
We need to look into it more. We have logged the issue in our database for investigations. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-47049 - Save to PDF issue with shapes on .NET Standard

Thanks @ahsaniqbalsidiqui

That’s much appreciated. We are very keen to progress our application to use the .NET Standard version of Aspose.Cells so we can update our application to use Azure Web Functions.

If you could let me know - even if you have a pre-release version I can test - that would be fantastic.

Cheers, Dave

@darcher,
As we just logged the ticket, so could you spare us a little time (3-5 days or so) for complete evaluation and investigation for your issue. If it is not much complex, you should be receiving the fix before the end of next week or even before it. If the issue is complex, it might take a couple of weeks.

Once we have an update on it, we will let you know here.

Hello @darcher

We tried your test project, but the output PDF seems to be correct, I can not reproduce this issue.
So, would you please help us to confirm two things:

1, The file “AsposePDF.png” you provided, is it created by Aspose Cells .netStandard version or .netframework version?
I mean, is this issue occurs in both .netStandard and .netframework version(Aspose Cells v19+), or just occurs in .netStandard version?

2, Please try:
Workbook book = new Workbook(“Test.XLSM”);
book.Save(“Test.pdf”, Aspose.Cells.SaveFormat.Pdf);
I mean, skip “CalculateFormula” or skip “UpdateSelectedValue” steps, just open it and save it to pdf for test, will this issue occur again?

Thank you!

Hi @wangtao

I’m using the .Net Standard version (I have this deployed to an Azure Web Function running .Net Core 2.1).

I managed to find a work around. If I update my (large) workbook, run a “CalculateFormula” and a few other process, then save this to Azure Blob Storage in the original format (XLSM).

I then open the workbook in a seperate function, and then save as PDF immediately without any calculations or functions. By doing this, I get the correct format.

It’s not ideal, but it works and at this point, that’s what I care about!

Cheers,
Dave

Hello, @darcher
Thank you for your response, do you mean that you have found a solution but it is not very ideal?
But I still hope to reproduce this issue and provide you an ideal one.
We have publish Aspose.Cells 19.12 on nuget, which relies on System.Drawing.Common 4.6.0,
it will support .netcore 3.0 (19.11 or earlier only support .netcore 2.1).
Please try 19.12 and give me a response, thank you!

By the way, I think this issue occurs after you call funtion “wsShape.Shapes.UpdateSelectedValue();”
It is a conjecture, even it can not reproduce in my environment.
Maybe some difference between you and my environment cause this problem, I hope I can find it out.

Hello @darcher
We have reproduced this issue, can you try to set your winodws DPI to 100% to see if this issue can be fixed?
Here we find out if we set DPI to 150% in windows control panel, this issue will reproduce.

Hi @leoluo,

While I could do this for my test version, I’m deploying this code to an Azure Web Function that runs independent of the DPI setting.

@darcher,
We are discussing your feedback and will share our thoughts soon.

Hi,
I was wondering how you are going with this issue? We would really like to migrate our process to use a web function (using .Net Core) and still have this issue.

I have attached the most recent example (XLSM and resulting PDF output). The sheet that shows the issue is the ‘Performance Overview’ sheet (page 8 in the PDF). As you can see, the green boxes (linked images) are a different size to the XLSM workbook sheet.

Prior to saving the PDF from the Excel Workbook:

  • book.CalculateFormula(true);
  • Loop through all worksheets and call sheet.Shapes.UpdateSelectedValue();

To save the PDF, I use:
MemoryStream ms = new MemoryStream();
PdfSaveOptions pdfSave = new PdfSaveOptions()
{
CalculateFormula = false,
RefreshChartCache = false,
UpdateSmartArt = false
};

book.Save(ms, pdfSave);

Please let me know if you need any more information.

Updated Excel and PDF:
Zip File

@darcher,
We were able to observe the issue with Page 8 of the Pdf file. We have logged the information and files in our database for further investigations. Once we will have some news for you, we will update you in this topic.

1 Like