Save This Page
Home » iText-src-2.1.3 » com.lowagie » text » pdf » [javadoc | source]
com.lowagie.text.pdf
public class: PdfAnnotation [javadoc | source]
java.lang.Object
   com.lowagie.text.pdf.PdfObject
      com.lowagie.text.pdf.PdfDictionary
         com.lowagie.text.pdf.PdfAnnotation

Direct Known Subclasses:
    PdfFormField

A PdfAnnotation is a note that is associated with a page.
Nested Class Summary:
public static class  PdfAnnotation.PdfImportedLink  This class processes links from imported pages so that they may be active. The following example code reads a group of files and places them all on the output PDF, four pages in a single page, keeping the links active.
String[] files = new String[] {"input1.pdf", "input2.pdf"};
String outputFile = "output.pdf";
int firstPage=1;
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile));
document.setPageSize(PageSize.A4);
float W = PageSize.A4.getWidth() / 2;
float H = PageSize.A4.getHeight() / 2;
document.open();
PdfContentByte cb = writer.getDirectContent();
for (int i = 0; i < files.length; i++) {
PdfReader currentReader = new PdfReader(files[i]);
currentReader.consolidateNamedDestinations();
for (int page = 1; page <= currentReader.getNumberOfPages(); page++) {
PdfImportedPage importedPage = writer.getImportedPage(currentReader, page);
float a = 0.5f;
float e = (page % 2 == 0) ? W : 0;
float f = (page % 4 == 1 || page % 4 == 2) ? H : 0;
ArrayList links = currentReader.getLinks(page);
cb.addTemplate(importedPage, a, 0, 0, a, e, f);
for (int j = 0; j < links.size(); j++) {
PdfAnnotation.PdfImportedLink link = (PdfAnnotation.PdfImportedLink)links.get(j);
if (link.isInternal()) {
int dPage = link.getDestinationPage();
int newDestPage = (dPage-1)/4 + firstPage;
float ee = (dPage % 2 == 0) ? W : 0;
float ff = (dPage % 4 == 1 || dPage % 4 == 2) ? H : 0;
link.setDestinationPage(newDestPage);
link.transformDestination(a, 0, 0, a, ee, ff);
}
link.transformRect(a, 0, 0, a, e, f);
writer.addAnnotation(link.createAnnotation(writer));
}
if (page % 4 == 0)
document.newPage();
}
if (i < files.length - 1)
document.newPage();
firstPage += (currentReader.getNumberOfPages()+3)/4;
}
document.close();
 
Field Summary
public static final  PdfName HIGHLIGHT_NONE    highlight attributename 
public static final  PdfName HIGHLIGHT_INVERT    highlight attributename 
public static final  PdfName HIGHLIGHT_OUTLINE    highlight attributename 
public static final  PdfName HIGHLIGHT_PUSH    highlight attributename 
public static final  PdfName HIGHLIGHT_TOGGLE    highlight attributename 
public static final  int FLAGS_INVISIBLE    flagvalue 
public static final  int FLAGS_HIDDEN    flagvalue 
public static final  int FLAGS_PRINT    flagvalue 
public static final  int FLAGS_NOZOOM    flagvalue 
public static final  int FLAGS_NOROTATE    flagvalue 
public static final  int FLAGS_NOVIEW    flagvalue 
public static final  int FLAGS_READONLY    flagvalue 
public static final  int FLAGS_LOCKED    flagvalue 
public static final  int FLAGS_TOGGLENOVIEW    flagvalue 
public static final  PdfName APPEARANCE_NORMAL    appearance attributename 
public static final  PdfName APPEARANCE_ROLLOVER    appearance attributename 
public static final  PdfName APPEARANCE_DOWN    appearance attributename 
public static final  PdfName AA_ENTER    attributevalue 
public static final  PdfName AA_EXIT    attributevalue 
public static final  PdfName AA_DOWN    attributevalue 
public static final  PdfName AA_UP    attributevalue 
public static final  PdfName AA_FOCUS    attributevalue 
public static final  PdfName AA_BLUR    attributevalue 
public static final  PdfName AA_JS_KEY    attributevalue 
public static final  PdfName AA_JS_FORMAT    attributevalue 
public static final  PdfName AA_JS_CHANGE    attributevalue 
public static final  PdfName AA_JS_OTHER_CHANGE    attributevalue 
public static final  int MARKUP_HIGHLIGHT    attributevalue 
public static final  int MARKUP_UNDERLINE    attributevalue 
public static final  int MARKUP_STRIKEOUT    attributevalue 
public static final  int MARKUP_SQUIGGLY    attributevalue
    since: 2.1.3 -
 
protected  PdfWriter writer     
protected  PdfIndirectReference reference     
protected  HashMap templates     
protected  boolean form     
protected  boolean annotation     
protected  boolean used    Holds value of property used. 
Fields inherited from com.lowagie.text.pdf.PdfDictionary:
FONT,  OUTLINES,  PAGE,  PAGES,  CATALOG,  hashMap
Fields inherited from com.lowagie.text.pdf.PdfObject:
BOOLEAN,  NUMBER,  STRING,  NAME,  ARRAY,  DICTIONARY,  STREAM,  NULL,  INDIRECT,  NOTHING,  TEXT_PDFDOCENCODING,  TEXT_UNICODE,  bytes,  type,  indRef
Constructor:
 public PdfAnnotation(PdfWriter writer,
    Rectangle rect) 
 public PdfAnnotation(PdfWriter writer,
    float llx,
    float lly,
    float urx,
    float ury,
    PdfAction action) 
    Constructs a new PdfAnnotation of subtype link (Action).
    Parameters:
    writer -
    llx -
    lly -
    urx -
    ury -
    action -
 public PdfAnnotation(PdfWriter writer,
    float llx,
    float lly,
    float urx,
    float ury,
    PdfString title,
    PdfString content) 
    Constructs a new PdfAnnotation of subtype text.
    Parameters:
    writer -
    llx -
    lly -
    urx -
    ury -
    title -
    content -
Method from com.lowagie.text.pdf.PdfAnnotation Summary:
createFileAttachment,   createFileAttachment,   createFreeText,   createInk,   createLine,   createLink,   createLink,   createLink,   createLink,   createMarkup,   createPopup,   createScreen,   createSquareCircle,   createStamp,   createText,   getIndirectReference,   getMK,   getMKColor,   getPlaceInPage,   getTemplates,   isAnnotation,   isForm,   isUsed,   setAction,   setAdditionalActions,   setAppearance,   setAppearance,   setAppearanceState,   setBorder,   setBorderStyle,   setColor,   setDefaultAppearanceString,   setFlags,   setHighlighting,   setLayer,   setMKAlternateCaption,   setMKAlternateIcon,   setMKBackgroundColor,   setMKBorderColor,   setMKIconFit,   setMKNormalCaption,   setMKNormalIcon,   setMKRolloverCaption,   setMKRolloverIcon,   setMKRotation,   setMKTextPosition,   setName,   setPage,   setPage,   setPlaceInPage,   setPopup,   setRotate,   setTitle,   setUsed
Methods from com.lowagie.text.pdf.PdfDictionary:
contains,   get,   getAsArray,   getAsBoolean,   getAsDict,   getAsIndirectObject,   getAsName,   getAsNumber,   getAsStream,   getAsString,   getDirectObject,   getKeys,   isCatalog,   isFont,   isOutlineTree,   isPage,   isPages,   merge,   mergeDifferent,   put,   putAll,   putEx,   remove,   size,   toPdf,   toString
Methods from com.lowagie.text.pdf.PdfObject:
canBeInObjStm,   getBytes,   getIndRef,   isArray,   isBoolean,   isDictionary,   isIndirect,   isName,   isNull,   isNumber,   isStream,   isString,   length,   setContent,   setIndRef,   toPdf,   toString,   type
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.lowagie.text.pdf.PdfAnnotation Detail:
 public static PdfAnnotation createFileAttachment(PdfWriter writer,
    Rectangle rect,
    String contents,
    PdfFileSpecification fs) throws IOException 
    Creates a file attachment annotation
 public static PdfAnnotation createFileAttachment(PdfWriter writer,
    Rectangle rect,
    String contents,
    byte[] fileStore,
    String file,
    String fileDisplay) throws IOException 
    Creates a file attachment annotation.
 public static PdfAnnotation createFreeText(PdfWriter writer,
    Rectangle rect,
    String contents,
    PdfContentByte defaultAppearance) 
    Add some free text to the document.
 public static PdfAnnotation createInk(PdfWriter writer,
    Rectangle rect,
    String contents,
    float[][] inkList) 
 public static PdfAnnotation createLine(PdfWriter writer,
    Rectangle rect,
    String contents,
    float x1,
    float y1,
    float x2,
    float y2) 
    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) 
    Creates a link.
 public static PdfAnnotation createLink(PdfWriter writer,
    Rectangle rect,
    PdfName highlight,
    PdfAction action) 
    Creates an Annotation with an Action.
 public static PdfAnnotation createLink(PdfWriter writer,
    Rectangle rect,
    PdfName highlight,
    String namedDestination) 
    Creates an Annotation with an local destination.
 public static PdfAnnotation createLink(PdfWriter writer,
    Rectangle rect,
    PdfName highlight,
    int page,
    PdfDestination dest) 
    Creates an Annotation with a PdfDestination.
 public static PdfAnnotation createMarkup(PdfWriter writer,
    Rectangle rect,
    String contents,
    int type,
    float[] quadPoints) 
 public static PdfAnnotation createPopup(PdfWriter writer,
    Rectangle rect,
    String contents,
    boolean open) 
    Adds a popup to your document.
 public static PdfAnnotation createScreen(PdfWriter writer,
    Rectangle rect,
    String clipTitle,
    PdfFileSpecification fs,
    String mimeType,
    boolean playOnDisplay) throws IOException 
    Creates a screen PdfAnnotation
 public static PdfAnnotation createSquareCircle(PdfWriter writer,
    Rectangle rect,
    String contents,
    boolean square) 
    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) 
    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) 
 public PdfIndirectReference getIndirectReference() 
 PdfDictionary getMK() 
 public static PdfArray getMKColor(Color color) 
 public int getPlaceInPage() 
    Getter for property placeInPage.
 public HashMap getTemplates() 
 public boolean isAnnotation() 
    Getter for property annotation.
 public boolean isForm() 
    Getter for property form.
 public boolean isUsed() 
    Getter for property used.
 public  void setAction(PdfAction action) 
 public  void setAdditionalActions(PdfName key,
    PdfAction action) 
 public  void setAppearance(PdfName ap,
    PdfTemplate template) 
 public  void setAppearance(PdfName ap,
    String state,
    PdfTemplate template) 
 public  void setAppearanceState(String state) 
 public  void setBorder(PdfBorderArray border) 
 public  void setBorderStyle(PdfBorderDictionary border) 
 public  void setColor(Color color) 
 public  void setDefaultAppearanceString(PdfContentByte cb) 
 public  void setFlags(int flags) 
 public  void setHighlighting(PdfName 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) 
    Sets the layer this annotation belongs to.
 public  void setMKAlternateCaption(String caption) 
 public  void setMKAlternateIcon(PdfTemplate template) 
 public  void setMKBackgroundColor(Color color) 
 public  void setMKBorderColor(Color color) 
 public  void setMKIconFit(PdfName scale,
    PdfName scalingType,
    float leftoverLeft,
    float leftoverBottom,
    boolean fitInBounds) 
 public  void setMKNormalCaption(String caption) 
 public  void setMKNormalIcon(PdfTemplate template) 
 public  void setMKRolloverCaption(String caption) 
 public  void setMKRolloverIcon(PdfTemplate template) 
 public  void setMKRotation(int rotation) 
 public  void setMKTextPosition(int tp) 
 public  void setName(String 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() 
 public  void setPage(int page) 
 public  void setPlaceInPage(int 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) 
 public  void setRotate(int v) 
 public  void setTitle(String title) 
 public  void setUsed() 
    Setter for property used.