OK, I partially got it to work by using "RC":
String styles = "";
if(a.underline && !a.strikeout)
{
styles = "text-decoration:underline;";
}
else if(a.strikeout && !a.underline)
{
styles = "text-decoration:line-through;";
}
else if(a.strikeout && a.underline)
{
styles = "text-decoration:line-through underline;";
}
if (a.bold)
{
styles += "font-weight:bold;";
}
if (a.italic)
{
styles += "font-style:italic;";
}
freeText.put(PdfName.RC, new PdfString("<?xml version=\"1.0\"?><body
xmlns=\"http://www.w3.org/1999/xhtml\"
xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\"
xfa:APIVersion=\"Acrobat:8.2.0\" xfa:spec=\"2.0.2\"><p
dir=\"ltr\"><span style=\"" + styles + "font-family:" +
a.font.getFamilyFontName()[0][3] + "\">" + a.text +
"</span></p></body>"));
At least it works properly in Acrobat, but is totally ignored in i.e.
Foxit PDFReader (and I guess in any other PDF Reader).
So if anybody else has some more tips please tell me :)
Thanks!
2010/2/11 <[email protected]>:
> Thanks Mark,
>
> could you maybe share some code with me please? I am rather new to iText...
>
> Thanks a lot!
>
> 2010/2/11 Mark Storer <[email protected]>:
>> If you really want arbitrary text/font/color/etc in an annotation, you can
>> build a PushbuttonField, use the Icon-Only style, and set that button's Icon
>> to any ol PdfTemplate you like.
>>
>> I use that trick a lot when building forms whose appearance doesn't fit into
>> normal AcroForms. I draw their background into an icon-only button, then
>> draw the data-entry portion on top (with transparent borders/background).
>> This also lets me show-hide the entire "field", rather than just parts...
>> without monkeying about with Optional Content Groups.
>>
>> --Mark Storer
>> Senior Software Engineer
>> Cardiff.com
>>
>> #include <disclaimer>
>> typedef std::Disclaimer<Cardiff> DisCard;
>>
>>
>>
>>> -----Original Message-----
>>> From: Leonard Rosenthol [mailto:[email protected]]
>>> Sent: Wednesday, February 10, 2010 4:03 PM
>>> To: 'Post all your questions about iText here'
>>> Subject: Re: [iText-questions] How to underline/strikethru a FREETEXT
>>> Annotation?
>>>
>>>
>>> No, it is not possible with PDF in general (has nothing to do
>>> with iText).
>>>
>>> You should consider using regular content (aka a Stamp) instead.
>>>
>>> -----Original Message-----
>>> From: [email protected] [mailto:[email protected]]
>>> Sent: Wednesday, February 10, 2010 6:21 PM
>>> To: [email protected]
>>> Subject: [iText-questions] How to underline/strikethru a
>>> FREETEXT Annotation?
>>>
>>> I wonder if it is possible with iText to underline/strikethru
>>> a FREETEXT PdfAnnotation.
>>>
>>> My current code:
>>>
>>> PdfContentByte pcb = new PdfContentByte(writer);
>>> BaseFont font = FontFactory.getFont(BaseFont.HELVETICA, 20,
>>> Font.STRIKETHRU).getCalculatedBaseFont(false);
>>> pcb.setFontAndSize(font, 20);
>>> pcb.setColorFill(BaseColor.RED);
>>>
>>> PdfAnnotation freeText = PdfAnnotation.createFreeText(writer,
>>> new Rectangle(startX, startY, endX, endY),
>>> "My text to underline",
>>> pcb);
>>>
>>> writer.addAnnotation(freeText);
>>>
>>> Changing the style of the Font that I get from FontFactory
>>> only works with BOLD and ITALIC - but not for UNDERLINE or STRIKETHRU.
>>>
>>> Could anybody please help me out there? How can I add an
>>> underline for a FREETEXT Annotation (yes, it has to be an Annotation).
>>>
>>> Thank you very much!
>>> --
>>> NEU: Mit GMX DSL über 1000,- ¿ sparen!
>>> http://portal.gmx.net/de/go/dsl02
>>>
>>> --------------------------------------------------------------
>>> ----------------
>>> SOLARIS 10 is the OS for Data Centers - provides features
>>> such as DTrace,
>>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>>> http://p.sf.net/sfu/solaris-dev2dev
>>> _______________________________________________
>>> iText-questions mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>>
>>> Buy the iText book: http://www.1t3xt.com/docs/book.php
>>> Check the site with examples before you ask questions:
>> http://www.1t3xt.info/examples/
>> You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
>>
>> ------------------------------------------------------------------------------
>> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>> http://p.sf.net/sfu/solaris-dev2dev
>> _______________________________________________
>> iText-questions mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>> Buy the iText book: http://www.1t3xt.com/docs/book.php
>> Check the site with examples before you ask questions:
>> http://www.1t3xt.info/examples/
>> You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
>>
>>
>> ------------------------------------------------------------------------------
>> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>> http://p.sf.net/sfu/solaris-dev2dev
>> _______________________________________________
>> iText-questions mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>> Buy the iText book: http://www.1t3xt.com/docs/book.php
>> Check the site with examples before you ask questions:
>> http://www.1t3xt.info/examples/
>> You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
>>
>
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/