PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu May 24, 2007 11:14 pm 
Offline

Joined: Thu May 24, 2007 10:20 pm
Posts: 11
Location: Bedford, UK
I'm just starting to use PDFsharp with VB.net and its looks really good. Thank you to everyone who has been working on it.

I've managed to print some strings and a paragraph of text in a rectangle, but I'm struggling with measurements.

What unit of measurement is used to define where drawstring and drawrectangle, etc. should be positioned, and how large they should be?

How about font sizes, are they in the same units?

Is it millimetres, points (72 points to an inch I think) or some other unit.

I am trying to layout a page but I'm having to do quite a lot of guessing rather than using a ruler.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu May 31, 2007 3:46 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Unit generally is Points.
You can use the XUnit class to make things simple:
Code:
XRect recA4 = new XRect(0, 0,
  XUnit.FromPoint(595),
  XUnit.FromPoint(842));

XRect recA4fromCentimeter = new XRect(0, 0,
  XUnit.FromCentimeter(21.0224),
  XUnit.FromCentimeter(29.7302));

You can also use XUnit.FromInch or XUnit.FromMillimeter.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu May 31, 2007 3:53 pm 
Offline

Joined: Thu May 24, 2007 10:20 pm
Posts: 11
Location: Bedford, UK
Thanks for that. I'll try it out and then add it to the documentation.

Ragrds.

Chris


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 04, 2007 10:46 am 
Offline

Joined: Thu May 24, 2007 10:20 pm
Posts: 11
Location: Bedford, UK
When I try the code that you suggest, I get a 13mm margin on the left, rather than an 11mm margin, and a 29mm from the top rather than 23mm!

Dim dSideMargin As Double = XUnit.FromMillimeter(11)
oXGraphics.DrawString("My test string", oXFont_H, XBrushes.Black, _
New XRect(dSideMargin, XUnit.FromMillimeter(23), oPDFPage.Width.Point - (dSideMargin * 2), oXFont_H.Height), XStringFormat.TopLeft)

Have I misunderstood something?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 04, 2007 11:13 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
AFAIK this is a bug - in PDFsharp or in Windows.
The margins of the printer add to the margins you set.

See this thread for a solution.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

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