Using iText
Apache iText is an open-source Java library that supports developing and converting PDF documents.
While converting HTML files to PDF files, the config.json file ensures that all the CSS attributes are reflected properly.
The config.json defines the parameters to be used while generating PDF Reports.
The parameters supported are listed in the following table.
Attribute | Description | ||
---|---|---|---|
Header parameters: Sample Code
Sample Output
| |||
type | Header | ||
headerHtml | The HTML code of the header to be added | ||
fontSize | Font Size | ||
fontType | Font Type | ||
posix | X-coordinate (abscissa) of the position of the header | ||
posy | Y-coordinate (ordinate) of the position of the header | ||
height | Height of the header section | ||
width | Width of the header section | ||
headerPages | The pages to add the header to:
| ||
Footer parameters: Sample Code
Sample Output
| |||
type | Footer | ||
footerHtml | The HTML code of the footer to be added | ||
fontSize | Font Size | ||
fontType | Font Type | ||
posix | X-coordinate (abscissa) of the position of the footer | ||
posy | Y-coordinate (ordinate) of the position of the footer | ||
height | Height of the footer section | ||
width | Width of the footer section | ||
footerPages | The pages to add the footer to:
| ||
Page Margin parameters: Sample code
Sample Page Margins
| |||
type | PageMargin | ||
bottomFirstPageMargin | The bottom margin of the first page. | ||
leftFirstPageMargin | The left margin of the first page. | ||
rightFirstPageMargin | The right margin of the first page. | ||
topFirstPageMargin | The top margin of the first page. | ||
topPageMargin | The top margin of all pages. | ||
bottomPageMargin | The bottom margin of all pages. | ||
leftPageMargin | The left margin of all pages. | ||
rightPageMargin | The right margin of all pages. | ||
'Add Continued On Next Page' parameters: Sample Code
Sample Output
| |||
type | AddContinuedOnNextPage | ||
isActive | Set isActive to true to activate this parameter. | ||
firstParameter | The HTML tag indicates the start of the added text. This will be deleted later. | ||
secondParameter | The HTML tag indicates the end of the added text. This will be deleted later. | ||
textToAdd | The text to be added. | ||
fontType | Font Type | ||
fontSize | Font Size | ||
posix | X-coordinate (abscissa) of the position of the text | ||
posy | Y-coordinate (ordinate) of the position of the text. | ||
Change mark parameter: Sample code
| |||
type | DrawChangeMark | ||
startTag | The HTML tag indicates the start of the added text. This will be deleted later. | ||
endTag | The HTML tag indicates the end of the added text. This will be deleted later. | ||
lineWidth | Width of the line | ||
topFirstPageMargin | The top margin of the first page. | ||
bottomFirstPageMargin | The bottom margin of the first page. | ||
marginTop | Top margin | ||
marginBottom | Bottom Margin | ||
Horizontal line parameter: Sample code
| |||
type | HorizontalLine | ||
tag | The HTML tag indicates the position of the added text. This will be deleted later. | ||
startPosix | X-coordinate (abscissa) of the start position of the line. | ||
endPosix | X-coordinate (abscissa) of the end position of the line. | ||
lineWidth | Width of the line | ||
Page number parameter Sample Code
Sample Output
| |||
type | PageNumber | ||
posix | X-coordinate (abscissa) of the position of the page number. | ||
posy | Y-coordinate (ordinate) of the position of the page number. | ||
firstPagePosix | X-coordinate (abscissa) of the position of the page number on the first page. | ||
firstPagePosy | Y-coordinate (ordinate) of the position of the page number on the first page. | ||
fontType | Font Type | ||
fontSize | Font Size | ||
firstPageFontType | Font Type in the first page. | ||
firstPageFontSize | Font Size in the first page. | ||
positionString | The HTML tag to indicate the position of the page number. This will be removed later. | ||
pageNumberAction |
| ||
fontColor | red/blue/white/pink/gray/yellow/green (nothing for black) | ||
stringToDisplay | String to display in case pageNumberAction = string | ||
Page size parameters: Sample code
| |||
type | PageSize | ||
pageSizeParamValue |
| ||
Table content parameter | |||
type | TableContent | ||
tag | The HTML tag indicates where to add the input. This will be deleted later. | ||
fontType | Font Type | ||
fontSize | Font Size | ||
posix | X-coordinate (abscissa) of the position of the Table. | ||
posy | Y-coordinate (ordinate) of the position of the Table. | ||
pageNumber | Number of the page to which the Table is to be added. | ||
Step attachment parameter | |||
type | stepAttachment | ||
tag | stepAttachment |