Search in sources :

Example 11 with PDAppearanceStream

use of com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream in project PdfBox-Android by TomRoush.

the class PDSquareAppearanceHandler method generateNormalAppearance.

@Override
public void generateNormalAppearance() {
    float lineWidth = getLineWidth();
    PDAnnotationSquareCircle annotation = (PDAnnotationSquareCircle) getAnnotation();
    PDAppearanceContentStream contentStream = null;
    try {
        contentStream = getNormalAppearanceAsContentStream();
        boolean hasStroke = contentStream.setStrokingColorOnDemand(getColor());
        boolean hasBackground = contentStream.setNonStrokingColorOnDemand(annotation.getInteriorColor());
        setOpacity(contentStream, annotation.getConstantOpacity());
        contentStream.setBorderLine(lineWidth, annotation.getBorderStyle(), annotation.getBorder());
        PDBorderEffectDictionary borderEffect = annotation.getBorderEffect();
        if (borderEffect != null && borderEffect.getStyle().equals(PDBorderEffectDictionary.STYLE_CLOUDY)) {
            CloudyBorder cloudyBorder = new CloudyBorder(contentStream, borderEffect.getIntensity(), lineWidth, getRectangle());
            cloudyBorder.createCloudyRectangle(annotation.getRectDifference());
            annotation.setRectangle(cloudyBorder.getRectangle());
            annotation.setRectDifference(cloudyBorder.getRectDifference());
            PDAppearanceStream appearanceStream = annotation.getNormalAppearanceStream();
            appearanceStream.setBBox(cloudyBorder.getBBox());
            appearanceStream.setMatrix(cloudyBorder.getMatrix());
        } else {
            PDRectangle borderBox = handleBorderBox(annotation, lineWidth);
            contentStream.addRect(borderBox.getLowerLeftX(), borderBox.getLowerLeftY(), borderBox.getWidth(), borderBox.getHeight());
        }
        contentStream.drawShape(lineWidth, hasStroke, hasBackground);
    } catch (IOException e) {
        Log.e("PdfBox-Android", e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(contentStream);
    }
}
Also used : PDAppearanceContentStream(com.tom_roush.pdfbox.pdmodel.PDAppearanceContentStream) PDAppearanceStream(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream) PDBorderEffectDictionary(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDBorderEffectDictionary) PDRectangle(com.tom_roush.pdfbox.pdmodel.common.PDRectangle) IOException(java.io.IOException) PDAnnotationSquareCircle(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationSquareCircle)

Aggregations

PDAppearanceStream (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream)11 PDRectangle (com.tom_roush.pdfbox.pdmodel.common.PDRectangle)9 PDAppearanceContentStream (com.tom_roush.pdfbox.pdmodel.PDAppearanceContentStream)5 PDResources (com.tom_roush.pdfbox.pdmodel.PDResources)4 PDBorderEffectDictionary (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDBorderEffectDictionary)4 IOException (java.io.IOException)4 PDAppearanceDictionary (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary)3 PDAnnotationMarkup (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup)2 PDAnnotationSquareCircle (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationSquareCircle)2 Matrix (com.tom_roush.pdfbox.util.Matrix)2 PointF (android.graphics.PointF)1 AffineTransform (com.tom_roush.harmony.awt.geom.AffineTransform)1 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)1 PDPage (com.tom_roush.pdfbox.pdmodel.PDPage)1 PDPageContentStream (com.tom_roush.pdfbox.pdmodel.PDPageContentStream)1 COSArrayList (com.tom_roush.pdfbox.pdmodel.common.COSArrayList)1 PDFont (com.tom_roush.pdfbox.pdmodel.font.PDFont)1 PDColor (com.tom_roush.pdfbox.pdmodel.graphics.color.PDColor)1 PDFormXObject (com.tom_roush.pdfbox.pdmodel.graphics.form.PDFormXObject)1 PDFormFieldAdditionalActions (com.tom_roush.pdfbox.pdmodel.interactive.action.PDFormFieldAdditionalActions)1