Unable create Landscape pdf document from scrach

HI -
When I am using below code the content of the page still comes in portrait size. How can I resolve this issue.

Document myPdf = new Document();

emailPdf.Pages.Add();
Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();
margin.Top = 5f;
margin.Left = 0f;
margin.Right = 0f;
margin.Bottom = 5f;
emailPdf[1].PageInfo.Margin = margin;
emailPdf[1].PageInfo.IsLandscape = true;
emailPdf[1].SetPageSize(Aspose.Pdf.PageSize.A4.Height, Aspose.Pdf.PageSize.A4.Width);
emailPdf.Pages[1].Paragraphs.Add(GeneratePage(pagedetaillist));

 private Aspose.Pdf.Table GeneratePage(List<string> cessiondetails)
    {         
        

        Aspose.Pdf.Table tble = new Aspose.Pdf.Table();

        tble.ColumnWidths = "1400";

        for (int i = 0; i <= 50; i++)
        {

            Aspose.Pdf.Row rws = new Aspose.Pdf.Row();              
            Aspose.Pdf.Cell css = new Aspose.Pdf.Cell();
            Aspose.Pdf.Text.TextFragment tf = new Aspose.Pdf.Text.TextFragment("This is long text for landscape,This is long text for landscape,This is long text for landscape,This is long text for landscape,This is long text for landscape,This is long text for landscape,This is long text for landscape,This is long text for landscape,This is long text for landscape,");
            css.Paragraphs.Add(tf);
            rws.Cells.Add(css);
            tble.Rows.Add(rws);
        }


        return tble;
    }

@rmadesh

Thanks for contacting support.

We were able to observe the same issue while using Aspose.PDF for .NET 18.6, in our environment. Hence, for the sake of detailed investigation, we have logged it as PDFNET-44871 in our issue tracking system. We will further look into details of the issue and keep you informed with the status of its correction.

Furthermore, we have used Document.Pages[1].PageInfo Property, in order to set page margins and orientation, because Document.PageInfo Property will going to be removed in future versions of the API and you will need to set PageInfo at page level.

......
emailPdf.Pages[1].PageInfo.Margin = margin;
emailPdf.Pages[1].PageInfo.IsLandscape = true;
emailPdf.Pages[1].PageInfo.Height = PageSize.A4.Width;
emailPdf.Pages[1].PageInfo.Width = PageSize.A4.Height;
//emailPdf.Pages[1].SetPageSize(Aspose.Pdf.PageSize.A4.Height, Aspose.Pdf.PageSize.A4.Width);
emailPdf.Pages[1].Paragraphs.Add(GeneratePage());
......

Please be patient and spare us little time.

We are sorry for the inconvenience.

@rmadesh

In the code provided, the page size setting should be removed after the landscape orientation setting line

emailPdf.Pages[1].PageInfo.IsLandscape = true;// These lines are not needed.// emailPdf.Pages[1].PageInfo.Height = PageSize.A4.Width;// emailPdf.Pages[1].PageInfo.Width = PageSize.A4.Height;

Or change the page size setting by changing the width with the height

emailPdf.Pages[1].PageInfo.IsLandscape = true;
emailPdf.Pages[1].PageInfo.**Width** = PageSize.A4.Width;
emailPdf.Pages[1].PageInfo.**Height** = PageSize.A4.Height;