Page Orientation (Landscape)

May 23, 2011 at 9:28 AM

I cannot print my pdf document setting the page to landscape orientation:

	Dim _fd As New SaveFileDialog()
        _fd.Filter = "PDF file format|*.pdf"

        If True = _fd.ShowDialog Then
            Dim _pdf_document As New PdfDocument()
            Dim _page As PdfPage = _pdf_document.AddPage()
            _page.Orientation = PdfSharp.PageOrientation.Portrait
            _page.Size = PdfSharp.PageSize.A4
            Dim _gfx As XGraphics = XGraphics.FromPdfPage(_page)

                       ' Write image
            Dim _img As ImageTools.ExtendedImage = _canvas.ToImage()
            Dim _mstream As New MemoryStream
            Dim _jpg_encoder As New JpegEncoder
            _jpg_encoder.Quality = 100
            _jpg_encoder.Encode(_img, _mstream)
            _mstream.Seek(0, SeekOrigin.Begin)
            Dim _pdf_img As XImage = XImage.FromStream(_mstream)
            _gfx.DrawImage(_pdf_img, 10, 10)

            ' Save pdf
        End If
Even if I set the page orientation to landscape the output pdf is always portrait oriented.

May 23, 2011 at 10:12 AM

Considering the fact that I was made a copy mistake in the above post,
I've solved adding the PageLayout setting to the pdf docuemnt

           ' Create PDF Document
            Dim _pdf_document As New PdfDocument()
            _pdf_document.PageLayout = PdfPageLayout.SinglePage

            ' Set PDF Page
            Dim _page As PdfPage = _pdf_document.AddPage()
            _page.Size = PdfSharp.PageSize.A4
            _page.Orientation = PdfSharp.PageOrientation.Landscape

That's work!

Jun 22, 2011 at 10:01 AM

Look below, this works:

    PdfDocument document = new PdfDocument();

 // do not create new page by document.AddPage()

   PdfPage page = new PdfPage();
   page.Size = PdfSharp.PageSize.A3;
   page.Orientation = PdfSharp.PageOrientation.Landscape;

//now You can add

// I can account for this but it works :)
Have a nice day
Grzegorz Pawluch