Search in sources :

Example 1 with PDAnnotationText

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

the class PDTextAppearanceHandler method generateNormalAppearance.

@Override
public void generateNormalAppearance() {
    PDAnnotationText annotation = (PDAnnotationText) getAnnotation();
    if (!SUPPORTED_NAMES.contains(annotation.getName())) {
        return;
    }
    PDAppearanceContentStream contentStream = null;
    try {
        contentStream = getNormalAppearanceAsContentStream();
        PDColor bgColor = getColor();
        if (bgColor == null) {
            // White is used by Adobe when /C entry is missing
            contentStream.setNonStrokingColor(1f);
        } else {
            contentStream.setNonStrokingColor(bgColor);
        }
        // stroking color is always black which is the PDF default
        setOpacity(contentStream, annotation.getConstantOpacity());
        String annotationTypeName = annotation.getName();
        if (PDAnnotationText.NAME_NOTE.equals(annotationTypeName)) {
            drawNote(annotation, contentStream);
        } else if (PDAnnotationText.NAME_CROSS.equals(annotationTypeName)) {
            drawCross(annotation, contentStream);
        } else if (PDAnnotationText.NAME_CIRCLE.equals(annotationTypeName)) {
            drawCircles(annotation, contentStream);
        } else if (PDAnnotationText.NAME_INSERT.equals(annotationTypeName)) {
            drawInsert(annotation, contentStream);
        } else if (PDAnnotationText.NAME_HELP.equals(annotationTypeName)) {
            drawHelp(annotation, contentStream);
        } else if (PDAnnotationText.NAME_PARAGRAPH.equals(annotationTypeName)) {
            drawParagraph(annotation, contentStream);
        } else if (PDAnnotationText.NAME_NEW_PARAGRAPH.equals(annotationTypeName)) {
            drawNewParagraph(annotation, contentStream);
        } else if (PDAnnotationText.NAME_STAR.equals(annotationTypeName)) {
            drawStar(annotation, contentStream);
        } else if (PDAnnotationText.NAME_CHECK.equals(annotationTypeName)) {
            drawCheck(annotation, contentStream);
        } else if (PDAnnotationText.NAME_RIGHT_ARROW.equals(annotationTypeName)) {
            drawRightArrow(annotation, contentStream);
        } else if (PDAnnotationText.NAME_RIGHT_POINTER.equals(annotationTypeName)) {
            drawRightPointer(annotation, contentStream);
        } else if (PDAnnotationText.NAME_CROSS_HAIRS.equals(annotationTypeName)) {
            drawCrossHairs(annotation, contentStream);
        } else if (PDAnnotationText.NAME_UP_ARROW.equals(annotationTypeName)) {
            drawUpArrow(annotation, contentStream);
        } else if (PDAnnotationText.NAME_UP_LEFT_ARROW.equals(annotationTypeName)) {
            drawUpLeftArrow(annotation, contentStream);
        } else if (PDAnnotationText.NAME_COMMENT.equals(annotationTypeName)) {
            drawComment(annotation, contentStream);
        } else if (PDAnnotationText.NAME_KEY.equals(annotationTypeName)) {
            drawKey(annotation, contentStream);
        }
    } catch (IOException e) {
        Log.e("PdfBox-Android", e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(contentStream);
    }
}
Also used : PDAnnotationText(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationText) PDAppearanceContentStream(com.tom_roush.pdfbox.pdmodel.PDAppearanceContentStream) IOException(java.io.IOException) PDColor(com.tom_roush.pdfbox.pdmodel.graphics.color.PDColor)

Aggregations

PDAppearanceContentStream (com.tom_roush.pdfbox.pdmodel.PDAppearanceContentStream)1 PDColor (com.tom_roush.pdfbox.pdmodel.graphics.color.PDColor)1 PDAnnotationText (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationText)1 IOException (java.io.IOException)1