Hi Paulo,
> > > > 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().
Yep works a treat.
> > > > 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.
Yep again works a treat. Although
it took a little while to figure out that the "value font size"
set to zero performs dynamic scaling and the "Caption font size"
controls the font when no scaling is required, i.e. I missed the word "Value"
when first reading your reply :-)
Many thanks for your help.
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/