Thanks Mark for the sample code! But I guess I will stick to the RichText stuff, as Acrobat is the only reader used, this should be fine.
Thanks again! 2010/2/11 Mark Storer <[email protected]>: > Sure, it would go something like this (writing in the email off the cuff): > > static int buttonCounter = 0; > public void addTemplateAsIcon( PdfStamper stamper, PdfTemplate template, > Rectangle rect, int pageNum ) { > PushbuttonField push = new PushbuttonField( stamper.getWriter(), rect, > "blah" + (buttonCounter++) ); > > push.setTemplate( template ); > push.setLayout( PushbuttonField.LAYOUT_ICON_ONLY ); // no caption, just the > template > push.setOptions( BaseField.READ_ONLY ); // it's just there to look pretty, > not to actually be clicked > > // you might want to mess with the scaling/adjustment settings a bit > push.setScaleIcon( PushbuttonField.SCALE_ICON_NEVER ); // don't scale the > template to fit the button bounds > push.setScaleIconHorizontalAdjustment( 0.5f ); // horizontal centered > push.setScaleIconVerticalAdjustment( 0.5f ) // vertical centered > > stamper.addAnnotation( push.getField(), pageNum ); > } > > You'll have to fill in the template yourself. You could use HTMLWorker to > fill a page to a document in memory, and import it (inefficient but easy), or > write your own text layout code. I believe a ColumnText object can write > directly to a PdfContentByte (or one of its descendents, like oh... say... > PdfTemplate). That's a happy medium leaning heavily towards the "efficient" > end of the spectrum. Building and parsing a PDF just to import a page is a > bit much in my mind (not that I haven't done it, and with HTMLWorker to boot). > > --Mark Storer > Senior Software Engineer > Cardiff.com > > #include <disclaimer> > typedef std::Disclaimer<Cardiff> DisCard; > > > >> -----Original Message----- >> From: [email protected] [mailto:[email protected]] >> Sent: Thursday, February 11, 2010 12:56 AM >> To: Post all your questions about iText here >> Subject: Re: [iText-questions] How to underline/strikethru a >> FREETEXTAnnotation? >> >> >> 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/ > > > ------------------------------------------------------------------------------ > 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/
