PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

PDF Sharp: Arrow head line AND vertical text
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1885
Page 1 of 1

Author:  tulips [ Mon Jan 16, 2012 10:47 am ]
Post subject:  PDF Sharp: Arrow head line AND vertical text

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.

Author:  Thomas Hoevel [ Mon Jan 16, 2012 12:06 pm ]
Post subject:  Re: PDF Sharp: Arrow head line AND vertical text

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

Author:  tulips [ Mon Jan 16, 2012 12:52 pm ]
Post subject:  Re: PDF Sharp: Arrow head line AND vertical text

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);

Author:  tulips [ Mon Jan 16, 2012 1:17 pm ]
Post subject:  Re: PDF Sharp: Arrow head line AND vertical text

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

Author:  Thomas Hoevel [ Mon Jan 16, 2012 2:21 pm ]
Post subject:  Re: PDF Sharp: Arrow head line AND vertical text

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.

Author:  tulips [ Mon Jan 16, 2012 4:18 pm ]
Post subject:  Re: PDF Sharp: Arrow head line AND vertical text

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!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/