| Method from com.lowagie.text.pdf.PdfAnnotation Detail: |
public static PdfAnnotation createFileAttachment(PdfWriter writer,
Rectangle rect,
String contents,
PdfFileSpecification fs) throws IOException {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.put(PdfName.SUBTYPE, PdfName.FILEATTACHMENT);
if (contents != null)
annot.put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
annot.put(PdfName.FS, fs.getReference());
return annot;
}
Creates a file attachment annotation |
public static PdfAnnotation createFileAttachment(PdfWriter writer,
Rectangle rect,
String contents,
byte[] fileStore,
String file,
String fileDisplay) throws IOException {
return createFileAttachment(writer, rect, contents, PdfFileSpecification.fileEmbedded(writer, file, fileDisplay, fileStore));
}
Creates a file attachment annotation. |
public static PdfAnnotation createFreeText(PdfWriter writer,
Rectangle rect,
String contents,
PdfContentByte defaultAppearance) {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.put(PdfName.SUBTYPE, PdfName.FREETEXT);
annot.put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
annot.setDefaultAppearanceString(defaultAppearance);
return annot;
}
Add some free text to the document. |
public static PdfAnnotation createInk(PdfWriter writer,
Rectangle rect,
String contents,
float[][] inkList) {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.put(PdfName.SUBTYPE, PdfName.INK);
annot.put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
PdfArray outer = new PdfArray();
for (int k = 0; k < inkList.length; ++k) {
PdfArray inner = new PdfArray();
float deep[] = inkList[k];
for (int j = 0; j < deep.length; ++j)
inner.add(new PdfNumber(deep[j]));
outer.add(inner);
}
annot.put(PdfName.INKLIST, outer);
return annot;
}
|
public static PdfAnnotation createLine(PdfWriter writer,
Rectangle rect,
String contents,
float x1,
float y1,
float x2,
float y2) {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.put(PdfName.SUBTYPE, PdfName.LINE);
annot.put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
PdfArray array = new PdfArray(new PdfNumber(x1));
array.add(new PdfNumber(y1));
array.add(new PdfNumber(x2));
array.add(new PdfNumber(y2));
annot.put(PdfName.L, array);
return annot;
}
Adds a line to the document. Move over the line and a tooltip is shown. |
protected static PdfAnnotation createLink(PdfWriter writer,
Rectangle rect,
PdfName highlight) {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.put(PdfName.SUBTYPE, PdfName.LINK);
if (!highlight.equals(HIGHLIGHT_INVERT))
annot.put(PdfName.H, highlight);
return annot;
}
|
public static PdfAnnotation createLink(PdfWriter writer,
Rectangle rect,
PdfName highlight,
PdfAction action) {
PdfAnnotation annot = createLink(writer, rect, highlight);
annot.putEx(PdfName.A, action);
return annot;
}
Creates an Annotation with an Action. |
public static PdfAnnotation createLink(PdfWriter writer,
Rectangle rect,
PdfName highlight,
String namedDestination) {
PdfAnnotation annot = createLink(writer, rect, highlight);
annot.put(PdfName.DEST, new PdfString(namedDestination));
return annot;
}
Creates an Annotation with an local destination. |
public static PdfAnnotation createLink(PdfWriter writer,
Rectangle rect,
PdfName highlight,
int page,
PdfDestination dest) {
PdfAnnotation annot = createLink(writer, rect, highlight);
PdfIndirectReference ref = writer.getPageReference(page);
dest.addPage(ref);
annot.put(PdfName.DEST, dest);
return annot;
}
Creates an Annotation with a PdfDestination. |
public static PdfAnnotation createMarkup(PdfWriter writer,
Rectangle rect,
String contents,
int type,
float[] quadPoints) {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
PdfName name = PdfName.HIGHLIGHT;
switch (type) {
case MARKUP_UNDERLINE:
name = PdfName.UNDERLINE;
break;
case MARKUP_STRIKEOUT:
name = PdfName.STRIKEOUT;
break;
case MARKUP_SQUIGGLY:
name = PdfName.SQUIGGLY;
break;
}
annot.put(PdfName.SUBTYPE, name);
annot.put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
PdfArray array = new PdfArray();
for (int k = 0; k < quadPoints.length; ++k)
array.add(new PdfNumber(quadPoints[k]));
annot.put(PdfName.QUADPOINTS, array);
return annot;
}
|
public static PdfAnnotation createPopup(PdfWriter writer,
Rectangle rect,
String contents,
boolean open) {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.put(PdfName.SUBTYPE, PdfName.POPUP);
if (contents != null)
annot.put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
if (open)
annot.put(PdfName.OPEN, PdfBoolean.PDFTRUE);
return annot;
}
Adds a popup to your document. |
public static PdfAnnotation createScreen(PdfWriter writer,
Rectangle rect,
String clipTitle,
PdfFileSpecification fs,
String mimeType,
boolean playOnDisplay) throws IOException {
PdfAnnotation ann = new PdfAnnotation(writer, rect);
ann.put(PdfName.SUBTYPE, PdfName.SCREEN);
ann.put (PdfName.F, new PdfNumber(FLAGS_PRINT));
ann.put(PdfName.TYPE, PdfName.ANNOT);
ann.setPage();
PdfIndirectReference ref = ann.getIndirectReference();
PdfAction action = PdfAction.rendition(clipTitle,fs,mimeType, ref);
PdfIndirectReference actionRef = writer.addToBody(action).getIndirectReference();
// for play on display add trigger event
if (playOnDisplay)
{
PdfDictionary aa = new PdfDictionary();
aa.put(new PdfName("PV"), actionRef);
ann.put(PdfName.AA, aa);
}
ann.put(PdfName.A, actionRef);
return ann;
}
Creates a screen PdfAnnotation |
public static PdfAnnotation createSquareCircle(PdfWriter writer,
Rectangle rect,
String contents,
boolean square) {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
if (square)
annot.put(PdfName.SUBTYPE, PdfName.SQUARE);
else
annot.put(PdfName.SUBTYPE, PdfName.CIRCLE);
annot.put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
return annot;
}
Adds a circle or a square that shows a tooltip when you pass over it. |
public static PdfAnnotation createStamp(PdfWriter writer,
Rectangle rect,
String contents,
String name) {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.put(PdfName.SUBTYPE, PdfName.STAMP);
annot.put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
annot.put(PdfName.NAME, new PdfName(name));
return annot;
}
Adds a Stamp to your document. Move over the stamp and a tooltip is shown |
public static PdfAnnotation createText(PdfWriter writer,
Rectangle rect,
String title,
String contents,
boolean open,
String icon) {
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.put(PdfName.SUBTYPE, PdfName.TEXT);
if (title != null)
annot.put(PdfName.T, new PdfString(title, PdfObject.TEXT_UNICODE));
if (contents != null)
annot.put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
if (open)
annot.put(PdfName.OPEN, PdfBoolean.PDFTRUE);
if (icon != null) {
annot.put(PdfName.NAME, new PdfName(icon));
}
return annot;
}
|
public PdfIndirectReference getIndirectReference() {
if (reference == null) {
reference = writer.getPdfIndirectReference();
}
return reference;
}
|
PdfDictionary getMK() {
PdfDictionary mk = (PdfDictionary)get(PdfName.MK);
if (mk == null) {
mk = new PdfDictionary();
put(PdfName.MK, mk);
}
return mk;
}
|
public static PdfArray getMKColor(Color color) {
PdfArray array = new PdfArray();
int type = ExtendedColor.getType(color);
switch (type) {
case ExtendedColor.TYPE_GRAY: {
array.add(new PdfNumber(((GrayColor)color).getGray()));
break;
}
case ExtendedColor.TYPE_CMYK: {
CMYKColor cmyk = (CMYKColor)color;
array.add(new PdfNumber(cmyk.getCyan()));
array.add(new PdfNumber(cmyk.getMagenta()));
array.add(new PdfNumber(cmyk.getYellow()));
array.add(new PdfNumber(cmyk.getBlack()));
break;
}
case ExtendedColor.TYPE_SEPARATION:
case ExtendedColor.TYPE_PATTERN:
case ExtendedColor.TYPE_SHADING:
throw new RuntimeException("Separations, patterns and shadings are not allowed in MK dictionary.");
default:
array.add(new PdfNumber(color.getRed() / 255f));
array.add(new PdfNumber(color.getGreen() / 255f));
array.add(new PdfNumber(color.getBlue() / 255f));
}
return array;
}
|
public int getPlaceInPage() {
return placeInPage;
}
Getter for property placeInPage. |
public HashMap getTemplates() {
return templates;
}
|
public boolean isAnnotation() {
return annotation;
}
Getter for property annotation. |
public boolean isForm() {
return form;
}
Getter for property form. |
public boolean isUsed() {
return used;
}
Getter for property used. |
public void setAction(PdfAction action) {
put(PdfName.A, action);
}
|
public void setAdditionalActions(PdfName key,
PdfAction action) {
PdfDictionary dic;
PdfObject obj = get(PdfName.AA);
if (obj != null && obj.isDictionary())
dic = (PdfDictionary)obj;
else
dic = new PdfDictionary();
dic.put(key, action);
put(PdfName.AA, dic);
}
|
public void setAppearance(PdfName ap,
PdfTemplate template) {
PdfDictionary dic = (PdfDictionary)get(PdfName.AP);
if (dic == null)
dic = new PdfDictionary();
dic.put(ap, template.getIndirectReference());
put(PdfName.AP, dic);
if (!form)
return;
if (templates == null)
templates = new HashMap();
templates.put(template, null);
}
|
public void setAppearance(PdfName ap,
String state,
PdfTemplate template) {
PdfDictionary dicAp = (PdfDictionary)get(PdfName.AP);
if (dicAp == null)
dicAp = new PdfDictionary();
PdfDictionary dic;
PdfObject obj = dicAp.get(ap);
if (obj != null && obj.isDictionary())
dic = (PdfDictionary)obj;
else
dic = new PdfDictionary();
dic.put(new PdfName(state), template.getIndirectReference());
dicAp.put(ap, dic);
put(PdfName.AP, dicAp);
if (!form)
return;
if (templates == null)
templates = new HashMap();
templates.put(template, null);
}
|
public void setAppearanceState(String state) {
if (state == null) {
remove(PdfName.AS);
return;
}
put(PdfName.AS, new PdfName(state));
}
|
public void setBorder(PdfBorderArray border) {
put(PdfName.BORDER, border);
}
|
public void setBorderStyle(PdfBorderDictionary border) {
put(PdfName.BS, border);
}
|
public void setColor(Color color) {
put(PdfName.C, new PdfColor(color));
}
|
public void setDefaultAppearanceString(PdfContentByte cb) {
byte b[] = cb.getInternalBuffer().toByteArray();
int len = b.length;
for (int k = 0; k < len; ++k) {
if (b[k] == '\n")
b[k] = 32;
}
put(PdfName.DA, new PdfString(b));
}
|
public void setFlags(int flags) {
if (flags == 0)
remove(PdfName.F);
else
put(PdfName.F, new PdfNumber(flags));
}
|
public void setHighlighting(PdfName highlight) {
if (highlight.equals(HIGHLIGHT_INVERT))
remove(PdfName.H);
else
put(PdfName.H, highlight);
}
Sets the annotation's highlighting mode. The values can be
HIGHLIGHT_NONE, HIGHLIGHT_INVERT,
HIGHLIGHT_OUTLINE and HIGHLIGHT_PUSH; |
public void setLayer(PdfOCG layer) {
put(PdfName.OC, layer.getRef());
}
Sets the layer this annotation belongs to. |
public void setMKAlternateCaption(String caption) {
getMK().put(PdfName.AC, new PdfString(caption, PdfObject.TEXT_UNICODE));
}
|
public void setMKAlternateIcon(PdfTemplate template) {
getMK().put(PdfName.IX, template.getIndirectReference());
}
|
public void setMKBackgroundColor(Color color) {
if (color == null)
getMK().remove(PdfName.BG);
else
getMK().put(PdfName.BG, getMKColor(color));
}
|
public void setMKBorderColor(Color color) {
if (color == null)
getMK().remove(PdfName.BC);
else
getMK().put(PdfName.BC, getMKColor(color));
}
|
public void setMKIconFit(PdfName scale,
PdfName scalingType,
float leftoverLeft,
float leftoverBottom,
boolean fitInBounds) {
PdfDictionary dic = new PdfDictionary();
if (!scale.equals(PdfName.A))
dic.put(PdfName.SW, scale);
if (!scalingType.equals(PdfName.P))
dic.put(PdfName.S, scalingType);
if (leftoverLeft != 0.5f || leftoverBottom != 0.5f) {
PdfArray array = new PdfArray(new PdfNumber(leftoverLeft));
array.add(new PdfNumber(leftoverBottom));
dic.put(PdfName.A, array);
}
if (fitInBounds)
dic.put(PdfName.FB, PdfBoolean.PDFTRUE);
getMK().put(PdfName.IF, dic);
}
|
public void setMKNormalCaption(String caption) {
getMK().put(PdfName.CA, new PdfString(caption, PdfObject.TEXT_UNICODE));
}
|
public void setMKNormalIcon(PdfTemplate template) {
getMK().put(PdfName.I, template.getIndirectReference());
}
|
public void setMKRolloverCaption(String caption) {
getMK().put(PdfName.RC, new PdfString(caption, PdfObject.TEXT_UNICODE));
}
|
public void setMKRolloverIcon(PdfTemplate template) {
getMK().put(PdfName.RI, template.getIndirectReference());
}
|
public void setMKRotation(int rotation) {
getMK().put(PdfName.R, new PdfNumber(rotation));
}
|
public void setMKTextPosition(int tp) {
getMK().put(PdfName.TP, new PdfNumber(tp));
}
|
public void setName(String name) {
put(PdfName.NM, new PdfString(name));
}
Sets the name of the annotation.
With this name the annotation can be identified among
all the annotations on a page (it has to be unique). |
public void setPage() {
put(PdfName.P, writer.getCurrentPage());
}
|
public void setPage(int page) {
put(PdfName.P, writer.getPageReference(page));
}
|
public void setPlaceInPage(int placeInPage) {
this.placeInPage = placeInPage;
}
Places the annotation in a specified page that must be greater
or equal to the current one. With PdfStamper the page
can be any. The first page is 1. |
public void setPopup(PdfAnnotation popup) {
put(PdfName.POPUP, popup.getIndirectReference());
popup.put(PdfName.PARENT, getIndirectReference());
}
|
public void setRotate(int v) {
put(PdfName.ROTATE, new PdfNumber(v));
}
|
public void setTitle(String title) {
if (title == null) {
remove(PdfName.T);
return;
}
put(PdfName.T, new PdfString(title, PdfObject.TEXT_UNICODE));
}
|
public void setUsed() {
used = true;
}
Setter for property used. |