logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
gsdeng  
#1 Posted : Friday, December 1, 2017 8:30:24 AM(UTC)
Quote
gsdeng

Rank: Newbie

Groups: Registered
Joined: 12/1/2017(UTC)
Posts: 2
United States

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?
PataAndrey  
#2 Posted : Friday, December 1, 2017 8:13:07 PM(UTC)
Quote
PataAndrey

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.
gsdeng  
#3 Posted : Saturday, December 2, 2017 1:03:06 AM(UTC)
Quote
gsdeng

Rank: Newbie

Groups: Registered
Joined: 12/1/2017(UTC)
Posts: 2
United States

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

Quick Reply Show Quick Reply
Users browsing this topic
Guest (3)
New Topic Post Reply
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.