class PDLinkAppearanceHandler extends PDAbstractAppearanceHandler
{
    private static final Logger LOG = LogManager.getLogger(PDLinkAppearanceHandler.class);
    
    public PDLinkAppearanceHandler(PDAnnotation annotation)
    {
        super(annotation);
    }

    public PDLinkAppearanceHandler(PDAnnotation annotation, PDDocument document)
    {
        super(annotation, document);
    }

    @Override
    public void generateNormalAppearance()
    {<FILL_FUNCTION_BODY>}

    @Override
    public void generateRolloverAppearance()
    {
        // No rollover appearance generated for a link annotation
    }

    @Override
    public void generateDownAppearance()
    {
     // No down appearance generated for a link annotation
    }
    
    /**
     * 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;
    }
}

        PDAnnotationLink annotation = (PDAnnotationLink) getAnnotation();
        PDRectangle rect = annotation.getRectangle();
        if (rect == null)
        {
            // 660402-p1-AnnotationEmptyRect.pdf has /Rect entry with 0 elements
            return;
        }

        // Adobe doesn't generate an appearance for a link annotation
        float lineWidth = getLineWidth();
        try (PDAppearanceContentStream contentStream = getNormalAppearanceAsContentStream())
        {
            PDColor color = annotation.getColor();
            if (color == null)
            {
                // spec is unclear, but black is what Adobe does
                color = new PDColor(new float[] { 0 }, PDDeviceGray.INSTANCE);
            }
            boolean hasStroke = contentStream.setStrokingColorOnDemand(color);

            contentStream.setBorderLine(lineWidth, annotation.getBorderStyle(), annotation.getBorder());

            // Acrobat applies a padding to each side of the bbox so the line is completely within
            // the bbox.
            PDRectangle borderEdge = getPaddedRectangle(getRectangle(),lineWidth/2);

            float[] pathsArray = annotation.getQuadPoints();

            if (pathsArray != null)
            {
                // QuadPoints shall be ignored if any coordinate in the array lies outside
                // the region specified by Rect.
                for (int i = 0; i < pathsArray.length / 2; ++i)
                {
                    if (!rect.contains(pathsArray[i * 2], pathsArray[i * 2 + 1]))
                    {
                        LOG.warn(
                                "At least one /QuadPoints entry ({};{}) is outside of rectangle, {}, /QuadPoints are ignored and /Rect is used instead",
                                pathsArray[i * 2], pathsArray[i * 2 + 1], rect);
                        pathsArray = null;
                        break;
                    }
                }
            }

            if (pathsArray == null)
            {
                // Convert rectangle coordinates as if it was a /QuadPoints entry
                pathsArray = new float[8];
                pathsArray[0] = borderEdge.getLowerLeftX();
                pathsArray[1] = borderEdge.getLowerLeftY();
                pathsArray[2] = borderEdge.getUpperRightX();
                pathsArray[3] = borderEdge.getLowerLeftY();
                pathsArray[4] = borderEdge.getUpperRightX();
                pathsArray[5] = borderEdge.getUpperRightY();
                pathsArray[6] = borderEdge.getLowerLeftX();
                pathsArray[7] = borderEdge.getUpperRightY();
            }

            boolean underlined = false;
            if (pathsArray.length >= 8)
            {
                PDBorderStyleDictionary borderStyleDic = annotation.getBorderStyle();
                if (borderStyleDic != null)
                {
                    underlined = PDBorderStyleDictionary.STYLE_UNDERLINE.equals(borderStyleDic.getStyle());
                }
            }
            int of = 0;
            while (of + 7 < pathsArray.length)
            {
                contentStream.moveTo(pathsArray[of], pathsArray[of + 1]);
                contentStream.lineTo(pathsArray[of + 2], pathsArray[of + 3]);
                if (!underlined)
                {
                    contentStream.lineTo(pathsArray[of + 4], pathsArray[of + 5]);
                    contentStream.lineTo(pathsArray[of + 6], pathsArray[of + 7]);
                    contentStream.closePath();
                }
                of += 8;
            }

            contentStream.drawShape(lineWidth, hasStroke, false);
        }
        catch (IOException e)
        {
            LOG.error(e);
        }
    
<methods>public void <init>(org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation) ,public void <init>(org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation, org.apache.pdfbox.pdmodel.PDDocument) <variables>protected static final Set<java.lang.String> ANGLED_STYLES,static final double ARROW_ANGLE,protected static final Set<java.lang.String> INTERIOR_COLOR_STYLES,protected static final Set<java.lang.String> SHORT_STYLES,private final non-sealed org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation annotation,private org.apache.pdfbox.pdmodel.font.PDFont defaultFont,protected final non-sealed org.apache.pdfbox.pdmodel.PDDocument document