Ekta Agarwal wrote:
Thanks for the pointer. Here is a simpler java code for my problem.
Your code doesn't compile because you aren't providing the class
FieldCell. So I commented out the cell event stuff and compiled
the example without the TextField (see attachment).
I didn't like what I saw because instead of removing the border,
you added a border in white. This white border covers the border
of the outer table. Maybe that's the "problem" you are referring to.
In which case it's not a problem with iText, but with your wrong use
of iText.
--
This answer is provided by 1T3XT BVBA
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.TextField;
public class TextFieldTest {
public static Font black_8 =
FontFactory.getFont(FontFactory.TIMES_ROMAN,8, Font.NORMAL, new Color(0x00,
0x00, 0x00));
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("text_field_test.pdf"));
//PdfWriter writer = PdfWriter.getInstance(document,
baosPDF);
document.open();
float[] table5Widths = {72*4.0f, 72*4.0f};
PdfPTable table5 = new PdfPTable(table5Widths);
table5.setTotalWidth(576f);
table5.setLockedWidth(true);
float[] outerTableWidths = {140f,140f};
PdfPTable outerTable = new PdfPTable(outerTableWidths);
outerTable.setTotalWidth(280f);
outerTable.setLockedWidth(true);
PdfPCell currentCell = createCellNoBorderBlack_8("3.
DATE ADMINSTRATIVE DEBT WAS INCURRED:");
currentCell.setFixedHeight(36f);
outerTable.addCell(currentCell);
currentCell = createCellNoBorderBlack_8("mm/dd/yyyy");
currentCell.setFixedHeight(36f);
outerTable.addCell(currentCell);
currentCell = new PdfPCell(outerTable);
currentCell.setBorderColor(Color.BLACK);
table5.addCell(currentCell);
currentCell = createCellNoBorderBlack_8("4. IF COURT JUDGEMENT,
DATE OBTAINED:");
currentCell.setFixedHeight(36f);
outerTable = new PdfPTable(outerTableWidths);
outerTable.setTotalWidth(280f);
outerTable.setLockedWidth(true);
outerTable.addCell(currentCell);
currentCell = new PdfPCell();
TextField t = new TextField(writer,new
Rectangle(0,0,15,15),"date");
t.setFont(black_8.getBaseFont());
t.setFieldName("date");
t.setFontSize(8);
t.setBackgroundColor(Color.GRAY);
t.setText("");
/*try {
currentCell.setCellEvent(new
FieldCell(t.getTextField(),
140, writer));
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
} */
currentCell.setFixedHeight(36f);
currentCell.setBorderColor(Color.BLACK);
outerTable.addCell(currentCell);
table5.addCell(outerTable);
document.add(table5);
}catch (IOException ie) {
System.err.println(ie.getMessage());
}
catch (DocumentException de) {
System.err.println(de.getMessage());
}
document.close();
}
public static PdfPCell createCellNoBorderBlack_8(String aString){
Paragraph p = new Paragraph();
Chunk caseChunk = new Chunk(aString,black_8 );
p.add(caseChunk);
PdfPCell cell = new PdfPCell(p);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
}
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
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/