I'd like to add a watermark image to my docx and PDF files. I've added a paragraph (w:p/w:r/w:pict/v:shape/v:imagedata) to my w:hdr:
- Code: Select all
<w:p>
<w:r>
<w:pict>
<v:shape type="#_x0000_t75" style="position:absolute;margin-left:0;margin-top:0;width:113.35pt;height:67.61475716064757pt;z-index:-251657216;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin" o:hralign="left" o:allowincell="f" o:insetmode="custom" o:connectortype="straight">
<v:imagedata o:title="watermark" r:id="rId3" gain="19661f" blacklevel="22938f"/>
</v:shape>
</w:pict>
</w:r>
</w:p>
@SuppressWarnings("deprecation")
private P createWatermarkP(Watermark watermark, byte[] bytes, Part part) {
try {
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(docPackage, part, bytes);
// Width and height in pt
ImageInfo imageInfo = imagePart.getImageInfo();
if (imageInfo == null) ...