PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Postioning text
http://forum.pdfsharp.com/viewtopic.php?f=2&t=3953
Page 1 of 1

Author:  Rocky48 [ Thu May 09, 2019 5:15 pm ]
Post subject:  Postioning text

I am investigating using this in a project where I need to position the text at a precise position on the page.
I also need to change the page orientation how do you do that?
In the "Hello World" example you have the following statement:
New XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.Center
I asume that 0, 0 is the position of the rectangle, so does that mean that 0, 0 is the centre of the page?
I also see that all the commands begin with X, so have you got a list of all these Class commands and their syntax?

Author:  TH-Soft [ Thu May 09, 2019 8:18 pm ]
Post subject:  Re: Postioning text

Rocky48 wrote:
I asume that 0, 0 is the position of the rectangle, so does that mean that 0, 0 is the centre of the page?
No. I think (0, 0) is the top-left corner of the page.
Rocky48 wrote:
I also see that all the commands begin with X, so have you got a list of all these Class commands and their syntax?
The Graphics class from Microsoft and others (Rect, Brush, Pen, ...) are sealed. The extra X indicates classes that work with PDF and with a Graphics object when needed.
The documentation from the source code can be found here:
http://www.nudoq.org/#!/Packages/PDFsha ... harp/XRect

Author:  Rocky48 [ Fri May 10, 2019 12:28 pm ]
Post subject:  Re: Postioning text

If the top left-hand corner is 0,0 why is the example printed in the centre of the page? I can't see any other commands that state any position in the pdfsharp "Hello World" example (VB VERSION)?

If the 0,0 are the top left of the page, then are the properties page.width & page.height the size of the page, so as to define the rectangle of the page size and the center property prints the text in the middle of the page. Am I right in assuming this?
If so where does the code get the page size?
How do you define the page?
I am not very conversant with C#,can I code this in VB?

Author:  TH-Soft [ Sun May 12, 2019 12:53 pm ]
Post subject:  Re: Postioning text

Rocky48 wrote:
I am not very conversant with C#,can I code this in VB?
Yes.

The DrawString method has a parameter that specifies the alignment. The XRect is the complete page. Page sizes is taken from properties of the page.
Typically you will use a smaller rectangle and a different alignment.

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