Aspose.Pdf.Examples.CSharp.AsposePDF.Text.SpecifyCharacterSpacing.UsingTextBuilderAndParagraph C# (CSharp) Method

UsingTextBuilderAndParagraph() public static method

public static UsingTextBuilderAndParagraph ( ) : void
return void
        public static void UsingTextBuilderAndParagraph()
        {
            // ExStart:UsingTextBuilderAndParagraph
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Create Document instance
            Document pdfDocument = new Document();
            // Add page to pages collection of Document
            Page page = pdfDocument.Pages.Add();
            // Create TextBuilder instance
            TextBuilder builder = new TextBuilder(pdfDocument.Pages[1]);
            // Instantiate TextParagraph instance
            TextParagraph paragraph = new TextParagraph();
            // Create TextState instance to specify font name and size
            TextState state = new TextState("Arial", 12);
            // Specify the character spacing
            state.CharacterSpacing = 1.5f;
            // Append text to TextParagraph object
            paragraph.AppendLine("This is paragraph with character spacing", state);
            // Specify the position for TextParagraph
            paragraph.Position = new Position(100, 550);
            // Append TextParagraph to TextBuilder instance
            builder.AppendParagraph(paragraph);

            dataDir = dataDir + "CharacterSpacingUsingTextBuilderAndParagraph_out.pdf";
            // Save resulting PDF document.
            pdfDocument.Save(dataDir);
            // ExEnd:UsingTextBuilderAndParagraph
            Console.WriteLine("\nCharacter spacing specified successfully using Text builder and paragraph.\nFile saved at " + dataDir);
        }
        public static void UsingTextStamp()