Free Support Forum - aspose.com

Pdf not readable after converting from a large XLS

Hi,
I am trying to use the Aspose.Cells component to convert a XLS to a PDF. The dataset contains 350 records. After converting to PDF, the 350 rows of data got
condensed into two pages in the PDF which is not readable unless zooming it to 800% in the PDF viewer.
I'm using Aspose.Cells v4.5.0.17 and PDF version 3.7.0.0

Below is the code for coverting to PDF:

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.Name = "expenses";

Aspose.Cells.Cells cells = workbook.Worksheets[0].Cells;

sheet.Cells.ImportDataTable(dtData, false, "A8");
sheet.AutoFitColumns();

string _SaveAsFileName = "expenses.pdf";
string fileXML = "~/tempdata/xls2PDF.xml";

// Saving an XLS file in Aspose.Pdf xml format
workbook.Worksheets[0].PageSetup.FitToPagesWide = 1; //keeps all columns on same page
workbook.Save(Server.MapPath(fileXML), FileFormatType.AsposePdf);

// Converting XLS file to PDF through Aspose.Pdf using Aspose.Pdf xml file as a medium
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(Server.MapPath(fileXML), null);
pdf.IsLandscape = true;
pdf.IsTruetypeFontMapCached = true;
pdf.TruetypeFontMapPath = Path.GetTempPath();

pdf.Save(memStream);

Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Charset = "UTF-8";
Response.AddHeader("Content-Length", memStream.Length.ToString());
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", saveAsFileName));
Response.ContentType = "Application/pdf";
Response.BinaryWrite(memStream.ToArray());
Response.Flush();
Response.End();

Hi,

Could you try the following part of your code and post your created .xls file here, we will check it soon.

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.Name = "expenses";

Aspose.Cells.Cells cells = workbook.Worksheets[0].Cells;

sheet.Cells.ImportDataTable(dtData, false, "A8");
sheet.AutoFitColumns();

string _SaveAsFileName = "expenses.pdf";
string fileXML = "~/tempdata/xls2PDF.xml";

string fileXLS = "~/tempdata/xls2PDF.xls";

// Saving an XLS file in Aspose.Pdf xml format
workbook.Worksheets[0].PageSetup.FitToPagesWide = 1; //keeps all columns on same page
workbook.Save(Server.MapPath(fileXLS));

Thank you.

Hi,

Please try this fix.And change your codes:

workbook.Worksheets[0].PageSetup.FitToPagesWide = 1; //keeps all columns on same page

//the FitToPagesTall default value is 1, so this file is fitted to page tall. if FitToPagesTall is zero,

//it means the property is useless
workbook.Worksheets[0].PageSetup.FitToPagesTall = 0;

Simon,

Thank you very much for your help. The fix solved my problem with displaying multiple pages of data.

However, the performance was extremely slow. It look about 120 seconds to convert to the PDF, while it took only 2 seconds to convert to CSV or XLS with the same amount of data.

Is it possible to speed up the process? Is there any other settings I can change to make it faster?

Hi,

Could you post your template excel file here, we will check it soon.

Thank you.

my excel file contains 8800 rows of confidential data. Which email address should I send it to?

Hi,

Could you send it to me? Click the "Contact" button of this message frame and select "Send Amjad Sahi an email" and post your template file (as an attachment) with sample code. We will check it soon.

Thank you.

Hi,

We have evaluated your issue and actaully we convert xls file to .xml file in quick time but xml2pdf takes more time. We found the issue is related to Aspose.Pdf, we have notified Aspose.Pdf team about it and they have told us that they are improving the performance of the pdf conversion related large tables.

Thank you.

When can I expect to get the fix from the PDF team?

Hi

Aspose.Pdf team will fix it soon but I think you may also post a query there (Aspose.Pdf forum) and ask about the status of your issue by yourself referring to this thread.

Thank you.

Hi,

I am a developer of aspose pdf team. It is a known issue that the performance is low when processing large table. Our developers are working hard on it. But it is complicated and can't be fixed in short time. Sorry for inconvenience.
I have attached our latest version. It works better. Please try it.
Thanks.

Best regards.