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

Free Support Forum - aspose.com

How to change the orientation while converting to pdf

Hi,

Using while converting from word/ppt/excel to pdf is there a way i can change the orientation to either potrait or Landscape.

@pradeepdone,

Thanks for your query.

  1. See the sample code on how to change the orientation to Landscape for the sections in the document using Aspose.Words API:
    e.g
    Sample code:

     Document doc = new Document("D:\\temp\\in.docx");
     foreach(Section sec in doc.Sections)
     {
         sec.PageSetup.Orientation = Orientation.Landscape;
     }
     doc.Save("D:\\temp\\out.pdf");
    
  2. See the following sample code on how to change the PageSetup for worksheets (in the workbook) to landscape orientation in Excel to PDF rendering using Aspose.Cells APIs:
    e.g
    Sample code:

    Workbook wb = new Workbook(“e:\test2\Book1.xlsx”);

             foreach (Worksheet ws in wb.Worksheets)
             {
                 ws.PageSetup.Orientation = PageOrientationType.Landscape;    
    
             }
    
    
             //Save as pdf file.
             wb.Save("e:\\test2\\out1.pdf", SaveFormat.Pdf);
    
  3. See the sample code on how to change the slide orientation to Landscape in Powerpoint presentation using Aspose.Slides API:
    e.g
    Sample code:

     Presentation pres = new Presentation("D:\\temp\\in.pptx");
    
     pres.SlideSize.Orientation=SlideOrienation.Landscape;
    
     pres.Save("D:\\temp\\out.pdf", SaveFormat.Pdf);
    

Hope, this helps a bit.

Thank you that helped me to get the things done.

@pradeepdone,

Good to know that the sample code segment(s) are useful to you. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.