Hi Aspose Team,
We have another problem with a “complex” Excel spreadsheet. When using Aspose.Cells it results in a corrupt PDF output. Adobe Reader complains about the content on some of the pages and there are also big visual flaws there.
Sample file:
546358_1_0 (2).zip (320.6 KB)
Using this code:
Aspose.Cells.Workbook excelDoc = new Aspose.Cells.Workbook(filename);
excelDoc.Save(dstFilename, new Aspose.Cells.PdfSaveOptions()
{
OnePagePerSheet = onePagePerSheet,
AllColumnsInOnePagePerSheet = true,
ExportDocumentStructure = true
});
If you inspect the PDF by scrolling down through the pages you will see the problem there.
Thanks for investigate this problem !
Kind Regards,
Anders
@andersalvsaker
It appears you are encountering issues with generating a PDF from a complex Excel spreadsheet using Aspose.Cells, resulting in a corrupt PDF file. Here are several suggestions to troubleshoot and potentially resolve the issue:
-
Check for Complex Features: Complex Excel features such as advanced charts, embedded objects, or extensive formatting can sometimes lead to issues during PDF conversion. Try simplifying the spreadsheet by removing or flattening these elements.
-
Adjust PDF Save Options: Experiment with different PdfSaveOptions
. For instance, you can set OnePagePerSheet
to false
or AllColumnsInOnePagePerSheet
to false
to see if it improves the output.
Aspose.Cells.PdfSaveOptions pdfOptions = new Aspose.Cells.PdfSaveOptions
{
OnePagePerSheet = false,
AllColumnsInOnePagePerSheet = false,
ExportDocumentStructure = true
};
excelDoc.Save(dstFilename, pdfOptions);
-
Update Aspose.Cells: Ensure you are using the latest version of Aspose.Cells, as updates often include bug fixes and improvements that could resolve your issue.
-
Test with a Simplified File: Create a simplified version of your Excel file with only the essential data and formatting. If this converts successfully, it may help identify which specific elements in the original file are causing the corruption.
-
Contact Support: If the problem persists, consider reaching out to Aspose support with your specific file and code snippet for more tailored assistance.
These steps should assist you in troubleshooting the issue with the PDF output. If you require further assistance, please feel free to ask!
@andersalvsaker,
Thanks for the template Excel file.
I tested your scenario/case using your template Excel file and following sample code with Aspose.Cells for .NET v25.10 (please try it if you are not already using it). It works fine and the output PDF is OK.
e.g.,
Sample code:
Aspose.Cells.Workbook excelDoc = new Aspose.Cells.Workbook("e:\\test2\\546358_1_0 (2).xlsx");
excelDoc.Save("e:\\test2\\outasdfasdfasdf.pdf", new Aspose.Cells.PdfSaveOptions()
{
OnePagePerSheet = true,
AllColumnsInOnePagePerSheet = true,
ExportDocumentStructure = true
});
out1.pdf (1.0 MB)
Kindly find the attached output PDF file. I have reviewed it in Adobe Reader, scrolling through the pages one by one. Adobe Reader does not display any errors or issue any warnings regarding the content. If your concern relates to the visual appearance, including the height and width variations of different pages, it may be due to the attributes configured for PdfSaveOptions in the provided code segment:
OnePagePerSheet = true,
AllColumnsInOnePagePerSheet = true,
These Boolean properties are designed to render a single page for the entire worksheet’s contents. If your worksheets contain extensive data, content, or other objects, Aspose.Cells will attempt to create one large PDF page for the dataset, which may result in compressed content. This behavior is similar to manually setting comparable options in MS Excel and is considered expected. If you are concerned about the visual appearance, such as larger or smaller PDF pages with compressed content, it is recommended not to enable these attributes in your code.
Hi Amjad,
Yes i confirm your result PDF is okay
I have rested in my environment using latest Aspose.Cells, but still I get a corrupt output PDF file.
Please check this file.
546358_1_0 (2)_1_2_3.pdf (1.0 MB)
Error message from Adobe Reader , unfortunately in Norwegian:
image.png (104.0 KB)
@andersalvsaker
By testing with sample files and code on the latest version v25.10, we can reproduce the issue. When saving a file to PDF and viewing it on Adobe software, a crash message pop-up appears when scrolling through the PDF file multiple times.
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): CELLSNET-59194
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.
1 Like