PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Thu Oct 02, 2025 10:49 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Aug 04, 2015 5:59 pm 
Offline

Joined: Tue Aug 04, 2015 5:35 pm
Posts: 3
I'm using PDFSharp 1.30 GDI+. I'm importing and drawing a truss shape into a document. The trick is that in my coordinate system, the truss's bottom left corner rests at 0,0 and fills in Quadrant I from there. Rendering it in PDFSharp seemed pretty straightforward at first glance. Just loop through the line segments, running this code:
Code:
gfx.DrawLine(XPens.PowderBlue, faceLine.BasePoint.X.Inches, faceLine.BasePoint.Y.Inches, faceLine.EndPoint.X.Inches, faceLine.EndPoint.Y.Inches);


However, since the origin in PDFSharp starts at the top left, my truss shape renders upside down. I can halfway solve this by moving the origin to the bottom right with this code:
Code:
gfx.RotateTransform(180);
gfx.TranslateTransform(-612, -792); // Assumes 8.5 inch x 11 inch at 72 points/inch


Now my truss renders right side up, but because of the rotate transform, any text I add is upside down. This might be solved by a
Code:
gfx.Save()
and
Code:
gfx.Restore()
, but the text I need to add needs to be in very specific places relative to the truss shape I've drawn (like labeling the members in the attachment. I do that by attempting to add the text at the same time as drawing the lines, but then it is upside down.
Attachment:
File comment: Example of my problem
Capture.PNG
Capture.PNG [ 98.46 KiB | Viewed 5822 times ]


The simplest solution seems to be if I could move the origin to the bottom left corner. However this is not yet implemented. What's the best approach to this problem?


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 04, 2015 7:50 pm 
Offline
PDFsharp Guru
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 1057
Location: CCAA
Answered on SO:
http://stackoverflow.com/a/31817994/1015447

A combination of TranslateTransform and ScaleTransform(1,-1) should do what you want.

_________________
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  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 484 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