Rank: Newbie
Groups: Registered
Joined: 3/20/2019(UTC) Posts: 6  Location: HaNoi Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
Hello everyone, I'm a new member and also new programmer c #, I had trouble switching from a RectangleF to Rectangle On the viewing screen, I clicked e to drag the mouse to make a rectangle and took the position to attach a digital signature, when I dragged the mouse I got the position type RectangleF, but my signature library(ItextSharp) use type Rectangle. . How to convert position selection when drag the mouse and position signature is aligned correctly? I consulted and used the rectangular mouse drag in this article: https://forum.patagames....hot-feftality-as-AcrobatQuote: PointF lt; PointF rb; NormalizeSnapshotPoints(out lt, out rb); //The rectangle on a page in PDF coordinates which should be snapshoted. float pageX = lt.X; float pageY = lt.Y; float pageW = rb.X - lt.X; float pageH = lt.Y - rb.Y;
Rectangle rect = new Rectangle((int)pageX, (int)pageY, (int)pageW, (int)pageH);
If converting directly to int as above, it will be skewed Sorry,my English is very bad, looking forward to receiving everyone's help. Thanks so much Edited by user Saturday, March 23, 2019 2:36:33 AM(UTC)
| Reason: Not specified
|
 1 user thanked thanghv for this useful post.
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Hi,
lt and rb in the code you provided is a left-top and right-bottom corner of the rectangle in PDF points in user space coordinate system. In the PDF documents, the origin of default user space always corresponds to the lowerleft corner of the page.
The contents of a page ultimately appear on a raster output device such as a display or a printer. Such devices vary greatly in the built-in coordinate systems they use to address pixels within their imageable areas. A particular device’s coordinate system is called its device space. For the monitor the origin corresponds to the topleft corner of the screen.
I don't know what exactly means the Rectangle in the iTextSharp, but seems you need convert both lt and rb from one coordinate system to another. Given that you need integer coordinates, then most likely these are coordinates on the target device (monitor?)
Without knowing the details of your project it is extremely difficult to advise something specific.
|
 1 user thanked Paul Rayman for this useful post.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 3/20/2019(UTC) Posts: 6  Location: HaNoi Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
Hi Paul,
Thank you for sharing, my project is similar to Adobe reader DC, when users open the file on pdfviewer, users will choose the location to attach the digital signature to that pdf file by drawing a rectangle to locate the signature location.
Below is my demo project Step1: open file step2: click drawing -> mouse down, hover to draw step3: click sign
Link project :https://drive.google.com/file/d/1e7LEL-_FOLzop9jAwLhQMxUIFYrtG7Q5/view?usp=sharing
My problem as mentioned above, I cannot get the exact position that the user draws on pdfviewer, you can run my project and see that after signing the signature position, it is deviated from drawing. I hope to receive your help, plz. Thanks
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 3/20/2019(UTC) Posts: 6  Location: HaNoi Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
try to use pdfViewer1.PageToClient method to convert point from page coordinate space to user control coordinate space.
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 3/20/2019(UTC) Posts: 6  Location: HaNoi Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
I did the drawing with pdfViewer1.PageToClient, you can look at my project, but it doesn't seem to be the location I need to identify the signature on the page. :(
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 3/20/2019(UTC) Posts: 6  Location: HaNoi Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
I tried every way I thought but I still couldn't solve the problem, could you please give me detailed instructions. Edited by user Wednesday, April 3, 2019 9:06:26 PM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Hi, Use the following rect instead of yours Code:Rectangle rect = new Rectangle((int)pageX, (int)pageY - (int)pageH, (int)pageW, (int)pageH);
Also use SignaturePosition to align the signature in the rectangle.
|
 2 users thanked Paul Rayman for this useful post.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 3/20/2019(UTC) Posts: 6  Location: HaNoi Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: Paul Rayman  Hi, Use the following rect instead of yours Code:Rectangle rect = new Rectangle((int)pageX, (int)pageY - (int)pageH, (int)pageW, (int)pageH);
Also use SignaturePosition to align the signature in the rectangle. Great, thank you so much!
|
|
|
|
|
|
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