How to make this happen?
I used a TextStamp as watermark and added it to the document.
However, i can select it. Is there a way to somehow like flatten it to the document so that it will not be selectable?
How to make this happen?
Hi Chit,
Thanks for your inquriy. TextStamp class has a property (bool Draw) for the purpose. If this property is true stamp will be drawn with graphic operators instead of text. This prevents from selecting text (also stamp text can not be extracted from the document). Please check following code snippet, hopefully it will help you to accomplish the task.
Document doc = **new** Document();
Page page = doc.getPages().add();
TextStamp stamp = **new** TextStamp(**new** FormattedText("Aspose.Pdf for Java", java.awt.Color.*BLACK*, "Arial", EncodingType.*Identity_h*, **true**, 32));
stamp.setHorizontalAlignment(HorizontalAlignment.*Center*);
stamp.setVerticalAlignment(VerticalAlignment.*Center*);
//set this property to true in order to make stamp which is drawn with set of operators.
stamp.setDraw(**true**);
page.addStamp(stamp);
doc.save(“output.pdf”);
Best Regards,
Hi Chit,
Thanks for your email. In case of multi-line stamp you need to add text lines in FormattedText object as following, it will help you to accomplish the task.
FormattedText ft = new FormattedText((String) watermark.get(0), java.awt.Color.LIGHT_GRAY, 4, 5, false,FONT_SIZE, SPACING);
ft.addNewLineText((String) watermark.get(1));
ft.addNewLineText((String) watermark.get(2));
Please feel free to contact us for any further assistance.
Best Regards,
Hi Tilal
Hi Chit,