Crash in Aspose PDF When Saving as an Excel File

Hi,

I just had a user report that a function that has worked for a long time suddenly does not any more. We are taking a pdf and saving as an Excel file. The website crashes with the error message below. It seems to me that the latest version of Aspose.Pdf (24.4.0) is dependent on a library that does not exist in our environment. This is an asp.net website using .NET framework 4.8. Note that when I reverted to Aspose.Pdf version 23.12.0, it worked fine. I will also put the code snippet below.

Please help and thanks.

            // Load PDF document
            Aspose.Pdf.Document doc = new Aspose.Pdf.Document(filePath);
            // Instantiate ExcelSave Option object
            Aspose.Pdf.ExcelSaveOptions excelsave = new Aspose.Pdf.ExcelSaveOptions { MinimizeTheNumberOfWorksheets = true, Format = ExcelFormat.XLSX };

            // Save the output in XLS format (it really saves it as an xml file so we have to convert and can't save as xls format to web from pdf software)
            MemoryStream ms = new MemoryStream();
            doc.Save(ms, excelsave); // crashes on this line

Could not load file or assembly ‘System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Stack Trace:
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=zA$1SELY1glcn9IRd3p1dv9RHoFMJ(Object #=z38U23rA=)
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=zlXzvjMgVTrSVaISXxhkxkfuHvhmmeQ8caNettsc=()
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=z8iFHD$tVBI5gCoC10LTOnts=(Object #=z38U23rA=, UInt32 #=z32uMoNQ=)
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=zKgCNRg1E6udLbXI8XIg3ggs=(Boolean #=z38U23rA=)
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=zKgCNRg1E6udLbXI8XIg3ggs=(Boolean #=z38U23rA=)
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=zHkO2mRoiQZxF5u9guXYKYX6Z01jE()
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=z8RefS8VgsAhmRezNbyVmVrjLsMYP4_73vQ==(Object[] #=z38U23rA=, Type[] #=z32uMoNQ=, Type[] #=zBYVhxdM=, Object[] #=zIIsSC3o=)
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=z7eAff_j8NssANjYnMNQwCCT$Zq2OASbneg==(Stream #=z38U23rA=, String #=z32uMoNQ=, Object[] #=zBYVhxdM=, Type[] #=zIIsSC3o=, Type[] #=zZwx_6Fc=, Object[] #=zY1ol5IE=)
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=z2Qe9NEfxqoP7jgi6ZQ2cYlVviq4BdKgfiPGLLxgGwVld(Stream #=z38U23rA=, String #=z32uMoNQ=, Object[] #=zBYVhxdM=)
at #=qaKThU1Q0skbv8U$NCdBF$7EIgb6HmjSczgl23qG6Hns=.#=zHOSS$sYOPgy5l_pUWCm5GFpQ_EM7(Stream #=z38U23rA=, String #=z32uMoNQ=, Object[] #=zBYVhxdM=)
at #=zFI4PUV8$W0lkU$DVfB1I8X8=.#=zG_XDpZgs_QCy(Document #=zNYxZkw0=, Stream #=zyOBw_rXXcVlY, ExcelSaveOptions #=zNtGg$KCwy$9MvXJkBg==, DocSaveOptions #=zV2XeM2DBqwS4)
at #=zFI4PUV8$W0lkU$DVfB1I8X8=.#=zSR3Leko=(Document #=zNYxZkw0=, Stream #=zN1PTqTTMIQGz, ExcelSaveOptions #=zbfHmrC8=)
at Aspose.Pdf.Document.#=zbl7_Z6XVo6J1(Stream #=zh81E9dN0Tjkq, SaveOptions #=zbfHmrC8=)
at Aspose.Pdf.Document.#=zxUcMrARBMU09(Stream #=zN1PTqTTMIQGz, SaveOptions #=zbfHmrC8=)
at Aspose.Pdf.Document.Save(Stream outputStream, SaveOptions options)
at EDS.Web.Controls.DocumentConvert.ConvertFile(String filePath, Nullable`1 splitColumn) in E:\work\clients\IDS\Projects.GIT\EDS\EDS.Web\EDS.Web\Controls\DocumentConvert.ascx.cs:line 75

@scottbutler

Is it possible that you can please share your sample ASP.NET application with us in .zip format along with the sample document so that we can test the scenario in our environment and address it accordingly.

HI,

I tried to put together a small project but I could not replicate the issue. However, I have now seen this in a second asp.net framework project. When I look at Aspose.Pdf it says there are no dependencies but there definitely is a dependency on System.Text.Encoding.CodePages (v5.0).

I did put in a reference to that assembly using Nuget and that fixed the issue but Nuget says v5 is deprecated.

Please fix this for .Net Framework.

Thanks!

One more piece of information. My project loads System.Text.Encoding.CodePages (v7.0) assembly based on another Nuget package and it looks like if I am not explicitly loading v5, Aspose.Pdf crashes.

@scottbutler

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-57187

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.