/** * Adds a formfield to the AcroForm. * @param formField */ public void addFormField(PdfFormField formField) { writer.addAnnotation(formField); }
/** * Adds a formfield to the AcroForm. * @param formField */ public void addFormField(PdfFormField formField) { writer.addAnnotation(formField); }
/** * Adds a formfield to the AcroForm. * @param formField */ public void addFormField(PdfFormField formField) { writer.addAnnotation(formField); }
public class RadioGroupCellEvent implements PdfPCellEvent { private PdfFormField radioGroup; public RadioGroupCellEvent(PdfFormField radioGroup) { this.radioGroup = radioGroup; } @Override public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { PdfWriter writer = canvases[0].getPdfWriter(); writer.addAnnotation(radioGroup); } }
void addAnnotation(PdfAnnotation annot, int page) { addAnnotation(annot); }
void addAnnotation(PdfAnnotation annot) { writer.addAnnotation(annot); }
void addAnnotation(PdfAnnotation annot) { writer.addAnnotation(annot); }
void addAnnotation(PdfAnnotation annot, int page) { addAnnotation(annot); }
void addAnnotation(PdfAnnotation annot, int page) { addAnnotation(annot); }
void addAnnotation(PdfAnnotation annot) { writer.addAnnotation(annot); }
class LinkInCell implements PdfPCellEvent { protected String url; public LinkInCell(String url) { this.url = url; } public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { PdfWriter writer = canvases[0].getPdfWriter(); PdfAction action = new PdfAction(url); PdfAnnotation link = PdfAnnotation.createLink( writer, position, PdfAnnotation.HIGHLIGHT_INVERT, action); writer.addAnnotation(link); } }
public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) { final PdfWriter writer = canvases[0].getPdfWriter(); final TextField textField = new TextField(writer, rectangle, fieldname); textField.setText(textField.getFieldName()); try { final PdfFormField field = textField.getTextField(); writer.addAnnotation(field); } catch (final IOException ioe) { throw new ExceptionConverter(ioe); } catch (final DocumentException de) { throw new ExceptionConverter(de); } }
public static final String JAPANESE = "\u3042\u304d\u3089"; public static final String FONT = "resources/fonts/FreeSans.ttf"; public void createPdf(String dest) throws IOException, DocumentException { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open(); PushbuttonField button = new PushbuttonField(writer, new Rectangle(36, 780, 144, 806), "japanese"); BaseFont bf = BaseFont.createFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); button.setFont(bf); button.setText(JAPANESE); writer.addAnnotation(button.getField()); document.close(); }
public static void main(String[] args) throws IOException, DocumentException { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("js.pdf")); document.open(); writer.addJavaScript("function makeNegative() { this.getField('value2').value = -(this.getField('value1').value); } "); Rectangle rect1 = new Rectangle(40, 740, 200, 756); TextField value = new TextField(writer, rect1, "value1"); value.setBorderColor(GrayColor.GRAYBLACK); value.setBorderWidth(0.5f); PdfFormField field = value.getTextField(); field.setAdditionalActions(PdfName.BL, PdfAction.javaScript("makeNegative();", writer)); writer.addAnnotation(field); Rectangle rect2 = new Rectangle(40, 710, 200, 726); TextField neg = new TextField(writer, rect2, "value2"); neg.setBorderColor(GrayColor.GRAYBLACK); neg.setBorderWidth(0.5f); writer.addAnnotation(neg.getTextField()); document.close(); }
/** * @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 rect, PdfContentByte[] canvases) { if (cellField == null || (fieldWriter == null && parent == null)) throw new ExceptionConverter(new IllegalArgumentException("You have used the wrong constructor for this FieldPositioningEvents class.")); cellField.put(PdfName.RECT, new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding))); if (parent == null) fieldWriter.addAnnotation(cellField); else parent.addKid(cellField); } }
public void addAnnotation(PdfWriter writer, Document document, Rectangle rect, String text) { PdfAnnotation annotation = new PdfAnnotation(writer, new Rectangle( rect.getRight() + 10, rect.getBottom(), rect.getRight() + 30, rect.getTop())); annotation.setTitle("Text annotation"); annotation.put(PdfName.SUBTYPE, PdfName.TEXT); annotation.put(PdfName.OPEN, PdfBoolean.PDFFALSE); annotation.put(PdfName.NAME, new PdfName(text)); writer.addAnnotation(annotation); }
@SuppressWarnings( "unused" ) private void addCell_WithRadioButton( PdfPTable table, PdfWriter writer, PdfPCell cell, String strfldName ) { PdfFormField radiogroupField = PdfFormField.createRadioButton( writer, true ); radiogroupField.setFieldName( strfldName ); cell.setCellEvent( new PdfFieldCell( radiogroupField, new String[]{ "Yes", "No", "null" }, new String[]{ "true", "false", "" }, "", 30.0f, PdfDataEntryFormUtil.UNITSIZE_DEFAULT, PdfFieldCell.TYPE_RADIOBUTTON, writer ) ); table.addCell( cell ); writer.addAnnotation( radiogroupField ); }
/** * @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 rect, PdfContentByte[] canvases) { if (cellField == null || (fieldWriter == null && parent == null)) throw new IllegalArgumentException(MessageLocalization.getComposedMessage("you.have.used.the.wrong.constructor.for.this.fieldpositioningevents.class")); cellField.put(PdfName.RECT, new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding))); if (parent == null) fieldWriter.addAnnotation(cellField); else parent.addKid(cellField); } }
/** * @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 rect, PdfContentByte[] canvases) { if (cellField == null || (fieldWriter == null && parent == null)) throw new IllegalArgumentException(MessageLocalization.getComposedMessage("you.have.used.the.wrong.constructor.for.this.fieldpositioningevents.class")); cellField.put(PdfName.RECT, new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding))); if (parent == null) fieldWriter.addAnnotation(cellField); else parent.addKid(cellField); } }
protected boolean drawPdfScript( final RenderNode box ) { final Object attribute = box.getAttributes().getAttribute( AttributeNames.Pdf.NAMESPACE, AttributeNames.Pdf.SCRIPT_ACTION ); if ( attribute == null ) { return false; } final String attributeText = String.valueOf( attribute ); final PdfAction action = PdfAction.javaScript( attributeText, writer, false ); final AffineTransform affineTransform = getGraphics().getTransform(); final float translateX = (float) affineTransform.getTranslateX(); final float leftX = translateX + (float) ( StrictGeomUtility.toExternalValue( box.getX() ) ); final float rightX = translateX + (float) ( StrictGeomUtility.toExternalValue( box.getX() + box.getWidth() ) ); final float lowerY = (float) ( globalHeight - StrictGeomUtility.toExternalValue( box.getY() + box.getHeight() ) ); final float upperY = (float) ( globalHeight - StrictGeomUtility.toExternalValue( box.getY() ) ); final PdfAnnotation annotation = new PdfAnnotation( writer, leftX, lowerY, rightX, upperY, action ); writer.addAnnotation( annotation ); return true; }