• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 597
  • Last Modified:

Explanation of textbox rect dimensions

The following code snippet creates a textbox on a pdf:

Set jso = PDDoc.GetJSObject
rect(0) = 100  ' x lower left
rect(1) = 100  ' y lower left
rect(2) = 300  ' x upper right
rect(3) = 200  ' y upper right

' add a form field
Set field = jso.addField("myFormField", "text", 0, rect)

Can someone provide me with a more detailed explanation of the coordinates for 0-3?  For some reason, I'm drawing a blank here, and it's not abundantly clear in any of the Adobe help docs.

Jim Horn
Jim Horn
1 Solution
Karl Heinz KremerCommented:
After reviewing the code, I noticed that I screwed up in my comments (because Adobe broke their own rules :-)
The individual elements are (and this is a quote from the Acrobat Javascript Scripting Reference): "upper-left x, upper-left y, lower-right x and lower-right y". In all non-JavaScript rects that are described in the SDK, they use lower left corner and upper right corner.... And not even the JavaScript rects are consistent: Rects for annotations are different again AAAAARRRRRGGGGGHHHHHH... :-)

All coordinates in PDF (and PostScript) are expressed in points. One point is 1/72".

If you want to create a text box with an upper-left corner that is two inches from the bottom of the page (all coordinates are relative to the lower left corner of your page), and one inch from the left edge, is 3 inches wide and 1/2 inch high, you would use the following code:

rect(0) = 2 * 72  ' x upper left
rect(1) = 1 * 72  ' y upper left
rect(2) = 300 * 72 ' x lower right
rect(3) = 0.5 * 72  ' y lower right

Does this make more sense now? I'm sorry for the wrong information that I posted earlier.
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAuthor Commented:
Makes sense.  I was able to stumble my way through testing this a couple of days ago.  


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now