PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Mar 29, 2024 9:51 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Mon Jan 16, 2012 10:47 am 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
Hello!

I am doing a PDF Sharp document and have two questions:

1) How can I draw a line with Arrow head? I need that to show X axis and Y axis when doing some graph. I can draw a line but then how do I draw a arrow line?

2) I have to write some text on the side of the page and it should be vertical. It is some information about the version and website and to be written in bottom of the page vertically on the side going up. Can I do that somehow?

Thanks so much for your help on these!

Have a good day!

-tulips.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 16, 2012 12:06 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi!

Re 1: DrawPolygon can be used to draw triangles (arrows).

Re 2: RotateTransform allows to draw anything rotated. You should call "XGraphicsState gs = gfx.Save();" before applying the transformations, then draw your text, then call "gfx.Restore(gs);".
viewtopic.php?p=5097#p5097
viewtopic.php?p=4865#p4865

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 16, 2012 12:52 pm 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
Thank you Thomas! As always your replies are so helpful to me!

I have been trying this to rotate but without any luck...do you see something wrong? I have to make the text vertical so like rotate 90 degree.

XGraphicsState gs = gfx.Save();
gfx.DrawString("www.google.com", font, XBrushes.Black,500, 700);
gfx.RotateTransform(-90);
gfx.Restore(gs);


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 16, 2012 1:17 pm 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
I just managed to rotate the text based on sample image code but I am not getting how to put it where I want. How and where do I specify X,Y coordinates of text to put on the page? I want it very bottom right as vertical. The rotation worked but it is not clear on what function did what. This is the code now:

XGraphicsState gs = gfx.Save();
const double dx =800, dy = 1600;
gfx.TranslateTransform(dx / 2, dy / 2);
gfx.ScaleTransform(0.7);
gfx.RotateTransform(-90);
gfx.TranslateTransform(-dx / 2, -dy / 2);
gfx.DrawString("www.google.com", font, XBrushes.Black, 600, 650);
gfx.Restore(gs);

This appears in the center in bottom half of the page and it's rotated. What can I modify to move the text on the side and below.

Thanks,
tulips


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 16, 2012 2:21 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
tulips wrote:
How and where do I specify X,Y coordinates of text to put on the page?
That's the difficult part.
With TranslateTransform you specify the pivot point (the center of the rotation). Your pivot point is the center of the page.
It will be easier if the pivot point is where the text shall go.

Please try "gfx.TranslateTransform(600, 650);" before and "gfx.TranslateTransform(-600, -650);" after the rotation.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 16, 2012 4:18 pm 
Offline

Joined: Tue Nov 08, 2011 12:24 pm
Posts: 22
Thanks Thomas for the tip. I tried that and if I do that it goes off the page. SO, I am doing this

gfx.TranslateTransform(600,750);
gfx.ScaleTransform(0.6);
gfx.RotateTransform(-90);
gfx.TranslateTransform(-600,-750);
//gfx.TranslateTransform(-dx / 2, -dy / 2);
gfx.DrawString("www.google.com", font, XBrushes.Black, 600, 700);
gfx.Restore(gs);

This is giving me good result and I just want to bring it little down to start from near the bottom but not happening. It is tricky!


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 173 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