PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Oct 24, 2020 7:57 pm

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: Sat Jul 04, 2020 3:07 am 
Offline

Joined: Wed Jun 10, 2020 7:15 pm
Posts: 6
I have a document assembled from other pdfs. While all the pages are in portrait orientation looking at them in code reveals that some are in landscape orientation and have a rotation of 90 or 270.

When I try to add any images or text using xgraphics the items are added vertically. I can see that the page and media box have incorrect coordinates reverse the page height and width. I don't know why it rotates the image or text + or - 90 degrees though.

I've tried changing the page orientation to portrait but that doesn't work. I tried setting rotate to 0 but that sets the page back or landscape.

I also tried to transform the xgraphics using

Code:
gfx.RotateAtTransform(90, new XPoint( page.Height/2, page.Width/2));


That works partially to rotate the text or graphics but the location is off.

I also tried
Code:
 gfx.RotateTransform(90);


but then nothing is written on the page.

I don't really know what the rotateTransform or the rotateAtTransform functions are doing.


How do I get images and text to write with the correct locations when the page has a rotation of 90 or 270 and orientation says it is Landscape even though the page is being displayed as portrait?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 06, 2020 7:54 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 580
Location: CCAA
There is a known problem with rotation in version 1.50.

Maybe this post can help you:
viewtopic.php?p=11548#p11548

Workaround:
Code:
page.Orientation = PageOrientation.Portrait;


There are several problems with earlier versions (1.32 and older).

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 03, 2020 9:10 pm 
Offline

Joined: Wed Jun 10, 2020 7:15 pm
Posts: 6
TH-Soft wrote:
There is a known problem with rotation in version 1.50.

Maybe this post can help you:
viewtopic.php?p=11548#p11548

Workaround:
Code:
page.Orientation = PageOrientation.Portrait;


There are several problems with earlier versions (1.32 and older).


That didn't work. I tried manipulating page properties before initializing the XGraphics object but it just didn't work.

Had to rotate the Xgraphics object.
Code:
gfx.RotateAtTransform(90, new XPoint(page.Width / 2, page.Height / 2));

This resulted in the right orientation but coordinates being off because the center point in landscape and portrait are different. Figure out the difference between the two center points and shift the xgraphics accordingly. I think a better solution might be to move the graphics object from top left to bottom left then apply the rotate but I'm not interested in trying it out.


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 04, 2020 6:36 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 580
Location: CCAA
@All:
More details here:
viewtopic.php?f=2&t=4146&p=12919#p12919

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


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 17 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