Table of Contents

Class PdfHTMLTextElement

Namespace
Syncfusion.Pdf.Graphics
Assembly
Syncfusion.Pdf.Portable.dll

Represents a HTML text area with the ability to span several pages.

public class PdfHTMLTextElement
Inheritance
PdfHTMLTextElement
Inherited Members

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement(htmlText, font, PdfBrushes.Black);
htmlTextElement.TextAlign = TextAlign.Left;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
htmlTextElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
'Simple HTML content
Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
'Create new PDF HTML text element.
Dim htmlTextElement As New PdfHTMLTextElement(htmlText, font, PdfBrushes.Black)
htmlTextElement.TextAlign = TextAlign.Left
'Format Layout.
Dim format As New PdfMetafileLayoutFormat()
format.Layout = PdfLayoutType.Paginate
format.Break = PdfLayoutBreakType.FitPage
'Draw htmlString to PDF page.
htmlTextElement.Draw(page, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Remarks

This API is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight. To know more about refer this link .

Constructors

PdfHTMLTextElement()

Initializes a new instance of the PdfHTMLTextElement class.

public PdfHTMLTextElement()

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
htmlTextElement.TextAlign = TextAlign.Left;
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
htmlTextElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 htmlTextElement.TextAlign = TextAlign.Left
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 htmlTextElement.Draw(page, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format)
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Remarks

This Constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.

PdfHTMLTextElement(string, PdfFont, PdfBrush)

Initializes a new instance of the PdfHTMLTextElement class with the specified HTML text, font and brush

public PdfHTMLTextElement(string htmlText, PdfFont font, PdfBrush brush)

Parameters

htmlText string

The HTML text to be rendered in PDF.

font PdfFont

The font.

brush PdfBrush

The brush.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement(htmlText, font, PdfBrushes.Black);
htmlTextElement.TextAlign = TextAlign.Left;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
htmlTextElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
'Simple HTML content
Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
'Create new PDF HTML text element.
Dim htmlTextElement As New PdfHTMLTextElement(htmlText, font, PdfBrushes.Black)
htmlTextElement.TextAlign = TextAlign.Left
'Format Layout.
Dim format As New PdfMetafileLayoutFormat()
format.Layout = PdfLayoutType.Paginate
format.Break = PdfLayoutBreakType.FitPage
'Draw htmlString to PDF page.
htmlTextElement.Draw(page, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format)
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Remarks

This Constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.

Properties

Brush

Gets or sets the brush for the text element.

public PdfBrush Brush { get; set; }

Property Value

PdfBrush

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
htmlTextElement.TextAlign = TextAlign.Left;
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Set PDF brush.
htmlTextElement.Brush = new PdfSolidBrush(Color.Red);
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
htmlTextElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 htmlTextElement.TextAlign = TextAlign.Left
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
 'Set PDF brush.
 htmlTextElement.Brush = New PdfSolidBrush(Color.Red)
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 htmlTextElement.Draw(page, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format)
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Remarks

This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.

Font

Gets or sets the base font for the text element.

public PdfFont Font { get; set; }

Property Value

PdfFont

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
htmlTextElement.TextAlign = TextAlign.Left;
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
htmlTextElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 htmlTextElement.TextAlign = TextAlign.Left
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 htmlTextElement.Draw(page, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format)
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Remarks

This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.

HTMLText

Gets or sets the HTML Text.

public string HTMLText { get; set; }

Property Value

string

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
htmlTextElement.TextAlign = TextAlign.Left;
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
htmlTextElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 htmlTextElement.TextAlign = TextAlign.Left
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 htmlTextElement.Draw(page, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format)
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Remarks

This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.

TextAlign

Gets or sets the text alignment.

public TextAlign TextAlign { get; set; }

Property Value

TextAlign

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
//Set text align.
htmlTextElement.TextAlign = TextAlign.Left;
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
htmlTextElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 'Set text align
 htmlTextElement.TextAlign = TextAlign.Left
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 htmlTextElement.Draw(page, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format)
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Remarks

This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.

Methods

Draw(PdfGraphics, PointF, float, float)

Draws the text on the graphics.

public void Draw(PdfGraphics graphics, PointF location, float width, float height)

Parameters

graphics PdfGraphics
location PointF

Start location on the page.

width float

Width of the text bounds.

height float

Height of the text bounds.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
//Set text align.
htmlTextElement.TextAlign = TextAlign.Left;
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
htmlTextElement.Draw(graphics, new PointF(0, 0), page.GetClientSize().Width, page.GetClientSize().Height);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 'Set text align
 htmlTextElement.TextAlign = TextAlign.Left
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 htmlTextElement.Draw(graphics, New PointF(0, 0), page.GetClientSize().Width, page.GetClientSize().Height)
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Remarks

This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.

Draw(PdfGraphics, RectangleF)

Draws the text on the graphics.

public void Draw(PdfGraphics graphics, RectangleF layoutRectangle)

Parameters

graphics PdfGraphics
layoutRectangle RectangleF

RectangleF structure that specifies the bounds of the text.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files ";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
//Set text align.
htmlTextElement.TextAlign = TextAlign.Left;
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
htmlTextElement.Draw(graphics, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET " + "library with the capability to produce Adobe PDF files "
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 'Set text align
 htmlTextElement.TextAlign = TextAlign.Left
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 htmlTextElement.Draw(graphics, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height))
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Remarks

This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.

Draw(PdfPage, PointF, float, PdfLayoutFormat)

Draws the text on the page.

public PdfLayoutResult Draw(PdfPage page, PointF location, float width, PdfLayoutFormat format)

Parameters

page PdfPage

Current page where the text should be drawn.

location PointF

Start location on the page.

width float

Width of the text bounds.

format PdfLayoutFormat

Layout format.

Returns

PdfLayoutResult

Layouting result.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET library with the capability to produce Adobe PDF files";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
PdfLayoutResult result = htmlTextElement.Draw(page, new PointF(0, 0), page.GetClientSize().Width, format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET library with the capability to produce Adobe PDF files"
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 Dim result As PdfLayoutResult = htmlTextElement.Draw(page, New PointF(0, 0), page.GetClientSize().Width, format)
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Draw(PdfPage, PointF, float, float, PdfLayoutFormat)

Draws the text on the page.

public PdfLayoutResult Draw(PdfPage page, PointF location, float width, float height, PdfLayoutFormat format)

Parameters

page PdfPage

Current page where the text should be drawn.

location PointF

Start location on the page.

width float

Width of the text bounds.

height float

Height of the text bounds.

format PdfLayoutFormat

Layouting format.

Returns

PdfLayoutResult

Layouting result.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET library with the capability to produce Adobe PDF files"
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
PdfLayoutResult result = htmlTextElement.Draw(page, new PointF(0, 0), page.GetClientSize().Width, page.GetClientSize().Height, format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET library with the capability to produce Adobe PDF files"
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 Dim result As PdfLayoutResult = htmlTextElement.Draw(page, New PointF(0, 0), page.GetClientSize().Width, page.GetClientSize().Height, format)
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Draw(PdfPage, RectangleF, PdfLayoutFormat)

Draws the text on the page.

public PdfLayoutResult Draw(PdfPage page, RectangleF layoutRectangle, PdfLayoutFormat format)

Parameters

page PdfPage

Current page where the text should be drawn.

layoutRectangle RectangleF

RectangleF structure that specifies the bounds of the text.

format PdfLayoutFormat

layout format.

Returns

PdfLayoutResult

Layout result.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Simple HTML content
string htmlText = "Essential PDF is a .NET library with the capability to produce Adobe PDF files";
//Create new PDF HTML text element.
PdfHTMLTextElement htmlTextElement = new PdfHTMLTextElement();
//Set html text.
htmlTextElement.HTMLText = htmlText;
//Set font.
htmlTextElement.Font = font;
//Format Layout.
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;
//Draw htmlString to PDF page.
PdfLayoutResult result = htmlTextElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
 'Create a new PDF document.
 Dim doc As New PdfDocument()
 'Add a page to the document.
 Dim page As PdfPage = doc.Pages.Add()
 'Create PDF graphics for the page.
 Dim graphics As PdfGraphics = page.Graphics
 'Set the font.
 Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 14)
 'Simple HTML content
 Dim htmlText As String = "Essential PDF is a .NET library with the capability to produce Adobe PDF files"
 'Create new PDF HTML text element.
 Dim htmlTextElement As New PdfHTMLTextElement()
 'Set html text.
 htmlTextElement.HTMLText = htmlText
 'Set font.
 htmlTextElement.Font = font
'Format Layout.
 Dim format As New PdfMetafileLayoutFormat()
 format.Layout = PdfLayoutType.Paginate
 format.Break = PdfLayoutBreakType.FitPage
 'Draw htmlString to PDF page.
 Dim result As PdfLayoutResult = htmlTextElement.Draw(page, New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height), format)
 'Save the document.
 doc.Save("Output.pdf")
 'Close the document.
 doc.Close(True)

Events

BeginPageLayout

Event. Raises before the element should be printed on the page.

public event BeginPageLayoutEventHandler BeginPageLayout

Event Type

BeginPageLayoutEventHandler

EndPageLayout

Event. Raises after the element was printed on the page.

public event EndPageLayoutEventHandler EndPageLayout

Event Type

EndPageLayoutEventHandler