Skip to main content

HtmlArea

Version: 10.0

cete.dynamicpdf.pageelements.html.htmlarea

HtmlArea​

Represents a HTML Area page element.

public class HtmlArea : RotatingPageElement, IArea, ICoordinate, ISerializable
Public Class HtmlArea
Inherits RotatingPageElement
Implements IArea, ICoordinate, ISerializable

Inheritance: Object → PageElement → TaggablePageElement → RotatingPageElement → HtmlArea

Implements: IArea, ICoordinate, ISerializable

Licensing​

This class is a DynamicPDF Generator Professional Edition feature. One of the following licenses is required for non-evaluation usage:

  • DynamicPDF Generator for .NET Professional Edition
  • DynamicPDF Generator for .NET Enterprise Edition
  • DynamicPDF Merger for .NET Professional Edition
  • DynamicPDF Merger for .NET Enterprise Edition
  • DynamicPDF ReportWriter for .NET Professional Edition
  • DynamicPDF ReportWriter for .NET Enterprise Edition
  • DynamicPDF Core Suite for .NET Professional Edition
  • DynamicPDF Core Suite for .NET Enterprise Edition

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.

public HtmlArea(Stream stream, float x, float y, float width, float height)
Public Sub New (stream As Stream, x As Single, y As Single, width As Single, height As Single)

Parameters​

Stream object containing the HTML data.

X coordinate of the HTML Area.

Y coordinate of the HTML Area.

Width of the HTML Area.

Height of the HTML Area.

HtmlArea(Stream, Single, Single, Uri, Single, Single)​

Initializes a new instance of the HtmlArea class.

public HtmlArea(Stream stream, float x, float y, Uri baseHref, float width, float height)
Public Sub New (stream As Stream, x As Single, y As Single, baseHref As Uri, width As Single, height As Single)

Parameters​

Stream object containing the HTML data.

X coordinate of the HTML Area.

Y coordinate of the HTML Area.

  • baseHref: Uri

Basehref of the HTML Area.

Width of the HTML Area.

Height of the HTML Area.

HtmlArea(String, Single, Single, Single, Single)​

Initializes a new instance of the HtmlArea class.

public HtmlArea(string text, float x, float y, float width, float height)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single)

Parameters​

Text to display in the HTML Area.

X coordinate of the HTML Area.

Y coordinate of the HTML Area.

Width of the HTML Area.

Height of the HTML Area.

HtmlArea(String, Single, Single, Uri, Single, Single)​

Initializes a new instance of the HtmlArea class.

public HtmlArea(string text, float x, float y, Uri baseHref, float width, float height)
Public Sub New (text As String, x As Single, y As Single, baseHref As Uri, width As Single, height As Single)

Parameters​

Text to display in the HTML Area.

X coordinate of the HTML Area.

Y coordinate of the HTML Area.

  • baseHref: Uri

Basehref of the HTML Area.

Width of the HTML Area.

Height of the HTML Area.

HtmlArea(Uri, Single, Single, Single, Single)​

Initializes a new instance of the HtmlArea class.

public HtmlArea(Uri uri, float x, float y, float width, float height)
Public Sub New (uri As Uri, x As Single, y As Single, width As Single, height As Single)

Parameters​

Physical file path of the HTML Area.

X coordinate of the HTML Area.

Y coordinate of the HTML Area.

Width of the HTML Area.

Height of the HTML Area.

HtmlArea(Uri, Single, Single, Uri, Single, Single)​

Initializes a new instance of the HtmlArea class.

public HtmlArea(Uri uri, float x, float y, Uri baseHref, float width, float height)
Public Sub New (uri As Uri, x As Single, y As Single, baseHref As Uri, width As Single, height As Single)

Parameters​

Physical file path of the HTML Area.

X coordinate of the HTML Area.

Y coordinate of the HTML Area.

  • baseHref: Uri

Basehref of the HTML Area.

Width of the HTML Area.

Height of the HTML Area.

Properties​

Angle​

Gets or sets the heights of the angle element. (Inherited from RotatingPageElement)

public float Angle { get; set; }
Public Property Angle As Single

Property Value​

Single

Height​

Gets or sets the height of the HTML area.

public float Height { get; set; }
Public Property Height As Single

Property Value​

Single

ID​

Gets or sets the ID of the page element. (Inherited from PageElement)

public string ID { get; set; }
Public Property ID As String

Property Value​

String

Tag​

Gets or sets the tag of the taggable element. (Inherited from TaggablePageElement)

public Tag Tag { get; set; }
Public Property Tag As Tag

Property Value​

Tag

Licensing​

This property is a DynamicPDF Generator Enterprise Edition feature. One of the following licenses is required for non-evaluation usage:

  • DynamicPDF Generator for .NET Enterprise Edition
  • DynamicPDF Merger for .NET Enterprise Edition
  • DynamicPDF ReportWriter for .NET Enterprise Edition
  • DynamicPDF Core Suite for .NET Enterprise Edition

TagOrder​

Gets or sets the tag order of the taggable element. (Inherited from TaggablePageElement)

public int TagOrder { get; set; }
Public Property TagOrder As Int32

Property Value​

Int32

Width​

Gets or sets the width of the HTML area.

public float Width { get; set; }
Public Property Width As Single

Property Value​

Single

X​

Gets or sets the X coordinate of the page element. (Inherited from RotatingPageElement)

public float X { get; set; }
Public Property X As Single

Property Value​

Single

Y​

Gets or sets the Y coordinate of the page element. (Inherited from RotatingPageElement)

public float Y { get; set; }
Public Property Y As Single

Property Value​

Single

Methods​

Draw(PageWriter)​

Draws the page element to the given PageWriter object. (Inherited from RotatingPageElement)

public void Draw(PageWriter writer)
Sub Draw(writer As PageWriter)

Parameters​

PageWriter object to receive the page element's output.

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

GetOverflowHtmlArea()​

Returns a new HtmlArea object containing the overflow html area.

public HtmlArea GetOverflowHtmlArea()
Function GetOverflowHtmlArea() As HtmlArea

Returns​

A HtmlArea if there is overflow html area; otherwise, null .

Examples​

The following example shows you how to use the GetOverflowHtmlArea object.

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);

do
{
// Create a new 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);

// Set the html area object equal to the rest of the html area that did not fit
// if all the html area did fit, GetOverflowHtmlArea will return null
htmlArea = htmlArea.GetOverflowHtmlArea(0, 0, 600);

} while (htmlArea != null);

//Save the PDF
document.Draw(outputPath);
}
}

Remarks​

This method returns a new HTML area object that contains the remaining html area that did not fit.

GetOverflowHtmlArea(Single, Single, Single)​

Returns a new HtmlArea object containing the overflow html area.

public HtmlArea GetOverflowHtmlArea(float x, float y, float height)
Function GetOverflowHtmlArea(x As Single, y As Single, height As Single) As HtmlArea

Parameters​

X coordinate of the new object.

Y coordinate of the new object.

Height of the new object.

Returns​

A HtmlArea if there is overflow html area; otherwise, null .

Examples​

The following example shows you how to use the GetOverflowHtmlArea object.

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);

do
{
// Create a new 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);

// Set the html area object equal to the rest of the html area that did not fit
// if all the html area did fit, GetOverflowHtmlArea will return null
htmlArea = htmlArea.GetOverflowHtmlArea(0, 0, 600);

} while (htmlArea != null);

//Save the PDF
document.Draw(outputPath);
}
}

Remarks​

This method returns a new HTML area object that contains the remaining html area that did not fit.

GetRequiredHeight()​

Returns the height required to fit html file.

public float GetRequiredHeight()
Function GetRequiredHeight() As Single

Returns​

The required height to display html file.

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

See Also​

ceTe.DynamicPDF.PageElements.Html