Thanks Mark for your quick response.
I'd like to have a detailed sample on how to do this. We can do this through
your fee based services, such as Paid Consultancy Services, as I have dead line
coming up and don't time to figure out the exact coding sequence that you
outlined. Can you please response this to my business email along:
[email protected].
Thanks.
----- Original Message -----
From: Mark Storer
To: Post all your questions about iText here
Sent: Monday, August 15, 2011 12:44 PM
Subject: Re: [iText-questions] Urgent: AcroFields.setFieldRichValue()doesn't
write out rich text
setFieldRichValue() is a partial implementation. The appearance generation
code doesn't know anything about the rich value, only the regular value.
To get around this, you have to call
myAcroFields.setGenerateAppearances(false). Then, when Reader/Acrobat/etc open
the PDF, they know they need to generated the appearances themselves.
Compliant Viewers will see the rich value and render it.
NOTE: This means flattening isn't going to work... not without first being
opened by Acrobat, and saved with the rich value drawn in.
Or you could fix it yourself. iText can render HTML fragments (which is what
the rich text is) to PDF, I just didn't hook it up when I wrote
[s|g]etFieldRichValue() because it was an off-the-cuff feature that helped
someone at the time. You could even do this sort of thing yourself without
diving directly into the iText source:
1) Get the size of the form field in question.
2) In a new document, create a page with that size
3) Use XMLWorker/HTMLWorker to draw the rich value into that new page.
4) Save the new document to a memory stream
5) Import that new document's page and use it as the appearance for the field
needing a rich value.
Not terribly efficient, but it'll work.
PS: I think you'll need to draw the field's borders as well, but that code
is fairly simple, and can be found in BaseField.java.
--Mark Storer
Senior Software Engineer
Cardiff.com
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
----------------------------------------------------------------------------
From: Leonard Rosenthol [mailto:[email protected]]
Sent: Monday, August 15, 2011 7:12 AM
To: Post here
Subject: Re: [iText-questions] Urgent: AcroFields.setFieldRichValue()
doesn't write out rich text
You have the source code to iText - why not just trace into the code and
see what's going on??
From: Taichu Zhang <[email protected]>
Reply-To: Post here <[email protected]>
Date: Mon, 15 Aug 2011 06:52:02 -0700
To: Post here <[email protected]>
Subject: [iText-questions] Urgent: AcroFields.setFieldRichValue() doesn't
write out rich text
The setFieldRichValue() method in class AcroFields does not work. However,
AcroFields.getFieldRichValue() seems work. It can return thing like this:
<?xml version="1.0"?><body xfa:APIVersion="Acroform:2.7.0.0" xfa:spec="2.1"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr"
style="margin-top:0pt;margin-bottom:0pt;font-family:Helvetica;font-size:12pt">read
line1 plain</p</body>
The so called rich value.
If I write similar rich value to another field by using the following value
<?xml version="1.0"?><body xfa:APIVersion="Acroform:2.7.0.0" xfa:spec="2.1"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr"
style="margin-top:0pt;margin-bottom:0pt;font-family:Helvetica;font-size:12pt"><b>write
line1 bold</b></p</body>
passed by setFieldRichValue(). I got the return code as true, which
indicates the success of the method. However, there is nothing in the target
field of the result PDF file. I do have the rich text flag turned on for the
write field in the fillable PDF form.
Please help, this is urgent as my project is due, and I have this as a show
stopper. If I can't write part of the text in the whole text field as bold, and
leave the rest of it as plain text, my entire project is in jeopardy. I
couldn't find any thing using setFieldRichValue() in iText examples, and I
googled it on internet as well. Is this a bug, or I'm calling it the wrong way.
Thanks.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model
configuration take the hassle out of deploying and managing Subversion and
the tools developers use with it. Learn more about uberSVN and get a free
download at: http://p.sf.net/sfu/wandisco-dev2dev
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a
reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model
configuration take the hassle out of deploying and managing Subversion and
the tools developers use with it. Learn more about uberSVN and get a free
download at: http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php