Problem with PDF export

Hi,

I’m exporting to PDF/EXCEL data stored in datatable.
In case of Excel report is generated without any problems, but in case of PDF output file has too width columns (look attachments).
Below is source code what I’m using to save both files (excel and PDF)

Dim sStram As System.IO.MemoryStream = New System.IO.MemoryStream()
If pFormat = SaveFormat.Pdf Then
Dim pdfSaveOptions As New PdfSaveOptions(SaveFormat.Pdf)
pdfSaveOptions.AllColumnsInOnePagePerSheet = True
report.Save(sStram, pdfSaveOptions)
Else
report.Save(sStram, pFormat)
End If

Please anybody can help me to make PDF file with correct column width?

Hi Grzegorz,


Thank you for contacting Aspose support.

By looking at your provided PDF file, it seems that the API is rendering empty columns from the spreadsheet. Please try again by deleting the empty columns as elaborated below.

Visual Basic

Dim workbook As New Workbook(“D:/temp/XLS_Report.xls”)
workbook.Worksheets(0).Cells.DeleteBlankColumns()
Dim options As New PdfSaveOptions()
options.AllColumnsInOnePagePerSheet = True
workbook.Save(“D:\temp\output.pdf”, options)


In case the problem persists, please give a try to the latest version of Aspose.Cells for .NET 8.2.0.3. We have tested the scenario on our end, and the resultant PDF file is attached for your reference.

Thanks a lot for your help.

Additionally I had to trim all spaces from each item in datatable.

Hi Grzegorz,


It’s good to know that the provided solution helped in your scenario. Please feel free to write back in case you need our further assistance with Aspose APIs.