Fill with dots?

Fill with dots?

Forum member · Apr 3, 2006
Hi! Is there any function to add dots to a text placed in a Cell, so it automatically fills up to the columns width? Like this: Some text............... Yes Another text............ No Text.................... No //Magnus

Re: Fill with dots?

Forum member · Apr 3, 2006
Sorry, it was courier font in the editor, but not in the viewer, it should be like this: Some text........... Yes Another text....... No Text.................... No //Magnus

Re: Fill with dots?

Support · Apr 3, 2006
Hello Magnus, There is nothing built into Cell or Table objects to handle this but you could likely use the following Custom Page Element to create your label. Then you could pass that DottedLabel into the Table as desired. Here is the code for the Custom Page Element, DottedLabel Class: public class DottedLabel : ceTe.DynamicPDF.PageElement { private string text1; private string text2; private float x; private float y; private Single fontSize; private Font font; private float length; public DottedLabel( string text1, string text2, float x, float y, float fontSize, Font font, float length ) { this.text1 = text1; this.text2 = text2; this.x = x; this.y = y; this.fontSize = fontSize; this.font = font; this.length = length; } public override void Draw( PageWriter writer ) { float dotWidth = font.GetTextWidth( ".", fontSize ); float txt1Width = font.GetTextWidth( text1, fontSize ); float txt2Width = font.GetTextWidth( text2, fontSize ); float emptySpace; float dotsNeeded; string fullText; emptySpace = length - ( txt1Width + txt2Width ); dotsNeeded = emptySpace / dotWidth; fullText = text1; for( int i = 0; i < dotsNeeded - 1; i++) { fullText = fullText + "."; } Label objLabel1 = new Label( fullText, x, y, font.GetTextWidth(fullText, fontSize) + 0.1f, fontSize, font, fontSize); objLabel1.Draw( writer ); Label objLabel2 = new Label( text2, x + (length - txt2Width), y, font.GetTextWidth(text2, fontSize) + 0.1f, fontSize, font, fontSize, TextAlign.Right); objLabel2.Draw( writer ); } } Then the code to use something like this would be as follows: Document document = new Document(); Page page = new Page(); page.Elements.Add( new DottedLabel( "This is the label", "Reference", 30, 300, 18, ceTe.DynamicPDF.Font.TimesRoman, 400) ); page.Elements.Add( new DottedLabel( "This is another one", "Second Ref", 30, 320, 18, ceTe.DynamicPDF.Font.TimesRoman, 400) ); page.Elements.Add( new DottedLabel( "Four", "Ref", 30, 340, 18, ceTe.DynamicPDF.Font.TimesRoman, 400) ); page.Elements.Add( new DottedLabel( "Over Left", "Ref", 5, 360, 18, ceTe.DynamicPDF.Font.TimesRoman, 400) ); page.Elements.Add( new DottedLabel( "Over Right", "Right Ref", 70, 380, 18, ceTe.DynamicPDF.Font.TimesRoman, 400) ); page.Elements.Add( new DottedLabel( "Bigger Font", "Second Ref", 30, 400, 40, ceTe.DynamicPDF.Font.TimesRoman, 400) ); page.Elements.Add( new DottedLabel( "Smaller Font", "Small Ref", 30, 445, 7, ceTe.DynamicPDF.Font.TimesRoman, 400) ); page.Elements.Add( new DottedLabel( "Longer", "Far Ref", 30, 455, 18, ceTe.DynamicPDF.Font.TimesRoman, 550) ); page.Elements.Add( new DottedLabel( "Short", "Short Ref", 30, 475, 18, ceTe.DynamicPDF.Font.TimesRoman, 200) ); page.Elements.Add( new DottedLabel( "CourierFont", "Font Ref", 30, 280, 18, ceTe.DynamicPDF.Font.CourierBold, 400) ); document.Pages.Add( page ); document.Draw( PdfFilePath ); In your case you would just create the appropriate DottedLabels how you wanted and then add them to a cell in a table. Thanks, ceTe Software Support Team

Re: Fill with dots?

Forum member · Apr 4, 2006
Thanks for the rapid response! //Magnus