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

    A paragraph fragment - a segment of text with the same formatting.

    Namespace: DevExpress.Docs.Pdf

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

    NuGet Package: DevExpress.Docs.Pdf

    Declaration

    public class ParagraphFragment :
        TextFragment

    Example

    How to: Add Multiline Text to a PDF Page

    The following code snippet creates a paragraph and adds it to a PDF page:

    PDF page with center-aligned multiline paragraph describing the PDF Document API in Courier New font

    using DevExpress.Docs.Pdf;
    using DevExpress.Drawing;
    using DevExpress.Drawing.Printing;
    using System.Drawing;
    using System.IO;
    
    using (PdfDocument pdfDocument = new PdfDocument()) {
        var page = pdfDocument.Pages.Add(DXPaperKind.A4);
        // Create a paragraph fragment.
        var multiLine = new ParagraphFragment(){
            Text = "The PDF Document API is a non-visual .NET library that allows you to " +
                   "generate, convert, merge, split, edit, password-protect, and digitally " +
                   "sign PDF files.",
            Location = new PointF(10, 740),
            Font = new DXFont("Courier New", 11, DXFontStyle.Regular),
            Width = 500,
            Height = 500,
            StringFormat = new DXStringFormat() {
                Alignment = DXStringAlignment.Center,
                LineAlignment  = DXStringAlignment.Near,    
            },
        };
    
        // Add the paragraph to the PDF page.
        page.AddFragment(multiLine);
    
        pdfDocument.Save(new FileStream("Result.pdf", FileMode.Create, FileAccess.Write));
    }
    

    Implements

    Inheritance

    See Also