Hallo,
I would like to put freetext-Annotations with background-color (opaque) in PDF.
Just now I can do this only with 2 annotations:
public void addFilledFreeTextAnnotation(String pdfFileName)
{
// Load the PDF file
Document document = new Document(pdfFileName);
Page page = document.getPages().get_Item(1);
SquareAnnotation squareAnnotation = new SquareAnnotation(page, new Rectangle(67, 317, 261, 459));
squareAnnotation.setColor(Color.getYellow());
squareAnnotation.setInteriorColor(Color.getLightYellow());
squareAnnotation.setOpacity(0.25);
DefaultAppearance defaultAppearance = new DefaultAppearance();
defaultAppearance.setFontName("Helvetica");
defaultAppearance.setFontSize(12);
defaultAppearance.setTextColor(java.awt.Color.BLUE);
Rectangle rect = new Rectangle(67, 317, 261, 459);
FreeTextAnnotation freeTextAnnotation = new FreeTextAnnotation(page, rect, defaultAppearance);
freeTextAnnotation.setRichText("<?xml version=\"1.0\"?>\n" +
"<body xmlns=\"http://www.w3.org/1999/xtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:contentType=\"text/html\" xfa:APIVersion=\"Acrobat:8.0.0\" xfa:spec=\"2.4\">\n" +
"<div style=\"background-color:yellow\">\n" +
" <p style=\"text-align:left\">\n" +
" <b>\n" +
" <i>\n" +
" Here is some bold italic text\n" +
" </i>\n" +
" </b>\n" +
" </p>\n" +
" <p style= \"font-size:16pt\">\n" +
" This text uses default text state parameters but changes the font size to 16.\n" +
" </p>\n" +
"</div>\n" +
"</body>");
page.getAnnotations().add(freeTextAnnotation);
page.getAnnotations().add(squareAnnotation);
document.save(pdfFileName + "_anno_freetext2f.pdf");
}
Is there no easier way, to add backhround-color to the freetext-annotation?
Regards, Gerd