PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 10:24 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Thu May 25, 2017 4:10 pm 
Offline

Joined: Thu May 25, 2017 3:54 pm
Posts: 5
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)?


Last edited by PDerryberry on Thu May 25, 2017 7:19 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu May 25, 2017 7:14 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Hi!

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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Thu May 25, 2017 7:18 pm 
Offline

Joined: Thu May 25, 2017 3:54 pm
Posts: 5
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.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 25, 2017 7:52 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Nothing obviously wrong.

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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Thu May 25, 2017 8:38 pm 
Offline

Joined: Thu May 25, 2017 3:54 pm
Posts: 5
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 26, 2017 1:16 pm 
Offline

Joined: Thu May 25, 2017 3:54 pm
Posts: 5
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 26, 2017 6:24 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
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?

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Fri May 26, 2017 6:49 pm 
Offline

Joined: Thu May 25, 2017 3:54 pm
Posts: 5
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 143 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group