PDFTools - XML to PDF Guide
Since version 1.1, PDFTools include a XML to PDF conversion utility. This feature allows you to create a PDF document by specifying structure in a XML document. The XML tags in PDFTools is closer to HTML tags, so it is very easy to understand and use.Take a look at the DTD for PDFTools for list of tags and supported attributes.
Following are the tags supported in PDFTools :
- "document" : Represents a PDF document.
- "header" : Header tag
- "footer" : Footer tag
- "p" : Paragraph tag.
- "font" : Font tag
- "a" : Anchor(link) tag
- "br" : New line tag
- "pagebreak" : New page tag
- "img" : Image tag
- "pagenumber" : Page Number tag
- "table" : Table tag
- "cell" : Cell tag
- To insert space use
Examples :
1) To understand the PDFTools xml format. Download the following example files : newton.xml, image1 and image2
Copy images to c:\ folder, and run PDFTools's "PDF Creator" option.
You can download the generated PDF newton.pdf also from here.
Note: If you have problem accessing to sheelapps.com then change <!DOCTYPE document SYSTEM "http://sheelapps.com/PDFTools/PDFTools1.1.dtd"> to <!DOCTYPE document SYSTEM "PDFTools1.1.dtd"> and keep xml file and DTD file in same folder.
document
The document tag is the top most tag in PDFTools' XML file. All the other tags should be declared inside this tag. The document tag should contain at least one paragraph("p") or table tag to generate a PDF.Note: If you have problem accessing to sheelapps.com then change <!DOCTYPE document SYSTEM "http://sheelapps.com/PDFTools/PDFTools1.1.dtd"> to <!DOCTYPE document SYSTEM "PDFTools1.1.dtd"> and keep xml file and dtd file in same folder.
Example:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE document SYSTEM "http://sheelapps.com/PDFTools/PDFTools1.1.dtd"> <document author="Sheel Khanna" title="Isaac Newton" pageSize="A4" marginLeft="10" marginRight="10" marginTop="10" marginBottom="10"> <!-- other tags --> </document> |
Supported attributes :
Attribute | Description | Optional | Supported values | Default Value |
---|---|---|---|---|
author | Adds the author property to the document | Yes | Text | - |
title | Adds the title property to the document | Yes | Text | - |
marginTop | Sets the top margin for the document | Yes | Float | 36 |
marginBottom | Sets the bottom margin for the document | Yes | Float | 36 |
marginLeft | Sets the left margin for the document | Yes | Float | 36 |
marginRight | Sets the right margin for the document | Yes | Float | 36 |
pageSize | Sets the page size | Yes | Must be : A0 to A10 or B0 to B5 or ARCH_A to ARCH_E or HALFLETTER or LEDGER or _11X17 | A4 |
Following tags are allowed inside document tag:
p | header | footer | table | pagebreak | br |
---|
Back to Top
header
It is an optional tag. The header tag adds the Header section to every page in document. There should be only one header tag per document.Example:
<header align="right"> This is header text. </header> |
Supported attributes :
Attribute | Description | Optional | Supported values | Default Value |
---|---|---|---|---|
align | Alignment of text in header | Yes | "left" or "center" or "right" | "center" |
Following tags are allowed inside header tag :
font |
---|
Back to Top
footer
It is an optional tag. The footer tag adds the Footer section to every page in document. There should be only one footer tag per document.Note: Unlike header, you cannot specify a font tag inside a footer tag. Instead you can specify font attributes as footer attribute.
Example:
<footer align="right" size="7" > This is footer text and this is page # <pagenumber/>. </footer> |
Supported attributes :
Attribute | Description | Optional | Supported values | Default Value |
---|---|---|---|---|
align | Alignment of text in footer | Yes | "left" or "center" or "right" | "center" |
face | Footer Font face | Yes | See font | |
size | Footer Font size | Yes | See font | |
style | Footer Font style | Yes | See font | |
color | Footer Font color | Yes | See font |
Following tags are allowed inside footer tag :
pagenumber |
---|
Back to Top
p
The "p" (paragraph) tag are the building blocks of document. Each paragraph represents the section of data in document. You can add multiple paragraphs to document.Example:
<p>This is sample paragraph text. With a newline at <br/> and more text. Here is a text in <font style="bold underline"> bold and underline </font>. </p> |
Supported attributes :
None
Following tags are allowed inside paragraph tag :
font | a | pagenumber | img | table | br |
---|
Back to Top
font
"font" tag can be used to specify text formatting in a document.Example:
<font size="10" style="bold italic">size 10 bold italic</font> <font style="bold italic underline line-through">bold italic underline line-through test</font> <font size="8" color="blue">normal size 8 color blue text</font> <font face="Helvetica">Helvetica</font> <font face="Courier" size="8">Courier</font> <font face="Times-Roman">Times-Roman</font> <font face="Symbol">Symbol</font> |
Supported attributes :
No tags are allowed inside font tag.
Back to Top
a
"a" Anchor tag can be used to specify a hyperlink in a document. The link can be external or internal to another anchor.Example:
<a href="http://sheelapps.com" name="link1">link to sheelapps.com</a> <a href="#link1" >link to link1 in document</a> |
Supported attributes :
Attribute | Description | Optional | Supported values | Default Value |
---|---|---|---|---|
name | Name of the link | Yes | Text | |
href | Link target | Yes | Text |
Following tags are allowed inside "a" tag :
font |
---|
Back to Top
br
The "br" tag inserts a single line break.Example:
<p>This is simple text with <br/> line break. </p> |
Supported attributes :
None
Following tags are allowed inside "br" tag :
None
Back to Top
pagebreak
The "pagebreak" tag inserts a new page in the document.Example:
<pagebreak/> |
Supported attributes :
None
Following tags are allowed inside "pagebreak" tag :
None
Back to Top
img
"img" tag inserts an image in the document.Example:
<img src="c:/180px-Newton.jpg" align="left textwrap" alt="Engraving after Enoch Seeman 1726 portrait of Newton" border="0.1" /> |
Supported attributes :
Attribute | Description | Optional | Supported values | Default Value |
---|---|---|---|---|
src | The URL of the image to display | No | Text | |
alt | Defines a short description of the image | Yes | Text | |
border | Defines a border around an image. | Yes | Float | |
width | Defines the width of an image | Yes | Float pixels | |
height | Defines the height of an image | Yes | Float pixels | |
align | Specifies how to align the image according to surrounding text. Basically this attribute
has combination of two values 1) left or middle or right : Location of image 2) textwrap or underlying : Wrap the text or underlay. | Yes |
Following tags are allowed inside "img" tag :
None |
---|
Back to Top
pagenumber
This tag can be used to insert current page number in document.Example:
<pagenumber/> |
Supported attributes :
None
Following tags are allowed inside "pagenumber" tag :
None |
---|
Back to Top
table
"table" tags can be used to define table.Example:
<table width="50" align="center" border="0.1" cellspacing="5" cellpadding="5" columns="2" backgroundcolor="lightgray" bordercolor="blue"> <cell> Column 1 </cell> <cell> Column 2 </cell> <cell> Column 11 </cell> <cell> Column 22 </cell> </table> |
Supported attributes :
Attribute | Description | Optional | Supported values | Default Value |
---|---|---|---|---|
align | Aligns the table. | Yes | left or center or right | left |
columns | Number of columns in table | Yes | Number | 1 |
border | Specifies the border width | Yes | Float | 0 |
bordercolor | Border color | Yes | Color name | black |
cellpadding | Specifies the space between the cell walls and contents | Yes | Float | 0 |
cellspacing | Specifies the space between cells | Yes | Float | 0 |
backgroundcolor | Table background color | Yes | Color name | white |
width | Specifies the table width in percentage | Yes | Float |
Following tags are allowed inside "table" tag :
cell |
---|
Back to Top
cell
"cell" tags can be used to define cell inside a table. Cell can span to mutiple columns or rows.Example:
<table width="50" align="center" border="0.1" cellspacing="5" cellpadding="5" columns="2" backgroundcolor="lightgray" bordercolor="blue"> <cell halign="top"> Column 1 </cell> <cell> Column 2 </cell> <cell> Column 11 </cell> <cell> Column 22 </cell> </table> <table width="50" columns"2" > <cell width="20" border="0.1"> Column data </cell> <cell width="80"> Column data </cell> <cell colspan="2" border="0.1" > Second row Column data </cell> </table> |
Supported attributes :
Attribute | Description | Optional | Supported values | Default Value |
---|---|---|---|---|
halign | Horizontal alignment of text in cell | Yes | left or center or right | left |
valign | Vertical alignment of text in cell | Yes | top or middle or bottom | bottom |
border | Specifies the border width | Yes | Float | 0 |
bordercolor | Border color | Yes | Color name | black |
colspan | Specifies the number of columns will cell span | Yes | Float | 1 |
rowspan | Specifies the number of rows will cell span | Yes | Float | 1 |
backgroundcolor | Cell background color | Yes | Color name | white |
width | Specifies the cell width in percentage. It should be set to cells only in first row. | Yes | Number |
Following tags are allowed inside "cell" tag :
font | a | br | img | pagenumber |
---|
Back to Top
Applications |
Links |
PDFTools Links |
Share this Page |