Search in sources :

Example 6 with PDBorderStyleDictionary

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

the class PDCircleAppearanceHandler method getLineWidth.

/**
 * Get the line with of the border.
 *
 * Get the width of the line used to draw a border around the annotation.
 * This may either be specified by the annotation dictionaries Border
 * setting or by the W entry in the BS border style dictionary. If both are
 * missing the default width is 1.
 *
 * @return the line width
 */
// TODO: according to the PDF spec the use of the BS entry is annotation
// specific
// so we will leave that to be implemented by individual handlers.
// If at the end all annotations support the BS entry this can be handled
// here and removed from the individual handlers.
float getLineWidth() {
    PDAnnotationMarkup annotation = (PDAnnotationMarkup) getAnnotation();
    PDBorderStyleDictionary bs = annotation.getBorderStyle();
    if (bs != null) {
        return bs.getWidth();
    }
    COSArray borderCharacteristics = annotation.getBorder();
    if (borderCharacteristics.size() >= 3) {
        COSBase base = borderCharacteristics.getObject(2);
        if (base instanceof COSNumber) {
            return ((COSNumber) base).floatValue();
        }
    }
    return 1;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) PDAnnotationMarkup(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup) COSNumber(com.tom_roush.pdfbox.cos.COSNumber) COSBase(com.tom_roush.pdfbox.cos.COSBase) PDBorderStyleDictionary(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary)

Example 7 with PDBorderStyleDictionary

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

the class PDLinkAppearanceHandler method getLineWidth.

/**
 * Get the line with of the border.
 *
 * Get the width of the line used to draw a border around the annotation.
 * This may either be specified by the annotation dictionaries Border
 * setting or by the W entry in the BS border style dictionary. If both are
 * missing the default width is 1.
 *
 * @return the line width
 */
// TODO: according to the PDF spec the use of the BS entry is annotation
// specific
// so we will leave that to be implemented by individual handlers.
// If at the end all annotations support the BS entry this can be handled
// here and removed from the individual handlers.
float getLineWidth() {
    PDAnnotationLink annotation = (PDAnnotationLink) getAnnotation();
    PDBorderStyleDictionary bs = annotation.getBorderStyle();
    if (bs != null) {
        return bs.getWidth();
    }
    COSArray borderCharacteristics = annotation.getBorder();
    if (borderCharacteristics.size() >= 3) {
        COSBase base = borderCharacteristics.getObject(2);
        if (base instanceof COSNumber) {
            return ((COSNumber) base).floatValue();
        }
    }
    return 1;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSNumber(com.tom_roush.pdfbox.cos.COSNumber) COSBase(com.tom_roush.pdfbox.cos.COSBase) PDAnnotationLink(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink) PDBorderStyleDictionary(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary)

Aggregations

PDBorderStyleDictionary (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary)7 COSArray (com.tom_roush.pdfbox.cos.COSArray)5 COSBase (com.tom_roush.pdfbox.cos.COSBase)5 COSNumber (com.tom_roush.pdfbox.cos.COSNumber)5 PDAnnotationMarkup (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup)4 PDRectangle (com.tom_roush.pdfbox.pdmodel.common.PDRectangle)2 PDColor (com.tom_roush.pdfbox.pdmodel.graphics.color.PDColor)2 PDAppearanceCharacteristicsDictionary (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceCharacteristicsDictionary)2 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)1 PDDocument (com.tom_roush.pdfbox.pdmodel.PDDocument)1 PDPage (com.tom_roush.pdfbox.pdmodel.PDPage)1 PDPageContentStream (com.tom_roush.pdfbox.pdmodel.PDPageContentStream)1 PDAnnotationLink (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink)1 PDAnnotationWidget (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1