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(float x, float y, float width, float height) 

Source Link

Document

Constructor.

Usage

From source file:com.formkiq.core.service.pdf.pdfbox.PdfTextFieldTextGroupComparatorTest.java

License:Apache License

/**
 * testCompare02()./*from   w  ww  .  j a  v a 2 s .c om*/
 */
@Test
public void testCompare02() {
    // given
    final int fontSize = 24;
    String fontName = "bold";

    final int x = 30;
    final int y0 = 756;
    final int width0 = 375;
    final int height0 = 14;

    final int y1 = 731;
    final int width1 = 112;
    final int height1 = 14;

    PdfTextField o1 = new PdfTextField();
    o1.setRectangle(new PDRectangle(x, y0, width0, height0));
    o1.setFontSize(fontSize);
    o1.setFontName(fontName);

    PdfTextField o2 = new PdfTextField();
    o2.setRectangle(new PDRectangle(x, y1, width1, height1));
    o2.setFontSize(fontSize);
    o2.setFontName(fontName);

    // when
    int result0 = this.comparator.compare(o1, o2);
    int result1 = this.comparator.compare(o2, o1);

    // then
    assertEquals(0, result0);
    assertEquals(0, result1);
}

From source file:jgnash.report.pdf.Report.java

License:Open Source License

private PDPage createPage() {

    final PDPage page = new PDPage(
            new PDRectangle(0f, 0f, (float) getPageFormat().getWidth(), (float) getPageFormat().getHeight()));

    pdfDocument.addPage(page); // add the page to the document

    return page;/*from  w w w .j av a 2s  .  com*/
}

From source file:net.bookinaction.utils.AnnotationMaker.java

License:Apache License

public PDAnnotationTextMarkup textMarkupAnnotation(PDColor color, Rectangle2D.Float position, String comment) {
    // Now add the markup annotation, a highlight to PDFBox text
    PDAnnotationTextMarkup txtMark = new PDAnnotationTextMarkup(PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT);
    txtMark.setColor(color);//ww w.java  2s. com
    txtMark.setConstantOpacity((float) 0.2); // 20% transparent

    // Set the rectangle containing the markup
    txtMark.setRectangle(new PDRectangle(position.x, position.y, position.width, position.height));
    // work out the points forming the four corners of the annotations
    // set out in anti clockwise form (Completely wraps the text)
    // OK, the below doesn't match that description.
    // It's what acrobat 7 does and displays properly!
    float[] quads = new float[8];
    quads[0] = position.x; // x1
    quads[1] = position.y + position.height; // y1
    quads[2] = position.x + position.width; // x2
    quads[3] = quads[1]; // y2
    quads[4] = quads[0]; // x3
    quads[5] = position.y; // y3
    quads[6] = quads[2]; // x4
    quads[7] = quads[5]; // y5

    txtMark.setQuadPoints(quads);
    txtMark.setContents(comment);

    return txtMark;
}

From source file:net.bookinaction.utils.AnnotationMaker.java

License:Apache License

public PDAnnotationLink linkAnnotation(PDColor color, Rectangle2D.Float position, String url) {
    // Now add the link annotation, so the clickme works
    PDAnnotationLink txtLink = new PDAnnotationLink();
    txtLink.setBorderStyle(borderULine);

    // Set the rectangle containing the link
    txtLink.setRectangle(new PDRectangle(position.x, position.y, position.width, position.height));

    // add an action
    PDActionURI action = new PDActionURI();
    action.setURI(url);/*w  w w . ja va 2 s.com*/
    txtLink.setAction(action);

    return txtLink;
}

From source file:net.bookinaction.utils.AnnotationMaker.java

License:Apache License

public PDAnnotationSquareCircle squareAnnotation(PDColor color, Rectangle2D.Float position, String message) {

    PDAnnotationSquareCircle aSquare = new PDAnnotationSquareCircle(PDAnnotationSquareCircle.SUB_TYPE_SQUARE);
    aSquare.setContents(message);/* w  w  w.j  a v  a 2 s .c o m*/
    aSquare.setColor(color);
    aSquare.setBorderStyle(borderThin);

    aSquare.setRectangle(new PDRectangle(position.x, position.y, position.width, position.height));

    return aSquare;
}

From source file:net.bookinaction.utils.AnnotationMaker.java

License:Apache License

public PDAnnotationSquareCircle circleAnnotation(PDColor fillColor, PDColor lineColor,
        Rectangle2D.Float position, String message) {
    // Now draw a few more annotations
    PDAnnotationSquareCircle aCircle = new PDAnnotationSquareCircle(PDAnnotationSquareCircle.SUB_TYPE_CIRCLE);
    aCircle.setContents(message);//from   w  ww . ja v a 2s  .c o  m
    aCircle.setInteriorColor(fillColor); // Fill in circle in red
    aCircle.setColor(lineColor); // The border itself will be blue
    aCircle.setBorderStyle(borderThin);

    aCircle.setRectangle(new PDRectangle(position.x, position.y, position.width, position.height));

    return aCircle;
}