Thank you Tilman. I was poking around trying to find where to get the Font and Font size for a PDTextField but not having any luck. Is it in the CosDictionary or what is the proper way to find those 2 pieces of information?
Really appreciate the support. > On Jun 13, 2016, at 2:51 PM, Tilman Hausherr <[email protected]> wrote: > > Am 13.06.2016 um 22:36 schrieb Barry Neu: >> Thank you for the reply. >> I could store meta data about the fields’ capacity as a last resort. >> However, there are about 50 different forms to work with and the number will >> continue to grow. >> >> Including Tilman’s reply here: >> "Calculate the width of the /Rectangle. 1 unit = 1/72 inch.” >> >> Are the /Rect coordinates represented in the following order? >> Left rectangle boundary, Top, Right, Bottom >> >> So, 91.095 - 51.855 = 39.24/72s inch wide (or a little over a 1/2 inch)?? >> >> And, how does one get to the /Rect data? > > Get the widgets of the field > > PDField.getWidgets(). Usually there is only one (unless you have several > widgets, i.e. that the field appears several times in the PDF. So do this > call: > > getWidgets().get(0).getRectangle().getWidth() > > What is in the PDF shouldn't matter, unless for debugging. I.e. don't try to > parse the PDF yourself. > > I suggest you have a look at the examples in the source download, especially > in org.apache.pdfbox.examples.interactive.form. > > Tilman > >> I have a debug session open in Eclipse but am not seeing the /Rect data in >> ether the PDField or PDAcroForm. >> >>> On Jun 13, 2016, at 12:32 PM, Aaron Mulder <[email protected]> wrote: >>> >>> If the form isn't changing, can you just check out the field >>> definition in the PDF doc? Here's one from the PDF form I'm working >>> with: >>> >>> << /Type /Annot /T (SlotsTotal 19) /V () /Rect [ 51.855 457.452 91.095 >>> 478.332 >>> ] /DV () /FT /Tx /DA (/Helvetica 12 Tf 0 g) /F 4 /MK 1972 0 R /Q 1 /Subtype >>> /Widget >> >>> >>> The /Rect units aren't in pixels but I assume the text width >>> calculation would be the same so it would work out. >>> >>> My PDF was originally a Linearized mess but I opened it and saved it >>> in Preview on OS X and then all the form elements came out in plain >>> text which made it easy to inspect in a text editor. >>> >>> Thanks, >>> Aaron >>> >>> >>> On Mon, Jun 13, 2016 at 1:32 PM, Barry Neu <[email protected]> wrote: >>>> Hello. >>>> >>>> Is it possible to calculate the pixel width of a text field on a fillable >>>> PDF? >>>> If so, is there an example available or where can I look to research? >>>> >>>> Some context: >>>> I’m working with PDFBox 2.0. >>>> Data for a fillable form is collected in a web user interface. If the >>>> value for a given field exceeds the field capacity on the form, the value >>>> should be populated on an addendum form. The font size of the field cannot >>>> scale down below a particular value. >>>> >>>> The font and font size are known in advance so the length of the Value can >>>> be calculated. But I need to know the pixel capacity of the field to know >>>> if the value will “fit”. >>>> Also open to an alternate strategy if someone has solved differently. >>>> >>>> Thanks for any help. >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

