Here is a sample java code showing how to add a multi-line text stamp to a PDF document using jPDFProcess public API. This will automatically add a rounded corner around the text.
In this case, we’re creating a stamp that reads “Approved ” on the first line and has the current date on the second line.
You can customize the text, color and date format.
PDFDocument doc = new PDFDocument("C:/test/alphabets.pdf", null); // create a new multiline text stamp with static text and the current time String stampText = "Approved" + "\n" + DateFormat.getDateTimeInstance().format(new Date() + \n "By John Smith"); RubberStamp stamp = doc.getAnnotationFactory().createRubberStamp(stampText, Color.green); // by default the stamp is placed in the upper left corner - add some margins stamp.setRectangle(new Rectangle2D.Double(100, 100, stamp.getRectangle().getWidth(), stamp.getRectangle().getHeight())); // add the stamp to the page doc.getPage(0).addAnnotation(stamp); // save the document doc.saveDocument("c:/test/output.pdf"); |