> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Jim Cornmell
> Sent: Thursday, June 21, 2007 1:10 PM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] Accessing form variables from 
> within iText and detecting if text fits in a form field
> 
> 
> Hi Paolo, 
> 
> > > I'm currently developing an application which uses iText to 
> > > merge text and graphics into a new PDF file.  I'm 90% there 
> > > and am impressed with how easy it has been so far, but I am 
> > > stuck with two points which I hope someone can answer: 
> > > 
> > > Question 1:  Within Adobe LiveCycle you can add a variable to 
> > > the form using the:  File | Form Properties | Variable tab.   
> > > So for example I've added a variable called "foo" with a 
> > > value of "bar". 
> > > 
> > >         How can I access the value of this variable within 
> > > iText.  I basically am using iText to merge bits of 
> > > information together (images and text) and using the template 
> > > to control how this is done.  I've tried using a form field 
> > > and this works fine but is a bit hacky and the variable 
> > > facility seems like a more elegant solution. 
> > > 
> > 
> > You'll have to parse the XFA XML yourself. 
> 
> OK.  Any pointers to where in the iText API to go to extract the XML? 
>

AcroFields.getXfa().getDomDocument().
 
> > > Question2: When replacing text into a form how can I detect 
> > > if the text fits, and thus if it does not reduce the font 
> > > size of the field until it does fit for example? 
> > >         I can easily setup various field in the form so I can 
> > > control the text to some extent, i.e. setup a field to force 
> > > the text to crop or wrap.  But if one of my users specifies a 
> > > text box and wants the text to shrink to fit.  I'm currently 
> > > assuming if I can find the size of the box (which I already 
> > > can with AcroFields:getFieldPositions() ) and then the string 
> > > width (which I cannot) then I can reduce the font size until 
> > > it fits using AcroFields:setFieldProperty(). 
> > > 
> > > I guess for this I do not need to know the width of the 
> > > string I just need to know:  Is the field property set to 
> > > shrink to fit? and if so does the string fit?  If not reduce 
> > > the font little and try again. 
> > > 
> > 
> > If the field is auto-size why do you need to know the font size? 
> 
> Again maybe I'm being dumb but I've tried various options in 
> LiveCycle and all I get is cropped text, it does not shrink.  
> The closest I've found is the "Expand to fit" option in 
> layout but my resultant PDF still looks the same when I 
> substitute the values in iText. 
>

Set the value font size to 0.

Paulo


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to