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

Free Support Forum - aspose.com

Page Order in Converting Excel to Pdf

Hi,

I’m trying to use Aspose.Pdf to convert Excel file generated from Aspose.Cells in my ASP .Net application.
I set Page order in Excel file to Down, Then Other and checked it in generated Excel file. Everything was fine. After that I used sample code from documentation to convert it to Pdf. But I lost Page order in Pdf file. Maybe this is some license limitations?

There is my code:
Workbook excel= new Workbook();
excel.Open(“C:\template.xls”);

excel.Worksheets[0].PageSetup.Orientation = PageOrientationType.Landscape;
excel.Worksheets[0].PageSetup.Order = PrintOrderType.OverThenDown;

excel.Save(“C:\Sample.xml”, FileFormatType.AsposePdf);

Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf();

pdf1.BindXML(“C:\Sample.xml”, null);

pdf1.Save(“Sample.pdf”, Aspose.Pdf.SaveType.OpenInAcrobat, Response);


Regards,
Sergey Roznikov.

Hi Sergey Roznikov,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, I have implemented you code and I was not able to reproduce this issue. I don’t think it is a license limitation. Please share your template file and we will figure it out soon.

Thank you & Best Regards,

Hi,

Thanks for your reply.

I attached my template, generated xls file and pdf file which was converted from this xls. You can see that Page Order in Xls and template is “Over, Then Down”. But in Pdf file it looks like it is “Down, Then Over”.
I tried to print this Excel file using Adobe Pdf printer and Page Order was ok after that.

I hope you will help me.

Regards,
Sergey Roznikov.

Hi Sergey Roznikov,

Thank you for providing us with the related files regarding your issue. Please re-attach your template file because the template.xls file you have attached does not contain any data.

Thank you & Best Regards,

Hi Sergey Roznikov,

Thank you for considering Aspose.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I am afraid, currently “Over, then down” feature is not supported in Cells2Pdf. We have noted your requirement and we will try to provide this feature soon.

Thank you & Best Regards

Hi Sergey,

We have supported PageSetup.Order attribute in Xls2Pdf conversion, kindly try the attached version.

There is one minor issue you may still find i.e.., When you convert your excel file to pdf, if the wrapped text (in the cells) is truncated (as displayed in MS Excel View), it won't be rendered as it is for the text will not be truncated with wrapped on property. We will surely look into it and fix it soon.

Thank you.

Hi Amjad.

Thanks a lot. It working. I will try to test it more but at first look it is perfect.

Regards,
Sergey Roznikov.

Hello again.

Page order work perfect but I have another weird issue. I want to place picture into excel file and convert file into pdf. But I had error when app tried to convert it to pdf. “Unknown attribute in Image element. The attribute name is IsNeedRepeating”.
Maybe that is because last version of Cells because I did not have this error before.

There is my sample code:
Workbook wb = new Workbook();
wb.Open(“C:\template.xls”);

Worksheet sheet = wb.Worksheets[0];
sheet.Pictures.Add(0, 0, “c:\picture.jpg”);

wb.Save(“c:\toPdf.xml”, FileFormatType.AsposePdf);

Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf();
pdf1.BindXML(“c:\toPdf.xml”, null);

pdf1.Save(“c:\SamplePdf.pdf”);

Regards,
Sergey Roznikov.

Hi,

I don't find any problem using your template file and inserting a sample picture to it, the output .pdf file is fine.

Could you post your template file with your image to reproduce the issue, we will check it soon.

Thank you.

I attached my test solution, template file and picture. I hope that you will help me.

Regards,
Sergey Roznikov.

Hi Sergey,

Yes, we found the issue as you have described i.e.., "Unknown attribute in Image element. The attribute name is IsNeedRepeating", we will figure it out soon.

Thank you.

Hi Sergey,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached latest Aspose.Pdf fix. To repeat the image/shape in the Print Title Rows, we have added the “IsNeedRepeating” attribute in Image element. Please try this latest fix and do let us know if you face any problem.

Thank you & Best Regards,

Hello again,

I think there is something wrong with PageOrder.

I attached two pdf files with different PageOrders. I made these files from one Excel file, just changed PageOrder Setting. Please see that file with PageOrder.OverThenDown have strange page breaks, some page contains one line. But the same pages with another setting in second file is ok.

Please let me know if you won’t be able to reproduce this problem. Then I will place Excel file and/or source code.

Regards,
Sergey Roznikov.


Hi,

Thanks for providing us the template files.

Kindly try the attached version, If you still find the problem, kindly post your template file(s) here, we will check it soon.

Thank you.

Hello again,

I’m sorry but I still have that problem. I attached PDF and Xls files.


Regards,
Sergey Roznikov.

Hi Sergey,

Well, when you convert an xls/xlsx file to .pdf format, there might be slight difference related the pagesetup attributes specially (e.g.., page heights / widths are not exactly the same, no. of pages may not be the same as Ms Excel shows in the preview etc.) as both formats i.e.., xls/xlsx and pdf have different sets of characteristics and architectures. But we always try to mimic the same results while rendering to pdf file format.

Could you elaborate and point out the flaws which you want to fix or minimize, we will check and figure them out.

Thank you.

Hi Sergey,

And, for your info, MS Excel 2007 throws an exception when opening your attached xlsx file into it. There are some invalid merged cells settings in your workbook. For example, "C14:G14" ,"A14:J14" etc. could not be in the same worksheet. After removing the error settings and converting the changed / updated file to pdf file, we find only 4 pages are exported where as MS Excel will print 6 pages. We are looking into this issue and get back to you soon.

Thank you.

Hi Amjad,

Sorry guys if I’m bothering you so much and thanks for info about error in my code for Excel.

We have wide reports which we are exporting to Excel and after that, if it needed, we are converting it into PDF. And main problem now that with your tool we have problem with page order OverThenDown.You saw it in my sample file, weird page breaks when some pages contain one line but in fact that page must contain more. And this issue was not presented when I tried to print Excel file with Pdf Printer, not Aspose.Pdf. Sadly but we need exactly this Page Order, not DownThenOver.

We are going to buy Aspose.Cells and Aspose.Pdf so we want to be sure that we won’t have issues when we will use it in production.

Regards,
Sergey Roznikov.

Hi Sergey,

Thanks for considering Aspose.

Sure, we figure out all your issues. If you find any issue, kindly do let us know and we will be happy to fix it asap.

Thank you.

I found another issue related to PDF. I inserted wide image into Excel file using Aspose.Cells and after that I tried to convert this file into PDF. And I see that image was truncated, it was only on first page and others pages was empty. But I tried to convert the same file using another PDF printer and I had file with image which was extended to two page, as I expect. Not sure that it is related to Page Order issue, because I tried both settings and I had the same results.

Regards,
Sergey Roznikov.