We've thought of writing directly over our PDF instead of using a field but the 
part that doesn't feel right is we have to roll our own parser to parse some 
html like string to add Phrases to the pdf. Is there a better way to add 
dynamic html text that others have found to do this?

Our example
            PdfReader basePdfReader = new PdfReader(new 
ByteArrayInputStream(basePdf.getByteArray()));
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            PdfStamper stamper = new PdfStamper(basePdfReader, output);
            PdfContentByte content = stamper.getOverContent(1);
            content.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, 
BaseFont.WINANSI, BaseFont.EMBEDDED), 10.0F);

            ColumnText ct = new ColumnText(content);
            ct.setSimpleColumn(10, 20, 100, 100);

            // ------- Create something to Parse some html like string and add 
Phrases
            ct.addText(new Phrase("Some text should be ", new 
Font(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, 
BaseFont.EMBEDDED))));
            ct.addText(new Phrase("italic ", new 
Font(BaseFont.createFont(BaseFont.TIMES_ITALIC, BaseFont.WINANSI, 
BaseFont.EMBEDDED))));
            ct.addText(new Phrase("and other text to be ", new 
Font(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, 
BaseFont.EMBEDDED))));
            ct.addText(new Phrase("bold", new 
Font(BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.WINANSI, 
BaseFont.EMBEDDED))));
            // -------

            ct.go();

            stamper.close();

            return new ITextPdfForm(new 
ByteArrayInputStream(output.toByteArray()));
------------------------------

Message: 4
Date: Wed, 8 Apr 2009 11:20:25 -0500
From: Greg Orton
Subject: [iText-questions] Allow Rich Text Formatting in a field
To: "[email protected]"
        <[email protected]>
Message-ID:
        
<b05f0b4af35451408c1ee8ef08480bcf4411004...@exch2k7.isllcnets.studentloan.org>

Content-Type: text/plain; charset="us-ascii"

I'm trying to include rich text formatting in on a PDF text field so I can have 
dynamic text with some words bold and italicized within the text. I am using 
Acrobat to create my template.

For example: Some text should be <i>italic</i> and other text to be <b>bold</b>

I've found posts regarding iText not supporting this feature as of last year:
http://www.nabble.com/forum/ViewPost.jtp?post=16397594&framed=y

I also found a tutorial showing how to Create and change RichText form fields
http://www.crionics.com/tutorials/123-template_rtf_fields.html

How can I include rich text within a field without having the same formatting 
on the entire field?



This e-mail and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom

they are addressed. If you have received this e-mail in error please notify the 
originator of the message. This footer also

confirms that this e-mail message has been scanned for the presence of computer 
viruses. Any views expressed in this message are

those of the individual sender, except where the sender specifies and with 
authority, states them to be the views of Iowa Student

Loan.

This e-mail and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you have received this e-mail in error please notify the originator of the 
message. This footer also confirms that this
e-mail message has been scanned for the presence of computer viruses.

 Any views expressed in this message are those of the individual sender, except 
where the sender specifies and with authority, states them to be the views of 
Iowa Student Loan.



------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
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

Reply via email to