Skip to main content

HtmlLayout

Version: 10.0

HTML Layout

The HtmlLayout 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).

Sample Code​

This example shows simple Header Footer Text being displayed on the document.

//Create Html layout page info
PageInfo layoutPage = new PageInfo(PageSize.A4, PageOrientation.Portrait);

//Create Uri
Uri uri = new Uri(inputHTMLPath);

//Create Html Layout
HtmlLayout html = new HtmlLayout(uri, layoutPage);

//Create a header
html.Header.Center.Text = "%%PR%%%%SP%% of %%ST%%";
html.Header.Center.HasPageNumbers = true;
html.Header.Center.Width = 200;

//Create a footer
html.Footer.Center.Text = "%%PR%%%%SP(A)%% of %%ST(B)%%";
html.Footer.Center.HasPageNumbers = true;
html.Footer.Center.Width = 200;

//Create a PDF Document
Document document = html.Layout();

//Save the PDF
document.Draw(outputPath);
'Create Html layout page info
Dim layoutPage As PageInfo = New PageInfo(PageSize.A4, PageOrientation.Portrait)

'Create Uri
Dim uri As Uri = New Uri(inputHTMLPath)

'Create a Html Layout
Dim html As HtmlLayout = New HtmlLayout(uri, layoutPage)

'Create a header
html.Header.Center.Text = "%%PR%%%%SP%% of %%ST%%"
html.Header.Center.HasPageNumbers = True
html.Header.Center.Width = 200

'Create a footer
html.Footer.Center.Text = "%%PR%%%%SP(A)%% of %%ST(B)%%"
html.Footer.Center.HasPageNumbers = True
html.Footer.Center.Width = 200

'Create a PDF Document
Dim document As Document = html.Layout

'Save the PDF
document.Draw(outputPath)

HTML & CSS Support​

HTML TagsCSS
The following HTML tags along with their commonly used attributes are supportedThe following CSS properties 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
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

Character Encoding​

HTML source will use the following character encodings:

  • The encoding specified in the HTML file header is used when the HTML source is an HTML file. If that is not present, the HTML meta charset will be used.
  • The character encoding specified in the HTML Meta charset will be used for converting an HTML string.
  • UTF-8 is the default encoding used by the HTML Area when there is no meta charset or the file encoding specified.

Limitations​

Supported tags and properties are based on the HTML 4.0.1 and the CSS 2.1 specification. All limitations are specified in the Product Limitations section.