Stroke

Stroke

Forum member · Apr 24, 2012
Is it possible to add a stroke to a TextArea, both with Color and Width?

Re: Stroke

Support · Apr 24, 2012
Hello, You can set width to the TextArea using Width property. Also you can set single color to the TextArea text using TextColor property. It is not possible to set different colors for each word of the text which you are adding through TextArea. You can use FormattedTextArea using which you can set different colors for substrings within the text. You can use font tag and color attribute to do this. Please refer documentation on FormattedTextArea at: http://www.DynamicPDF.com/Support/NET_Help_Library_11_11/ceTe.DynamicPDF~ceTe.DynamicPDF.PageElements.FormattedTextArea.html . Also refer the supported HTML tags at: http://www.DynamicPDF.com/Support/NET_Help_Library_11_11/Formatted%20Text%20Area%20Formatting.html . Thanks, ceTe Software Support Team.

Re: Stroke

Forum member · May 3, 2012
I was not thinking of the width of the textarea but the strokewidth and color of the characters. Like having some text in normal black with a yellow stroke around the characters.

Re: Stroke

Support · May 4, 2012
Hello, You can achieve your requirements by using custom page elements. Custom page plements can be used to output PDF code to a page or can utilize other already existing Page Element objects. You will need to inherit the Label or the TextArea class and create a CustomPageElement that overrides the Draw method. Following is the sample code snippet: //Class that inherits TextArea class. class CustomElement : ceTe.DynamicPDF.PageElements.TextArea { public CustomElement(string text, float x, float y, float width, float height):base(text,x,y,width,height) { } public override void Draw(ceTe.DynamicPDF.IO.PageWriter writer) { writer.SetTextRenderingMode(TextRenderingMode.FillAndStroke); writer.SetStrokeColor(RgbColor.Yellow); writer.SetFillColor(RgbColor.Black); base.DrawRotated(writer); writer.SetTextRenderingMode(TextRenderingMode.Fill); } } //Class that implementing CustomElement class class Program { static void Main(string[] args) { Document document = new Document(); Page page = new Page(); String text="Hello World"; text=text+text; text=text+text; text=text+text; CustomElement element = new CustomElement(text, 0, 0, page.Dimensions.Body.Width, page.Dimensions.Body.Height); element.FontSize = 40; page.Elements.Add(element); document.Pages.Add(page); document.Draw(@"C:\Mydocument.pdf"); } } Thanks, ceTe Software Support Team.

Re: Stroke

Forum member · May 29, 2012
Is it possible to also specify the stroke width? It seems locked to 1pt?

Re: Stroke

Support · May 29, 2012
Hello, Use SetLineWidth method to set the stoke width. See the code below. public override void Draw(ceTe.DynamicPDF.IO.PageWriter writer) { writer.SetTextRenderingMode(TextRenderingMode.FillAndStroke); writer.SetStrokeColor(RgbColor.Yellow); writer.SetLineWidth(2); writer.SetFillColor(RgbColor.Black); base.DrawRotated(writer); writer.SetTextRenderingMode(TextRenderingMode.Fill); } Thanks, ceTe Software Support Team.

Re: Stroke

Forum member · May 29, 2012
Yes, sorry, found writer.SetLineWidth ... However... the next question... Is it possible to specify that the stroke should be aligned outside, centre or inside?

Re: Stroke

Support · May 30, 2012
Hello, It is not possible to specify the alignment for stroke. Thanks, ceTe Software Support Team.