Skip to main content
Participating Frequently
August 6, 2020
Question

How to draw rectangular position with mouse drag in PDF using javascript?

  • August 6, 2020
  • 2 replies
  • 820 views

I want to get rectangular position with height & width on the mouse drag. 

Can I make below code more dynamic? For example, eRect value should be come from mouse drag and it position should not be hardcoded.   

 

var inch = 72;
var aRect = doc.getPageBox({ nPage: currentPage });
aRect[0] += 0.5 * inch; // from upper left hand corner of page.
aRect[2] = aRect[0] + 2 * inch; // Make it 2 inch wide
aRect[1] -= 0.5 * inch;
aRect[3] = aRect[1] - 0.5 * inch; // and 0.5 inch high
sigField = doc.addField("signature1", "signature", currentPage, aRect);

 

  

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
August 6, 2020

No, it's not possible. The closest you can get to it is to use the mouse to mark the two opposite corners of the box (by clicking them) and then draw it. I've developed similar tools in the past so if you're interested I could help you set it up, for a fee.

You can contact me privately via [try6767 at gmail.com] to discuss it further.

Bernd Alheit
Community Expert
Community Expert
August 6, 2020

Use Tools > Prepare Form and add the signature field with the mouse.

ideepakAuthor
Participating Frequently
August 6, 2020

My requirement is to place the new control based on mouse drag using javascript. 

Bernd Alheit
Community Expert
Community Expert
August 6, 2020

May be not possible.