Skip to main content
All docs
V26.1
  • TextFragment Class

    A text fragment on a PDF page.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    Declaration

    public class TextFragment :
        VisualFragment

    Example

    How to: Add Formatted Text to a PDF Document

    The following code snippet adds a single line of text to a PDF document page:

    PDF page displaying the formatted text 'The PDF Document API' in Courier New font

    using DevExpress.Docs.Pdf;
    using DevExpress.Drawing.Printing;
    using System.Drawing;
    using DevExpress.Drawing;
    using System.IO;
    
    using (PdfDocument pdfDocument = new PdfDocument()) {
        var page = pdfDocument.Pages.Add(DXPaperKind.A4);
        // Create a text fragment with formatting.
        var text = new TextFragment()
        {
            Text = "The PDF Document API",
            Location = new PointF(10, 740),
            Font = new DXFont("Courier New", 11, DXFontStyle.Regular),
        };
        page.AddFragment(text);
    
        pdfDocument.Save(new FileStream("Result.pdf", FileMode.Create, FileAccess.Write));
    }
    

    Implements

    See Also