menu

Document Processing

PdfTextLayoutResult Class - C# PDF Library API Reference | Syncfusion

    Show / Hide Table of Contents

    PdfTextLayoutResult Class

    Represents the text lay outing result settings.

    Inheritance
    System.Object
    PdfLayoutResult
    PdfTextLayoutResult
    Inherited Members
    PdfLayoutResult.Bounds
    PdfLayoutResult.Page
    Namespace: Syncfusion.Pdf.Graphics
    Assembly: Syncfusion.Pdf.Base.dll
    Syntax
    public class PdfTextLayoutResult : PdfLayoutResult
    Examples
    // Create a PDF document
    PdfDocument doc = new PdfDocument();
    //Creates a new page and adds it as the last page of the document
    PdfPage page = doc.Pages.Add();
     private bool m_paginateStart = true;
    PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
    PdfPen pen = new PdfPen(Color.Black, 1f);
    //Creates a new  pdf font
    PdfStandardFont pdfFont = new PdfStandardFont(PdfFontFamily.Helvetica, 11.5f);
    Font font = new Font("Calibri", 14f, FontStyle.Bold);
    PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(font, true);
    string path = @"Essential studio.txt";
    StreamReader reader = new StreamReader(path, Encoding.ASCII);
    string text = reader.ReadToEnd();
    reader.Close();
    RectangleF column = new RectangleF(0, 20, page.Graphics.ClientSize.Width / 2f - 10f, page.Graphics.ClientSize.Height);
    //Create text element
    PdfTextElement element = new PdfTextElement(text, pdfFont);
    element.Brush = new PdfSolidBrush(Color.Black);
    PdfLayoutFormat layoutFormat = new PdfLayoutFormat();
    layoutFormat.Break = PdfLayoutBreakType.FitPage;
    layoutFormat.Layout = PdfLayoutType.Paginate;
    //Raise the event when the text flows to next page.
    element.BeginPageLayout += new BeginPageLayoutEventHandler(BeginPageLayout2);
    //Get the remaining text that flows beyond the boundary.
    PdfTextLayoutResult result = element.Draw(page, column, layoutFormat);
    //Saves the document.
    doc.Save("Sample.pdf");
    //End Text Page Layout Event
    private void EndPageLayout2(object sender, EndPageLayoutEventArgs e)
    {
        EndTextPageLayoutEventArgs args = (EndTextPageLayoutEventArgs)e;
        PdfTextLayoutResult tlr = args.Result;
        RectangleF bounds = tlr.Bounds;
     }
    'Create a PDF document
    Dim doc As New PdfDocument()
    'Creates a new page and adds it as the last page of the document
    Dim page As PdfPage = doc.Pages.Add()
    Dim m_paginateStart As Bool= True
    Dim brush As New PdfSolidBrush(Color.Black)
    Dim pen As New PdfPen(Color.Black, 1f)
    'Creates a new  pdf font
    Dim pdfFont As New PdfStandardFont(PdfFontFamily.Helvetica, 11.5f)
    Dim font As New Font("Calibri", 14f, FontStyle.Bold)
    Dim trueTypeFont As New PdfTrueTypeFont(font, True)
    Dim path As string = "Essential studio.txt"
    Dim reader As New StreamReader(path, Encoding.ASCII)
    Dim text As string = reader.ReadToEnd()
    reader.Close()
    Dim column As New RectangleF(0, 20, page.Graphics.ClientSize.Width / 2f - 10f, page.Graphics.ClientSize.Height)
    'Create text element
    Dim element As New PdfTextElement(text, pdfFont)
    element.Brush = New PdfSolidBrush(Color.Black)
    Dim layoutFormat As New PdfLayoutFormat()
    layoutFormat.Break = PdfLayoutBreakType.FitPage
    layoutFormat.Layout = PdfLayoutType.Paginate
    'Raise the event when the text flows to next page.
    element.BeginPageLayout += New BeginPageLayoutEventHandler(BeginPageLayout2)
    'Get the remaining text that flows beyond the boundary.
    Dim result As PdfTextLayoutResult = element.Draw(page, column, layoutFormat)
    'Saves the document.
    doc.Save("Sample.pdf")
    'End Text Page Layout Event
    Private Sub EndPageLayout2(ByVal sender As object, ByVal e As EndPageLayoutEventArgs)
    Dim args As EndTextPageLayoutEventArgs = CType(e, EndTextPageLayoutEventArgs)
    Dim tlr As PdfTextLayoutResult = args.Result
    Dim bounds As RectangleF = tlr.Bounds
    End Sub

    Properties

    LastLineBounds

    Gets a value that indicates the bounds of the last line that was printed on the page.

    Declaration
    public RectangleF LastLineBounds { get; }
    Property Value
    Type
    System.Drawing.RectangleF
    Examples
    // Create a PDF document
    PdfDocument doc = new PdfDocument();
    //Creates a new page and adds it as the last page of the document
    PdfPage page = doc.Pages.Add();
     private bool m_paginateStart = true;
    PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
    PdfPen pen = new PdfPen(Color.Black, 1f);
    //Creates a new  pdf font
    PdfStandardFont pdfFont = new PdfStandardFont(PdfFontFamily.Helvetica, 11.5f);
    Font font = new Font("Calibri", 14f, FontStyle.Bold);
    PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(font, true);
    string path = @"Essential studio.txt";
    StreamReader reader = new StreamReader(path, Encoding.ASCII);
    string text = reader.ReadToEnd();
    reader.Close();
    RectangleF column = new RectangleF(0, 20, page.Graphics.ClientSize.Width / 2f - 10f, page.Graphics.ClientSize.Height);
    //Create text element
    PdfTextElement element = new PdfTextElement(text, pdfFont);
    element.Brush = new PdfSolidBrush(Color.Black);
    PdfLayoutFormat layoutFormat = new PdfLayoutFormat();
    layoutFormat.Break = PdfLayoutBreakType.FitPage;
    layoutFormat.Layout = PdfLayoutType.Paginate;
    //Raise the event when the text flows to next page.
    element.BeginPageLayout += new BeginPageLayoutEventHandler(BeginPageLayout2);
    //Get the remaining text that flows beyond the boundary.
    PdfTextLayoutResult result = element.Draw(page, column, layoutFormat);
    //Saves the document.
    doc.Save("Sample.pdf");
    //End Text Page Layout Event
    private void EndPageLayout2(object sender, EndPageLayoutEventArgs e)
    {
        EndTextPageLayoutEventArgs args = (EndTextPageLayoutEventArgs)e;
        PdfTextLayoutResult tlr = args.Result;
        RectangleF bounds = tlr.LastLineBounds;
     }
    'Create a PDF document
    Dim doc As New PdfDocument()
    'Creates a new page and adds it as the last page of the document
    Dim page As PdfPage = doc.Pages.Add()
    Dim m_paginateStart As Bool= True
    Dim brush As New PdfSolidBrush(Color.Black)
    Dim pen As New PdfPen(Color.Black, 1f)
    'Creates a new  pdf font
    Dim pdfFont As New PdfStandardFont(PdfFontFamily.Helvetica, 11.5f)
    Dim font As New Font("Calibri", 14f, FontStyle.Bold)
    Dim trueTypeFont As New PdfTrueTypeFont(font, True)
    Dim path As string = "Essential studio.txt"
    Dim reader As New StreamReader(path, Encoding.ASCII)
    Dim text As string = reader.ReadToEnd()
    reader.Close()
    Dim column As New RectangleF(0, 20, page.Graphics.ClientSize.Width / 2f - 10f, page.Graphics.ClientSize.Height)
    'Create text element
    Dim element As New PdfTextElement(text, pdfFont)
    element.Brush = New PdfSolidBrush(Color.Black)
    Dim layoutFormat As New PdfLayoutFormat()
    layoutFormat.Break = PdfLayoutBreakType.FitPage
    layoutFormat.Layout = PdfLayoutType.Paginate
    'Raise the event when the text flows to next page.
    element.BeginPageLayout += New BeginPageLayoutEventHandler(BeginPageLayout2)
    'Get the remaining text that flows beyond the boundary.
    Dim result As PdfTextLayoutResult = element.Draw(page, column, layoutFormat)
    'Saves the document.
    doc.Save("Sample.pdf")
    'End Text Page Layout Event
    Private Sub EndPageLayout2(ByVal sender As object, ByVal e As EndPageLayoutEventArgs)
    Dim args As EndTextPageLayoutEventArgs = CType(e, EndTextPageLayoutEventArgs)
    Dim tlr As PdfTextLayoutResult = args.Result
    Dim bounds As RectangleF = tlr.LastLineBounds
    End Sub

    Remainder

    Gets a value that contains the text that was not printed.

    Declaration
    public string Remainder { get; }
    Property Value
    Type
    System.String
    Examples
    // Create a PDF document
    PdfDocument doc = new PdfDocument();
    //Creates a new page and adds it as the last page of the document
    PdfPage page = doc.Pages.Add();
     private bool m_paginateStart = true;
    PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
    PdfPen pen = new PdfPen(Color.Black, 1f);
    //Creates a new  pdf font
    PdfStandardFont pdfFont = new PdfStandardFont(PdfFontFamily.Helvetica, 11.5f);
    Font font = new Font("Calibri", 14f, FontStyle.Bold);
    PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(font, true);
    string path = @"Essential studio.txt";
    StreamReader reader = new StreamReader(path, Encoding.ASCII);
    string text = reader.ReadToEnd();
    reader.Close();
    RectangleF column = new RectangleF(0, 20, page.Graphics.ClientSize.Width / 2f - 10f, page.Graphics.ClientSize.Height);
    //Create text element
    PdfTextElement element = new PdfTextElement(text, pdfFont);
    element.Brush = new PdfSolidBrush(Color.Black);
    PdfLayoutFormat layoutFormat = new PdfLayoutFormat();
    layoutFormat.Break = PdfLayoutBreakType.FitPage;
    layoutFormat.Layout = PdfLayoutType.Paginate;
    //Raise the event when the text flows to next page.
    element.BeginPageLayout += new BeginPageLayoutEventHandler(BeginPageLayout2);
    //Get the remaining text that flows beyond the boundary.
    PdfTextLayoutResult result = element.Draw(page, column, layoutFormat);
    //Saves the document.
    doc.Save("Sample.pdf");
    //End Text Page Layout Event
    private void EndPageLayout2(object sender, EndPageLayoutEventArgs e)
    {
        EndTextPageLayoutEventArgs args = (EndTextPageLayoutEventArgs)e;
        PdfTextLayoutResult tlr = args.Result;
        string remText = tlr.Remainder;
     }
    'Create a PDF document
    Dim doc As New PdfDocument()
    'Creates a new page and adds it as the last page of the document
    Dim page As PdfPage = doc.Pages.Add()
    Dim m_paginateStart As Bool= True
    Dim brush As New PdfSolidBrush(Color.Black)
    Dim pen As New PdfPen(Color.Black, 1f)
    'Creates a new  pdf font
    Dim pdfFont As New PdfStandardFont(PdfFontFamily.Helvetica, 11.5f)
    Dim font As New Font("Calibri", 14f, FontStyle.Bold)
    Dim trueTypeFont As New PdfTrueTypeFont(font, True)
    Dim path As string = "Essential studio.txt"
    Dim reader As New StreamReader(path, Encoding.ASCII)
    Dim text As string = reader.ReadToEnd()
    reader.Close()
    Dim column As New RectangleF(0, 20, page.Graphics.ClientSize.Width / 2f - 10f, page.Graphics.ClientSize.Height)
    'Create text element
    Dim element As New PdfTextElement(text, pdfFont)
    element.Brush = New PdfSolidBrush(Color.Black)
    Dim layoutFormat As New PdfLayoutFormat()
    layoutFormat.Break = PdfLayoutBreakType.FitPage
    layoutFormat.Layout = PdfLayoutType.Paginate
    'Raise the event when the text flows to next page.
    element.BeginPageLayout += New BeginPageLayoutEventHandler(BeginPageLayout2)
    'Get the remaining text that flows beyond the boundary.
    Dim result As PdfTextLayoutResult = element.Draw(page, column, layoutFormat)
    'Saves the document.
    doc.Save("Sample.pdf")
    'End Text Page Layout Event
    Private Sub EndPageLayout2(ByVal sender As object, ByVal e As EndPageLayoutEventArgs)
    Dim args As EndTextPageLayoutEventArgs = CType(e, EndTextPageLayoutEventArgs)
    Dim tlr As PdfTextLayoutResult = args.Result
    Dim remText As String = tlr.Remainder
    End Sub
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved