Set TextRenderMode in Label

Set TextRenderMode in Label

Forum member · Mar 15, 2007
I am trying to add a watermark to a multipage PDF using a Label. I would like to set the TextRenderMode to Stroke for this, but am having trouble figuring this out. Any help would be appreciated. Thanks

Re: Set TextRenderMode in Label

Support · Mar 15, 2007
Hello, Yes, you can have the text appear as outlined font when used to watermark a multi page PDF without any problem by changing the TextRenderingMode. You will need to inherit the Label or the TextArea class and create a CustomPageElement that overrides the DrawRotated method. Following is the sample code snippet: // Class that inherits the Label class public class OutlineLabel extends Label { protected void drawRotated(PageWriter writer) { writer.setTextRenderingMode(com.cete.dynamicpdf.TextRenderingMode.STROKE); writer.setColor(super.getTextColor(), Apply.STROKE); super.drawRotated(writer); writer.setTextRenderingMode(com.cete.dynamicpdf.TextRenderingMode.FILL); } public OutlinePageElement(String txt, float x, float y, float width, float height) { super(txt,x,y,width,height); } } //Test class implementing the OutlineLabel class public class FontTest { public static void main(String args[]) { Document objDocument = new Document(); Page objPage = new Page(PageSize.LETTER, PageOrientation.PORTRAIT, 54.0f); String strText = "Hello World...\nFrom DynamicPDF™ Generator "; OutlineLabel objLabel = new OutlineLabel(strText, 0, 0, 504, 100); objPage.getElements().add(objLabel); objDocument.getPages().add(objPage); objDocument.draw("FontTest.pdf"); } } Thanks, ceTe Software Support Team