Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Accessing form variables from within iText and
detecting if text fits in a form field

Jim Cornmell

2007-06-21

Replies:


Hi All iText bods,

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.

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.

Hope this all makes sense.

Thanks in advance.

Jim


***********************************************************************************
This e-mail and attachments are intended for the above name only and may be confidential. If they have come to you in error, you must take no action based on them, nor must copy or show them to anyone; please reply to this e-mail and report the error.
Security warning: Please note that this e-mail has been created in the knowledge that the internet is not a one hundred percent secure communication medium. We advise that you understand and observe this lack of security when e-mailing us.
Virus: Although we have taken steps to ensure that this e-mail and attachments are free from any virus, we advise that in keeping with good practice the recipient should ensure they are actually virus free. If you have received this e-mail in error please notify:
postmaster@pindar.com


This message has been scanned for viruses by MailControl, a service from BlackSpider Technologies.

-------------------------------------------------------------------------
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
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.