Example usage for org.apache.pdfbox.pdmodel.common PDRectangle PDRectangle

List of usage examples for org.apache.pdfbox.pdmodel.common PDRectangle PDRectangle

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.common PDRectangle PDRectangle.

Prototype

public PDRectangle() 

Source Link

Document

Constructor.

Usage

From source file:org.socialbiz.cog.util.PDFUtil.java

License:Apache License

private void createLink(float x, float y, float textWidth, float height, String link) throws IOException {
    PDRectangle position = new PDRectangle();
    position.setLowerLeftX(x);// w  w w.ja  v a2s .c o  m
    position.setLowerLeftY(y); // down a couple of points
    position.setUpperRightX(x + textWidth);
    position.setUpperRightY(y + height);

    uri = new PDActionURI();
    uri.setURI(link);

    PDAnnotationLink txtLink = new PDAnnotationLink();
    txtLink.setRectangle(position);
    txtLink.setAction(uri);
    txtLink.setBorderStyle(borderULine);
    PDGamma gamma = new PDGamma();
    gamma.setB(1);
    txtLink.setColour(gamma);
    @SuppressWarnings("unchecked")
    List<PDAnnotationLink> annotations = page.getAnnotations();
    annotations.add(txtLink);

}

From source file:org.socialbiz.cog.WikiToPDF.java

License:Apache License

private void createLink(float x, float y, float textWidth, float height, String link) throws Exception {
    PDBorderStyleDictionary borderULine = new PDBorderStyleDictionary();
    borderULine.setStyle(PDBorderStyleDictionary.STYLE_UNDERLINE);
    borderULine.setWidth(0.5f);//  w w  w  . j a v a2s  .c  om

    PDRectangle position = new PDRectangle();
    position.setLowerLeftX(x);
    position.setLowerLeftY(y - 1);//must be a bit lower than the text
    position.setUpperRightX(x + textWidth);
    position.setUpperRightY(y + height + 1);

    PDActionURI uri = new PDActionURI();
    uri.setURI(link);

    PDAnnotationLink txtLink = new PDAnnotationLink();
    txtLink.setRectangle(position);
    txtLink.setAction(uri);
    txtLink.setBorderStyle(borderULine);
    PDGamma gamma = new PDGamma();
    gamma.setB(1);
    txtLink.setColour(gamma);
    @SuppressWarnings("unchecked")
    List<PDAnnotationLink> annotations = pdpage.getAnnotations();
    annotations.add(txtLink);
}

From source file:paper2ebook.Transformer.java

License:Apache License

/**
 * Heuristic search of the list of interesting areas in page, returned by
 * natural read order.//from   w  w  w .  j av a2s.  c  om
 */
public List<PDRectangle> getFragments(PDPage page) {
    List<PDRectangle> fragments = new ArrayList<PDRectangle>();

    // TODO: naive 2 columns hack: rewrite me to introspect the document
    // structure instead

    PDRectangle origBox = page.findCropBox();
    float width = origBox.getWidth();
    float height = origBox.getHeight();

    // top left
    PDRectangle box = new PDRectangle();
    box.setLowerLeftX(origBox.getLowerLeftX());
    box.setLowerLeftY(origBox.getLowerLeftY() + height / 2);
    box.setUpperRightX(origBox.getUpperRightX() / 2);
    box.setUpperRightY(origBox.getUpperRightY());
    fragments.add(box);

    // bottom left
    box = new PDRectangle();
    box.setLowerLeftX(origBox.getLowerLeftX());
    box.setLowerLeftY(origBox.getLowerLeftY());
    box.setUpperRightX(origBox.getUpperRightX() / 2);
    box.setUpperRightY(origBox.getUpperRightY() / 2);
    fragments.add(box);

    // top right
    box = new PDRectangle();
    box.setLowerLeftX(origBox.getLowerLeftX() + width / 2);
    box.setLowerLeftY(origBox.getLowerLeftY() + height / 2);
    box.setUpperRightX(origBox.getUpperRightX());
    box.setUpperRightY(origBox.getUpperRightY());
    fragments.add(box);

    // bottom right
    box = new PDRectangle();
    box.setLowerLeftX(origBox.getLowerLeftX() + width / 2);
    box.setLowerLeftY(origBox.getLowerLeftY());
    box.setUpperRightX(origBox.getUpperRightX());
    box.setUpperRightY(origBox.getUpperRightY() / 2);
    fragments.add(box);

    return fragments;
}

From source file:pdfboxprototype.Comment.java

/**
 * Constructor for Comment// w  ww.j a  v a2s  .  c om
 *
 * @param x
 * @param y
 * @param text
 */
public Comment(int x, int y, String text) {
    this.x = x;
    this.y = y;
    this.content = text;
    this.rectangle = new PDRectangle();
}

From source file:pdfboxprototype.Cross.java

public Cross(int x, int y) {
    this.x = x;//w ww  .j a  v a  2s  . c  o  m
    this.y = y;
    this.rectangle = new PDRectangle();
}

From source file:pdfboxprototype.Cross.java

/**
 * Constructor for Cross/*  w ww  .j  a v  a 2  s.c  om*/
 *
 * @param x
 * @param y
 * @param page
 */
public Cross(int x, int y, PDPage page) {
    this.x = x;
    this.y = y;
    this.page = page;
    this.rectangle = new PDRectangle();
}

From source file:pdfboxprototype.QuestionMark.java

/**
 * Constructor for QuestionMark/* w  ww . ja  va 2 s  .c  om*/
 *
 * @param x
 * @param y
 */
public QuestionMark(int x, int y) {
    this.x = x;
    this.y = y;
    this.rectangle = new PDRectangle();
}

From source file:pdfboxprototype.Tick.java

/**
 * Constructor for Tick/* ww w.j  a  va 2  s.  c  o  m*/
 *
 * @param x
 * @param y
 */
public Tick(int x, int y) {
    this.x = x;
    this.y = y;
    this.rectangle = new PDRectangle();
}