Find a circle of PDF in the Mac Watermark tool, are not very useful. Java Write a bar
The following code relies on the itext5.3.3 package,
Download from My network disk
Java Operations PDF relies on itext5.3.3
Read the original PDF
Pdfreader reader = new Pdfreader ("/test/" + "1.pdf");
Build a later PDF
Pdfstamper stamp = new Pdfstamper (reader, New FileOutputStream ("/test/" + "createsamplepdf2.pdf"));
int max = Reader.getnumberofpages ();
max = 2;
Text watermark
for (int i = 1; I <= max; i++) {
Pdfcontentbyte over = stamp.getovercontent (i);
Over.begintext ();
Basefont bf = Basefont.createfont (Basefont.helvetica, Basefont.winansi, basefont.embedded);
Over.setfontandsize (BF, 16);
Over.settextmatrix (10, 10);
Over.setcolorfill (Basecolor.gray);
Over.showtextaligned (element.align_left, "Java blog java-er.com", 150,670, 0);
0 0 0 indicates that the last 0 of the left leg is the angle, 0 indicates that the horizontal 45 is oblique
Over.endtext ();
}
Reader.close ();
Stamp.close ();
}