Rank: Newbie
Groups: Registered
Joined: 12/1/2017(UTC) Posts: 2 
|
I found that the bounding boxes of all objects use lower left as origin, however, I would like to use upper left as origin. How can I make this switch without converting the origin everytime I uses it?
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 11/3/2017(UTC) Posts: 7
Was thanked: 1 time(s) in 1 post(s)
|
Hi!
In pdf the coordinate count is from the lower left corner of the page.
Therefore, you can not switch the countdown, as you want.
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 12/1/2017(UTC) Posts: 2 
|
for anyone who's interested in doing the same, I finally use the below to make the switch. Code:
public static class BoundingBoxConverter
{
public static Rectangle ToDevBox(this PdfPageObject pageObj, PdfPage page)
{
var pt1 = page.PageToDevice(0, 0, Convert.ToInt32(page.Width), Convert.ToInt32(page.Height), PageRotate.Normal, pageObj.BoundingBox.Left, pageObj.BoundingBox.Top);
var pt2 = page.PageToDevice(0, 0, Convert.ToInt32(page.Width), Convert.ToInt32(page.Height), PageRotate.Normal, pageObj.BoundingBox.Right, pageObj.BoundingBox.Bottom);
//Build rectangle
var rect = new Rectangle(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);
//And normalize it if it has the negative size in any dimension
if (rect.Width < 0)
{
rect.Width = -rect.Width;
rect.X -= rect.Width;
}
if (rect.Height < 0)
{
rect.Height = -rect.Height;
rect.Y -= rect.Height;
}
return rect;
}
}
Edited by moderator Sunday, December 3, 2017 1:09:51 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close