Search in sources :

Example 46 with PDRectangle

use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.

the class PDFRenderer method transform.

// scale rotate translate
private void transform(Canvas canvas, PDPage page, float scaleX, float scaleY) {
    canvas.scale(scaleX, scaleY);
    // TODO should we be passing the scale to PageDrawer rather than messing with Graphics?
    int rotationAngle = page.getRotation();
    PDRectangle cropBox = page.getCropBox();
    if (rotationAngle != 0) {
        float translateX = 0;
        float translateY = 0;
        switch(rotationAngle) {
            case 90:
                translateX = cropBox.getHeight();
                break;
            case 270:
                translateY = cropBox.getWidth();
                break;
            case 180:
                translateX = cropBox.getWidth();
                translateY = cropBox.getHeight();
                break;
            default:
                break;
        }
        canvas.translate(translateX, translateY);
        canvas.rotate(rotationAngle);
    }
}
Also used : PDRectangle(com.tom_roush.pdfbox.pdmodel.common.PDRectangle) Paint(android.graphics.Paint)

Example 47 with PDRectangle

use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.

the class FDFAnnotation method getRectangle.

/**
 * The rectangle associated with this annotation.
 *
 * @return The annotation rectangle.
 */
public PDRectangle getRectangle() {
    PDRectangle retval = null;
    COSArray rectArray = (COSArray) annot.getDictionaryObject(COSName.RECT);
    if (rectArray != null) {
        retval = new PDRectangle(rectArray);
    }
    return retval;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) PDRectangle(com.tom_roush.pdfbox.pdmodel.common.PDRectangle)

Example 48 with PDRectangle

use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.

the class FDFAnnotationCaret method initFringe.

private void initFringe(Element element) throws IOException {
    String fringe = element.getAttribute("fringe");
    if (fringe != null && !fringe.isEmpty()) {
        String[] fringeValues = fringe.split(",");
        if (fringeValues.length != 4) {
            throw new IOException("Error: wrong amount of numbers in attribute 'fringe'");
        }
        PDRectangle rect = new PDRectangle();
        rect.setLowerLeftX(Float.parseFloat(fringeValues[0]));
        rect.setLowerLeftY(Float.parseFloat(fringeValues[1]));
        rect.setUpperRightX(Float.parseFloat(fringeValues[2]));
        rect.setUpperRightY(Float.parseFloat(fringeValues[3]));
        setFringe(rect);
    }
}
Also used : PDRectangle(com.tom_roush.pdfbox.pdmodel.common.PDRectangle) IOException(java.io.IOException)

Example 49 with PDRectangle

use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.

the class FDFAnnotationCircle method initFringe.

private void initFringe(Element element) throws IOException {
    String fringe = element.getAttribute("fringe");
    if (fringe != null && !fringe.isEmpty()) {
        String[] fringeValues = fringe.split(",");
        if (fringeValues.length != 4) {
            throw new IOException("Error: wrong amount of numbers in attribute 'fringe'");
        }
        PDRectangle rect = new PDRectangle();
        rect.setLowerLeftX(Float.parseFloat(fringeValues[0]));
        rect.setLowerLeftY(Float.parseFloat(fringeValues[1]));
        rect.setUpperRightX(Float.parseFloat(fringeValues[2]));
        rect.setUpperRightY(Float.parseFloat(fringeValues[3]));
        setFringe(rect);
    }
}
Also used : PDRectangle(com.tom_roush.pdfbox.pdmodel.common.PDRectangle) IOException(java.io.IOException)

Example 50 with PDRectangle

use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.

the class PDArtifactMarkedContent method getBBox.

/**
 * Gets the artifact's bounding box (BBox).
 *
 * @return the artifact's bounding box
 */
public PDRectangle getBBox() {
    PDRectangle retval = null;
    COSArray a = (COSArray) this.getProperties().getDictionaryObject(COSName.BBOX);
    if (a != null) {
        retval = new PDRectangle(a);
    }
    return retval;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) PDRectangle(com.tom_roush.pdfbox.pdmodel.common.PDRectangle)

Aggregations

PDRectangle (com.tom_roush.pdfbox.pdmodel.common.PDRectangle)82 IOException (java.io.IOException)19 PDResources (com.tom_roush.pdfbox.pdmodel.PDResources)13 PDAppearanceContentStream (com.tom_roush.pdfbox.pdmodel.PDAppearanceContentStream)12 PDColor (com.tom_roush.pdfbox.pdmodel.graphics.color.PDColor)11 Matrix (com.tom_roush.pdfbox.util.Matrix)11 COSArray (com.tom_roush.pdfbox.cos.COSArray)10 PDPage (com.tom_roush.pdfbox.pdmodel.PDPage)10 PDAppearanceStream (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream)9 Path (android.graphics.Path)8 AffineTransform (com.tom_roush.harmony.awt.geom.AffineTransform)7 PDFormXObject (com.tom_roush.pdfbox.pdmodel.graphics.form.PDFormXObject)6 COSBase (com.tom_roush.pdfbox.cos.COSBase)5 PDDocument (com.tom_roush.pdfbox.pdmodel.PDDocument)5 PDPageContentStream (com.tom_roush.pdfbox.pdmodel.PDPageContentStream)5 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)4 COSName (com.tom_roush.pdfbox.cos.COSName)4 PDExtendedGraphicsState (com.tom_roush.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState)4 PDAnnotationTextMarkup (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationTextMarkup)4 PDAnnotationWidget (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget)4