Skip to main content

HTML Area

Version: 9.0

HTML Area

The HtmlArea Page Element is designed to render HTML content within a specified area of the PDF page. It supports tags and properties based on HTML 4.0.1 and the CSS 2.1 specification, including some limitations (highlighted below the example). HTML Area requires Visual C++  Redistributables. Refer to the Deployment topic for more details.

The following example demonstrates the process for adding content from an HTML file into a specified region of a PDF document’s page:

Document document = new Document();
Uri uri = new Uri(@"c:\\temp\\TestPage");
HtmlArea htmlArea = new HtmlArea(uri, 0, 0,500,650);
Page page = new Page();
page.Elements.Add(htmlArea);
document.Pages.Add(page);
document.Draw("SampleHtml.pdf");
Dim MyDocument As Document= New Document()
Dim MyUri As Uri = New Uri("c:\\temp\\TestPage")
Dim MyHtmlArea As HtmlArea = New HtmlArea(MyUri, 0, 0, 500, 650)
Dim MyPage As Page = New Page()
page.Elements.Add(MyHtmlArea)
MyDocument.Pages.Add(MyPage)
MyDocument.Draw("SampleHtml.pdf")

The following HTML tags along with their commonly used attributes are supported:

  • a
  • address
  • blockquote
  • center
  • div
  • img
  • br
  • hr
  • h1
  • h2
  • h3
  • h4
  • h5
  • h6
  • p
  • pre
  • dd
  • dl
  • dt
  • li
  • ol
  • ul
  • table
  • b
  • i
  • q
  • u
  • em
  • tt
  • big
  • del
  • dfn
  • ins
  • kbd
  • sub
  • sup
  • var
  • abbr
  • cite
  • code
  • font
  • samp
  • span
  • small
  • s
  • strike
  • strong
  • input
  • textarea
  • label
  • button
  • fieldset
  • legend
  • select
  • acronym

The following CSS properties are supported:

  • background
  • color
  • text-decoration
  • letter-spacing
  • text-align
  • text-indent
  • text-transform
  • word – spacing
  • font
  • border
  • margin
  • padding
  • height
  • min-height
  • max-height
  • width
  • min-width
  • max-width
  • line-height
  • position
  • clip
  • top
  • right
  • bottom
  • left
  • z-index
  • list-style
  • border-collapse
  • border-spacing
  • caption-side
  • empty-cells
  • table-layout
  • clear
  • display
  • float
  • visibility
  • page-break-after
  • page-break-before

Noted Limitations:

  • The HtmlArea does not support Javascript.
  • Form field elements are not retained as interactive elements, but are flattened.
  • Content such as Flash, Java, and ActiveX coming from the Object tag are ignored and a rectangle is drawn in place of the Object tag.