Java Code Examples for com.lowagie.text.pdf.TextField#setFontSize()

The following examples show how to use com.lowagie.text.pdf.TextField#setFontSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldPositioningEvents.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter,
 *      com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
 */
@Override
public void onGenericTag(PdfWriter writer, Document document, Rectangle rect, String text) {
	rect.setBottom(rect.getBottom() - 3);
	PdfFormField field = (PdfFormField) genericChunkFields.get(text);
	if (field == null) {
		TextField tf = new TextField(writer, new Rectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)), text);
		tf.setFontSize(14);
		try {
			field = tf.getTextField();
		} catch (Exception e) {
			throw new ExceptionConverter(e);
		}
	} else {
		field.put(PdfName.RECT, new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)));
	}
	if (parent == null) {
		writer.addAnnotation(field);
	} else {
		parent.addKid(field);
	}
}
 
Example 2
Source File: FieldPositioningEvents.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
 */
public void onGenericTag(PdfWriter writer, Document document,
		Rectangle rect, String text) {
	rect.setBottom(rect.getBottom() - 3);
	PdfFormField field = (PdfFormField) genericChunkFields.get(text);
	if (field == null) {
		TextField tf = new TextField(writer, new Rectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)), text);
		tf.setFontSize(14);
		try {
			field = tf.getTextField();
		} catch (Exception e) {
			throw new ExceptionConverter(e);
		}
	}
	else {
		field.put(PdfName.RECT,  new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)));
	}
	if (parent == null)
		writer.addAnnotation(field);
	else
		parent.addKid(field);
}
 
Example 3
Source File: FieldPositioningEvents.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Creates a new event. This constructor will be used if you need to position fields with a Cell Event. 
    * @throws DocumentException
    * @throws IOException*/
   public FieldPositioningEvents(PdfWriter writer, String text) throws IOException, DocumentException {
   	this.fieldWriter = writer;
   	TextField tf = new TextField(writer, new Rectangle(0, 0), text);
	tf.setFontSize(14);
	cellField = tf.getTextField();
}
 
Example 4
Source File: FieldPositioningEvents.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Creates a new event. This constructor will be used if you need to position fields with a Cell Event. 
    * @throws DocumentException
    * @throws IOException*/
   public FieldPositioningEvents(PdfWriter writer, PdfFormField parent, String text) throws IOException, DocumentException {
   	this.parent = parent;
   	TextField tf = new TextField(writer, new Rectangle(0, 0), text);
	tf.setFontSize(14);
	cellField = tf.getTextField();
}
 
Example 5
Source File: SimpleRegistrationFormTest.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell,
 *      com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
 */
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
	TextField tf = new TextField(writer, position, fieldname);
	tf.setFontSize(12);
	try{
		PdfFormField field = tf.getTextField();
		writer.addAnnotation(field);
	} catch (Exception e) {
		throw new ExceptionConverter(e);
	}
}
 
Example 6
Source File: FieldPositioningEvents.java    From gcs with Mozilla Public License 2.0 3 votes vote down vote up
/**
 * Creates a new event. This constructor will be used if you need to position fields with a Cell
 * Event.
 * 
 * @throws DocumentException
 * @throws IOException
 */
public FieldPositioningEvents(PdfWriter writer, String text) throws IOException, DocumentException {
	fieldWriter = writer;
	TextField tf = new TextField(writer, new Rectangle(0, 0), text);
	tf.setFontSize(14);
	cellField = tf.getTextField();
}
 
Example 7
Source File: FieldPositioningEvents.java    From gcs with Mozilla Public License 2.0 3 votes vote down vote up
/**
 * Creates a new event. This constructor will be used if you need to position fields with a Cell
 * Event.
 * 
 * @throws DocumentException
 * @throws IOException
 */
public FieldPositioningEvents(PdfWriter writer, PdfFormField parent, String text) throws IOException, DocumentException {
	this.parent = parent;
	TextField tf = new TextField(writer, new Rectangle(0, 0), text);
	tf.setFontSize(14);
	cellField = tf.getTextField();
}