Paulo Soares <psoares <at> consiste.pt> writes:
>
> That's too much code. Post just a small standalone example. It wouldn't
> hurt to post the resulting PDF and what you'd expect to happen.
>
> Paulo
>
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfPageEventHelper;
import com.lowagie.text.pdf.PdfWriter;
public class BeneficiaryFormCreationUtilTester extends PdfPageEventHelper {
public Document createBeneficiaryFormPDF(Document document,
PdfWriter writer) {
try {
writer.setPageEvent(this);
document.open();
PdfPTable spouseContentTable = new PdfPTable(1);
spouseContentTable.setWidthPercentage(100);
spouseContentTable.setHorizontalAlignment(0);
spouseContentTable.setKeepTogether(true);
PdfPCell cell = null;
Phrase spouseXLine = new Phrase();
String spouseUnderlineText1
= " ";
Chunk spouseUnderline1 = new Chunk
(spouseUnderlineText1.replace(' ', '\u0020')
, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
spouseUnderline1.setUnderline(0.2f, -2f);
spouseXLine.add(spouseUnderline1);
String spouseXText = " X";
Chunk spouseXTextChunk = new Chunk(spouseXText.replace
(' ', '\u0020'), FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
spouseXLine.add(spouseXTextChunk);
String spouseUnderlineText2
= " ";
Chunk spouseUnderline2 = new Chunk(
spouseUnderlineText2.replace(' ', '\u0020'),
FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
spouseUnderline2.setUnderline(0.2f, -2f);
spouseXLine.add(spouseUnderline2);
String spouseXText2 = " ";
Chunk spouseXText2Chunk = new Chunk(spouseXText2.replace
(' ', '\u0020'), FontFactory.getFont(
FontFactory.TIMES_ROMAN, 12));
spouseXLine.add(spouseXText2Chunk);
String spouseUnderlineText3 = " ";
Chunk spouseUnderline3 = new Chunk
(spouseUnderlineText3.replace(' ', '\u0020'), FontFactory.getFont
(FontFactory.TIMES_ROMAN, 12));
spouseUnderline3.setUnderline(0.2f, -2f);
spouseXLine.add(spouseUnderline3);
cell = new PdfPCell(spouseXLine);
cell.setBorder(0);
spouseContentTable.addCell(cell);
document.add(new Phrase("Adding to document
directly:"));
document.add(Chunk.NEWLINE);
document.add(Chunk.NEWLINE);
document.add(spouseUnderline1);
document.add(spouseXTextChunk);
document.add(spouseUnderline2);
document.add(spouseXText2Chunk);
document.add(spouseUnderline3);
document.add(Chunk.NEWLINE);
document.add(Chunk.NEWLINE);
document.add(new Phrase("Adding as part of a
PdfPTable:"));
document.add(Chunk.NEWLINE);
document.add(Chunk.NEWLINE);
document.add(spouseContentTable);
} catch (Exception e) {
e.printStackTrace();
System.err.println("document: " + e.getMessage());
}
document.close();
return document;
}
}
My apologies. I have replaced the previous code with a much simpler example.
Not sure how to post the resulting PDF?
Thanks.
Bill
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/