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

Free Support Forum - aspose.com

Excel convert to pdf

Hi Dear,


We are converting to “AD-30005_6.xls” file to pdf we take some error pages.

We wait your solutions.
Thanks.

Hi Ahmet,


Thank you for contacting Aspose support.

Could you please state what kind of problem(s) are you facing while converting the spreadsheet to PDF? I have checked your provided PDF and it does seem to be OK. Please highlight the problematic areas by taking snapshots of such areas for further review.

Hi again,


Please check the attached resultant PDF generated on my side while using the latest version of Aspose.Cells for Java 8.5.1 and following simple statements.

Java
Workbook book = new Workbook(filePath);
book.save(“D:/output.pdf”, SaveFormat.PDF);

Hi,

Sorry for unexplained comment above. One of my friend posted it and i think he did not know anything about situation.

The problem is when i convert an .xls file to .pdf file some gaps occurs in pdf. I realized that if there is any formatted area(you can check formatted area with Ctrl + Shift + End key combination) except print area in excel file, this problem occurs. When converting pdf Aspose considers all formatted area as print area.

For example i attached two file. The first one(doc_v1) has some formatted area outside of print area. If you convert it to pdf via Aspose.Cells for NET you can see gaps in file. The second one(doc_v2) is edited by me and if you try it to convert to pdf you won’t see any gaps in file.

We can fix this problem with editing documents but our customers has thousands of them. And we can not offer them that as a valid solution.

Could you please share me some information for solution this problem?

Regards.

Note: I’m trying this scenario via Aspose.Cells for NET 8.5.2.0

Hi Ahmet,

Thank you for elaborating the issue further.

I have checked both of your samples, and I believe that the said problem occurs because some of the contents on worksheet ek-1 & ek-2 seep out to the next page due to the specified page size, therefore while rending with default settings (SaveFormat.Pdf), the Aspose.Cells APIs generate the PDF with gaps on some of the pages. You may confirm this by converting the problematic sample with Excel application and match its result with Aspose.Cells generated PDF, they will look the same.

You can avoid this situation by setting the PdfSaveOptions.OnePagePerSheet property to true. This solution should be applicable for most of your spreadsheets, and you do not have to manually manipulate the spreadsheet before the rendering process.

C#

var book = new Workbook(“D:/doc_v1.xls”);
book.Save(“D:/OnePagePerSheet.pdf”, new PdfSaveOptions() { OnePagePerSheet = true });

Moreover, if you wish to reset the Print Area, you can do it as follow, however, the result will be same as of default rendering because the contents of aforesaid worksheets do not fit one PDF page.

C#

var book = new var book = new Workbook("D:/doc_v1.xls"); foreach (Worksheet sheet in book.Worksheets) { Console.WriteLine(sheet.PageSetup.PrintArea); sheet.PageSetup.PrintArea = "A1:" + CellsHelper.ColumnIndexToName(sheet.Cells.MaxDataColumn) + sheet.Cells.MaxDataRow; Console.WriteLine(sheet.PageSetup.PrintArea); } book.Save("D:/ResetPrintArea.pdf", new PdfSaveOptions());