REST API call: PUT /cells/convert does not respect landscape orientation when coverting xml file to pdf

Hello,

I’m converting an xml file to pdf using the cells REST API. I’m using /cells/convert. In the XML file the orientation of the layout is configured to be landscape like this:

<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
			<PageSetup>
				<Layout x:Orientation="Landscape" x:CenterHorizontal="1"/>

This setting is not being applied when converting the file using ASPOSE. The resulting pdf is not in landscape mode.

I tried saving the same file as pdf with Excel. The result is a pdf with landscape pages so excel does apply the settings.

How can I resolve this issue? Is there a way I can instruct ASPOSE to output a pdf file with landscape pages?

Thanks in advance

@ExploreSpace

To ensure that the landscape orientation is respected when converting an XML file to PDF using the Aspose.Cells REST API, you may need to explicitly set the page orientation in your conversion request. Unfortunately, the default behavior may not always honor the orientation specified in the XML file.

Here are some steps you can take to resolve this issue:

  1. Check the XML Structure: Ensure that the XML file is correctly structured and that the landscape orientation is properly defined within the <PageSetup> section.

  2. Use the API Parameters: When making the API call to /cells/convert, you can specify additional parameters that may help enforce the landscape orientation. Look for parameters related to page setup or orientation in the API documentation.

  3. Post-Processing: If the API does not support setting the orientation directly, consider converting the XML to an intermediate format (like Excel) that allows you to set the orientation before converting to PDF. This can be done using Aspose.Cells to first load the XML, set the page orientation, and then save it as a PDF.

  4. Example Code: Here’s a basic example of how you might set the orientation using Aspose.Cells in C#:

    // Load the XML file
    Workbook workbook = new Workbook("input.xml");
    
    // Access the first worksheet
    Worksheet worksheet = workbook.Worksheets[0];
    
    // Set the page orientation to landscape
    worksheet.PageSetup.Orientation = PageOrientationType.Landscape;
    
    // Save the workbook as PDF
    workbook.Save("output.pdf", SaveFormat.Pdf);
    

By following these steps, you should be able to generate a PDF that respects the landscape orientation as intended. If you continue to experience issues, consider reaching out to Aspose support for further assistance.

Sources:
[1]: XML To PDF | Aspose.PDF for .NET API Reference

Thank you for the response. My issue does not seem to be solved, however.

  1. I checked the XML file structure by saving the file with Excel. Excel seems to understand the orientation setting and applies it correctly.
  2. I’ve looked for API parameters I can provide in the documentation here https://reference.aspose.cloud/cells/#/Conversion/PutConvertWorkbook. There do not seem to be any parameters for providing portrait/landscape orientation.
  3. & 4. I’m not using the .NET ASPOSE integration. I’m limited to using REST API calls.

@ExploreSpace,

Thanks for the additional information. As you are using REST (cloud) APIs, I am transferring your thread to the appropriate forum where you will receive assistance shortly.

@ExploreSpace,

Please try to add the query parameter OnePagePerSheet and set it to false.

e.g.
https://api.aspose.cloud/v3.0/cells/convert?format=pdf&OnePagePerSheet=false