Print Page | Close Window

DrawLine poistioning

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3321
Printed Date: 28 Sep 24 at 11:02PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: DrawLine poistioning
Posted By: rweetch
Subject: DrawLine poistioning
Date Posted: 03 May 16 at 7:00PM
When using Drawline with a width of, say, 2mm where are the X and Y positions? are they central to the line or are they set to a corner?

thanks



Replies:
Posted By: Ingo
Date Posted: 03 May 16 at 7:16PM
Hi Weetch,

they are there where you want it ;-)
Where to begin you can set with SetOrigin.
Which metric system you can set with SetMeasurementUnits.
If you want the line at the top of the page you should save two mm if you want to see it ;-)



-------------
Cheers,
Ingo



Posted By: rweetch
Date Posted: 04 May 16 at 12:18AM
Hi Ingo

what I have is

SetOrigin(1); //top left
SetMeasurementUnits(1); //mm
SetLineWidth(0.7056); //2pts converted to mm
DrawLine(12, 122, 12, 188);
DrawLine(12, 188, 69, 188);

The vertical line is slightly to the left and the bottom line slightly to the right and slightly lower - which means that the lines don't meet correctly at the corner.




Posted By: Ingo
Date Posted: 04 May 16 at 7:09PM
Hi,

here you can read about:
http://www.debenu.com/docs/pdf_library_reference/DrawLine.php
X means horizontal and Y means vertical.
Start means left and End means right.
Perhaps it's better to use SetMeasurementUnits(0) 'cause DrawLine uses points, too (i think)?
Don't forget the NormalizePage to avoid problems with rotated pages.
If there are still slightly differences try another font.



-------------
Cheers,
Ingo



Posted By: Ingo
Date Posted: 04 May 16 at 7:13PM
BTW: 1 point is ...
25,4 mm div 72 = 0,353...



-------------
Cheers,
Ingo



Posted By: Ingo
Date Posted: 04 May 16 at 7:16PM
BTW: 1 mm is ...
72 div 25,4 => 2,834...



-------------
Cheers,
Ingo



Posted By: rweetch
Date Posted: 05 May 16 at 2:44PM
Thanks, I have trawled the function pages and docs.

I have changed the setting of line sizes to points, but need to retain positioning as mm.

The X,Y must be referencing a particular end point of the line but I can't see which. 

if we have  (Origin = Top Left) startX = 1, startY = 1, endX = 10, EndY=1 (straight line for 10mm) say at 2mm wide - does the startX,StartY reference the top left hand corner, the left centre or the bottom left corner? 

If we have 2 lines 
StartX = 1, StartY = 1, EndX = 1, EndY = 10 
StartX = 1, StartY = 10, EndX = 10, EndY = 10 

then I would expect that the bottom of line 1 and the start of line 2 would either overlap completely or line 2 would butt up against line 1. However, line 2 overlaps part of the bottom of line one in both dimensions.



Posted By: tfrost
Date Posted: 05 May 16 at 5:08PM
If you need super accuracy, you may have to work it out by trial and error.  Set the line thickness temporarily to much wider than you need, draw some lines, and get out a ruler to measure where the coordinate base is on the line.  I suspect it will be quicker than asking here for a definitive answer!

Also remember that the start and end coordinates are double, not integer.  To get absolute accuracy you may need to set Startx to 10.123, not just 10 or 11.


Posted By: Ingo
Date Posted: 05 May 16 at 5:16PM
The first line should start at 1 step to right and 1 step top (x1/y1).
It ends at the same horizontal step but 10 step to top.
So it's a vertical line 9 steps long.

The second line should start at 1 step to right and 10 step top (x1/y1).
It ends horizontal 10 steps to right and 10 steps to top
So it's a horizontal line 9 steps long.

So together there should be a 90 degree rectangle.

If there are few points not identical you should try a bit for better results and share your experiences with us.
Thanks in advance ;-)




-------------
Cheers,
Ingo



Posted By: rweetch
Date Posted: 10 Jun 16 at 6:23PM
In the end I used the draw path methods and just did a bit of fractions of a millimetre adjustments to get it to work.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk