iText rectangle - can't remove border

2019-07-07 05:50发布

问题:

I can't seem to remove the border on a rectangle! See code below, I am creating a link using a PDFannotation. The links all work but each rectangle has a border.

PdfAnnotation annotation;
Rectangle rect = new Rectangle(xOffset, yOffset, xOffset + tab.getScaledWidth(),      yOffset+tab.getScaledHeight());

rect.setBorder(Rectangle.NO_BORDER);

annotation = PdfAnnotation.createLink(writer, rect, PdfAnnotation.HIGHLIGHT_NONE,      PdfAction.gotoLocalPage(section.GetStartPageIndex() + 1,destination, writer));

stamper.addAnnotation(annotation,i);

回答1:

I've realised it's the annotation which has the border, to remove use

annotation.setBorder(new PdfBorderArray(0f, 0f, 0f));


回答2:

Or you can use:

annotation.BorderStyle = new PdfBorderDictionary(0f, 0);


标签: itext