HtmlArea
Represents a HTML Area page element.
public class HtmlArea : RotatingPageElement, IArea, ICoordinate, ISerializable
Public Class HtmlArea
Inherits RotatingPageElement
Implements IArea, ICoordinate, ISerializable
Inheritance: ObjectPageElementTaggablePageElementRotatingPageElementHtmlArea
Implements: IArea, ICoordinate, ISerializable
Licensing Info
This class is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
Examples
This example shows simple HTML being displayed on the page.Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports ceTe.DynamicPDF.PageElements.Html
Module MyModule
Sub Main()
' Create a PDF Document
Dim MyDocument As Document = New Document()
' Create a uri
Dim MyUri As Uri = New Uri("C:\Temp\TestPage.html")
' Create a html area
Dim MyHtmlArea As HtmlArea = New HtmlArea(MyUri, 0, 0, 500, 600)
' Create a page
Dim MyPage As Page = New Page()
' Add the html area to the page
MyPage.Elements.Add(MyHtmlArea)
' Add the page to the document
MyDocument.Pages.Add(MyPage)
' Save the PDF
MyDocument.Draw("MyOutput.pdf")
End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements.Html;
public class Example
{
public static void CreatePDF(string inputHTMLPath, string outputPath)
{
// Create a PDF Document
Document document = new Document();
// Create a Uri
Uri filePath = new Uri( inputHTMLPath );
// Create a html area
HtmlArea htmlArea = new HtmlArea(filePath, 0, 0, 500, 600);
//Create a page
Page page = new Page();
// Add the html area to the page;
page.Elements.Add(htmlArea);
// Add the page to the document
document.Pages.Add(page);
// Save the PDF
document.Draw(outputPath);
}
}
Remarks
With some of the .Net runtimes (example: .Net Core 2.0), HTML Area will give the error "No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.". To resolve this error refer the user manual page Encoding Considerations.
Constructors
HtmlArea(Stream, Single, Single, Single, Single) | Initializes a new instance of the HtmlArea class. |
HtmlArea(Stream, Single, Single, Uri, Single, Single) | Initializes a new instance of the HtmlArea class. |
HtmlArea(String, Single, Single, Single, Single) | Initializes a new instance of the HtmlArea class. |
HtmlArea(String, Single, Single, Uri, Single, Single) | Initializes a new instance of the HtmlArea class. |
HtmlArea(Uri, Single, Single, Single, Single) | Initializes a new instance of the HtmlArea class. |
HtmlArea(Uri, Single, Single, Uri, Single, Single) | Initializes a new instance of the HtmlArea class. |
Properties
Angle | Gets or sets the heights of the angle element. (Inherited from RotatingPageElement) |
Height | Gets or sets the height of the HTML area. |
ID | Gets or sets the ID of the page element. (Inherited from PageElement) |
IgnoreMargins | Gets or sets ignore margin property. Setting false will consider the margin while placing the page element based on the RelativeTo property. (Inherited from PageElement) |
RelativeTo | Gets and sets placement of the page element on the page. (Inherited from PageElement) |
Tag | Gets or sets the tag of the taggable element. (Inherited from TaggablePageElement) |
TagOrder | Gets or sets the tag order of the taggable element. (Inherited from TaggablePageElement) |
Width | Gets or sets the width of the HTML area. |
X | Gets or sets the X coordinate of the page element. (Inherited from RotatingPageElement) |
Y | Gets or sets the Y coordinate of the page element. (Inherited from RotatingPageElement) |
Methods
Draw(PageWriter) | Draws the page element to the given PageWriter object. (Inherited from RotatingPageElement) |
Equals(Object) | Determines whether the specified Object is equal to the current Object . (Inherited from Object) |
GetHashCode() | Serves as a hash function for a particular type. (Inherited from Object) |
GetOverflowHtmlArea() | Returns a new HtmlArea object containing the overflow html area. |
GetOverflowHtmlArea(Single, Single, Single) | Returns a new HtmlArea object containing the overflow html area. |
GetRequiredHeight() | Returns the height required to fit html file. |
GetType() | Gets the Type of the current instance. (Inherited from Object) |
ToString() | Returns a String that represents the current Object . (Inherited from Object) |
Events
HtmlArea.FontSelecting | Occurs when the Font is being selected to write the HtmlArea text. This can be used to change the font and related properties of the text. |