PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Dec 11, 2019 5:48 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Dec 21, 2015 8:17 pm 
Offline

Joined: Mon Dec 21, 2015 7:49 pm
Posts: 13
I've forked the new GitHub repo witch I am happy that exists now.

It seems that PdfPage.Orientation is causing a bit of havoc throughout the code in relation to getting the Width and Height of the PdfPage. Currently the Width and Height properties return the rotated(rendered) width and height. The Orientation is not reset when a new rotation is applied(which doesn't fix anything). The Width and Height properties are used improperly throughout the source and the MediaBox is changed on occasion based on the value of the Orientation property. This is causing pages to be cut off when simply saving that page. The current work around is to set the Orientation property to portrait, which ensures that all properties getters return the correct value and that any value that is changed when set to landscape does not get changed(such as MediaBox). My questions are,

1: Are you accepting pull requests on GitHub?
if so,
2: What should be done about this?

I have no issue taking the time to correct the related issues with PdfPage.Orientation but before doing so, I would like a clear direction on what should be done. My personal preference is to remove PdfPage.Orientation entirely.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 21, 2015 9:15 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 508
Location: CCAA
I hope you have seen this thread and the suggested modification:
viewtopic.php?p=9587#p9587

My personal and private opinion is that a change that removes PdfPage.Orientation probably will not be merged into the master version.

Rotation and orientation are independent properties. Rotation is saved to the PDF file, orientation is internal to PDFsharp.

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 21, 2015 11:11 pm 
Offline

Joined: Mon Dec 21, 2015 7:49 pm
Posts: 13
"Rotation and orientation are independent properties." That's only partly true. The orientation is set for a PdfPage of an opened document. But it can be set afterwards witch does not immediately affect anything.

"orientation is internal to PDFsharp" Kinda true. While it does not get saved to the pdf document, it is used incorrectly to determine the dimensions of the MediaBox and other values which is the whole reason behind my post. It's breaking the way pdfs should be saved.

Commenting out those lines of code is essentially setting the orientation to PageOrientation.Portiat (the default value). While it is easier to write code using an enum over testing the rotation every time it is needed, everywhere in the code that actually uses the Orientation property seems to be incorrect. From what I can tell, after all the fixes it wont even be necessary to have. If anything, it needs to not affect other values, have a private setter and only be updated when the rotation of the page is set.

Tomorrow, I'm going to write my suggested fix in this reply and do a pull request. If they accept it, Awesome. If not, At least I'll have a proper fix until they deal with it.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 22, 2015 3:16 pm 
Offline

Joined: Thu Dec 17, 2015 2:20 pm
Posts: 4
MJLaukala wrote:
"Rotation and orientation are independent properties." That's only partly true. The orientation is set for a PdfPage of an opened document. But it can be set afterwards witch does not immediately affect anything.

"orientation is internal to PDFsharp" Kinda true. While it does not get saved to the pdf document, it is used incorrectly to determine the dimensions of the MediaBox and other values which is the whole reason behind my post. It's breaking the way pdfs should be saved.

Commenting out those lines of code is essentially setting the orientation to PageOrientation.Portiat (the default value). While it is easier to write code using an enum over testing the rotation every time it is needed, everywhere in the code that actually uses the Orientation property seems to be incorrect. From what I can tell, after all the fixes it wont even be necessary to have. If anything, it needs to not affect other values, have a private setter and only be updated when the rotation of the page is set.

Tomorrow, I'm going to write my suggested fix in this reply and do a pull request. If they accept it, Awesome. If not, At least I'll have a proper fix until they deal with it.


Please, take a look at some modification I'm using to handle portrait and landscape PDF (I've just posted the code in the forum).
http://forum.pdfsharp.net/viewtopic.php?f=3&t=3247
Now it works with portrait and Landscape (90° rotations)
It doesn't works with landscape rotated by 270°


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group