PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Problem With Landscape Orientation In VB 2012 Net
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3592
Page 1 of 1

Author:  PDerryberry [ Thu May 25, 2017 4:10 pm ]
Post subject:  Problem With Landscape Orientation In VB 2012 Net

Trying to create a PDF using PDFSharp (Dll version 1.37.2.608.0) in VB Net 2012. The code looks like -

Code:
Dim PDF_Document As PdfDocument = New PdfDocument
        Dim PDF_Page As PdfPage = PDF_Document.AddPage
        PDF_Page.Size = PdfSharp.PageSize.Letter
        PDF_Page.Orientation = PdfSharp.PageOrientation.Landscape
        Dim PDF_Graphics As XGraphics = XGraphics.FromPdfPage(PDF_Page)
        Dim PDF_Font As XFont
        etc....


The PDF creates fine but it always comes up in portrait orientation in Adobe Reader DC. What am I missing (probably something obvious)?

Author:  TH-Soft [ Thu May 25, 2017 7:14 pm ]
Post subject:  Re: Problem With Landscape Orientation In VB 2012 Net

Hi!

I think setting "Landscape" sets rotation to 90. But then you set rotation to 0.
Remove the line "PDF_Page.Rotate = 0".

Author:  PDerryberry [ Thu May 25, 2017 7:18 pm ]
Post subject:  Re: Problem With Landscape Orientation In VB 2012 Net

TH-Soft wrote:
Hi!

I think setting "Landscape" sets rotation to 90. But then you set rotation to 0.
Remove the line "PDF_Page.Rotate = 0".


Just tried that and still got the same results (Just corrected code in original post). Any other suggestions will be appreciated and attempted.

Author:  TH-Soft [ Thu May 25, 2017 7:52 pm ]
Post subject:  Re: Problem With Landscape Orientation In VB 2012 Net

Nothing obviously wrong.

The Page Sizes sample (C#) uses the same instructions:
http://pdfsharp.net/wiki/PageSizes-sample.ashx

Author:  PDerryberry [ Thu May 25, 2017 8:38 pm ]
Post subject:  Re: Problem With Landscape Orientation In VB 2012 Net

TH-Soft wrote:
Nothing obviously wrong.

That's what is making my head hurt! ;-) I've got similar code in another VB app and it works just fine.

Author:  PDerryberry [ Fri May 26, 2017 1:16 pm ]
Post subject:  Re: Problem With Landscape Orientation In VB 2012 Net

Never mind - it was a 'short' between the keyboard and the seat! :oops: After a good night's sleep and a fresh look, there was a code problem I finally found.

Author:  TH-Soft [ Fri May 26, 2017 6:24 pm ]
Post subject:  Re: Problem With Landscape Orientation In VB 2012 Net

PDerryberry wrote:
there was a code problem I finally found.
Something we can learn?
Was the problem outside the code snippet you shared with us?

Author:  PDerryberry [ Fri May 26, 2017 6:49 pm ]
Post subject:  Re: Problem With Landscape Orientation In VB 2012 Net

TH-Soft wrote:
PDerryberry wrote:
there was a code problem I finally found.
Something we can learn?
Was the problem outside the code snippet you shared with us?


Yes. Because of the 'presentation', the page appeared to me to be in portrait, when it was in reality in landscape. So the setting was working fine. I initially assumed because the report ran off the page in PDFSharp that it was in portrait mode instead of landscape. It was hard to tell in Adobe Reader. Once I realized the report actually was in landscape, then I figured out what was the real problem. This particular report in VB uses x,y coordinates to print instead of one continuous line. It appears that the x,y coordinates in printing in VB translate about 25% larger when passed to PDFSharp. I just multiplied them by .75 before PDFSharp saw them, and that put everything back in perspective.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/