Convert Excel to PDF with Landscape Printing layout

Hi all,

I have converted Excel to Pdf as following sample :
https://docs.aspose.cloud/display/cellscloud/Convert+Excel+Workbook+to+Different+File+Formats
File excel template : Excel Landscape Print.xlsx

When using PrintPreview in Microsoft Excel, I see one page (in landscape printing layout). But I have received 2 pages in result convert pdf.

Please tell me how to config to get convert pdf file with only 1 page (same as PrintPreview in Microsoft Excel with Landscape Printing layout).

Thanks,
Chien


Hi Chien,


Thank you for contacting Aspose support.

Please confirm that you have shared the correct spreadsheet for our testing. We have checked the provided spreadsheet in Excel 2007, and it has two pages when set to print in Landscape. Please check the attached snapshot for your reference.

Hibabar.raza is not online. Last active: 08-05-2014, 12:23 PM Babar,

Thank you for your response.

I’m sure that I have given the right Excel file. I have downloaded and opened it again in Microsoft Excel 2007. You can see some snapshot in my printing test and the result of printing with CutePDF Writer Printer (in pdf format).

But the convert pdf seems to be always generated in Portrait layout, not in Landscape layout.

Best Regards,
Chien


Hi Chien,


Thank you for writing back.

I am afraid, I am still getting two PDF pages for your provided spreadsheet even when it is exported out via MS Excel 2010. Please check the attached resultant PDF file for your reference. However, when we tested the same scenario with Aspose.Cells for .NET API, we are able to print only one PDF page in landscape. We are currently looking into this matter further to propose a solution, and we will shortly get back to you with updates in this regard.

Hi Chien,


We have tested the Cloud API with following PdfSaveOptions and have received the desired results, that is; the resultant PDF has only one page printed in landscape. Please share your settings for further investigation.


string xml = @"
<-- Pdf property -->
False
False
None
False
90
70
Pdf
";

Hi Babar,

I have tested it again the the result convert pdf is still in 2 pages. I’m using the PDFSaveOptions as following :


true
true
false
None
false
Pdf


With that PDFSaveOptions, I have tried to test another Excel file in Portrait mode and the result convert pdf is still in 2 pages. List files :
+ Test Portrait layout.xlsx
+
Test Portrait layout.pdf

Thanks,
Chien

Hi Chien,

Thank you for providing the PdfSaveOptions settings and the new samples. Unfortunately, we are getting different results than yours. Please check the attached resultant PDF files generated from your recently provided spreadsheets. You will notice that both PDF files contains only one page. We are not sure at the moment why the behavior is different on your side. In order to further investigate the matter, please provide us your complete code (in an archive) after uploading the sample spreadsheets to your cloud storage. Please also send us your AppSID & AppKey by using the contact button on the post window to send an email to babar.raza, and attach the requested information with it. Please note, sharing the AppSID & AppKey information on the forum threads is not allowed, so please use the mechanism shared above.

Hi Babar,

Thank you for your kind support. I can show you the scenario codes (extract from my Java codes) about using Aspose.Clouds for converting pdf file from Excel Spreadsheets, includes :
+ Upload file Excel
+ Save Excel file into PDF format (directly on Aspose’s server)
+ Download the result PDF.

You can see the detail from function in file AsposeCellsUtils.java :
public static byte[] getPdfDownloadData(byte[] inputExcel, String extension) throws Exception {



I’m afraid I can’t share you the information about AppSID & AppKey because of security reasons.

Best Regards,
Chien

Hi Chien,


Thank you for providing the code snippets.

We are performing tests with your code, and we will keep you posted with updates in this regard.

Hi Chien,


Thank you for your patience with us.

We are able to replicate the problem of multiple PDF pages with your provided spreadsheets & code snippet. The problem was replicated by using the overloaded version of ProcessCommand method (available in Aspose for Cloud Java SDK) accepting four parameters, where fourth parameter is the ContentType. We have noticed that when aforesaid parameter is set to “XML” (setting the request property Content-Type to application/xml) the generated PDF contains two pages. Please note, the saveAs resource controller used in this scenario does not support JSON Content-Type yet, therefore the Content-Type should always be XML (default). However, you can avoid the generation of multiple page generation by setting the OnePagePerSheet property to true in your XML for your provided spreadsheets.

We will further investigate why we are getting 2 page PDF with OnePagePerSheet set to false & ContentType set to XML, and post our findings here for your reference.

Hi Babar,

Thank you for your response.

With your suggestion, I can resolve the current issue. But the convert pdf should have the same layout as Excel spreadsheet layout in printing preview when OnePagePerSheet = false.

I’m waiting for your further investigations about this issue.

Best Regards,
Chien

Hi Chien,


Good to know that you can bypass the problem for now. We are investigating the matter in more detail to bring you updates in this regard. We will keep you posted.

Hi Chien,


Thank you for your patience with us.

We have logged the problem discussed here as a bug in our database for further investigation & correction purposes. The ticket Id for your future reference is SAASCELLS-99. Please spare us little more time for thorough investigation to provide you the fix for it. In the meanwhile, we will keep you posted with updates in this regard.