Skip to main content

FieldLogs

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

HeaderCode.png

Sample Output

HeaderOnly.png

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:

  • allPages

  • allExceptFirst

  • allExceptLast

  • oddPages

  • evenPages

  • firstPage

  • first2Pages

Footer parameters:

Sample Code

FooterCode.png

Sample Output

FooterOnly.png

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:

  • allPages

  • allExceptFirst

  • allExceptLast

  • oddPages

  • evenPages

Page Margin parameters:

Sample code

PagemarginCode.png

Sample Page Margins

PageMargins.png

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

ContinuedOnNextPageCode.png

Sample Output

ContinuedOnNextPage.png

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

DrawChangeMarkCode.png

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

HorizontalLine.png

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

PageNumber.png

Sample Output

PAgeNumberOutput.png

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

  • DEFAULT : page 6

  • TOTAL_PAGES : page 6 of 20

  • PAGE : 6/20

  • PAGE_NUMBER : 6

  • STRING : (look at stringToDisplay should be there)

  • TOTAL_PAGES_NUMBER : displays the total number of pages

fontColor

red/blue/white/pink/gray/yellow/green (nothing for black)

stringToDisplay

String to display in case pageNumberAction = string

Page size parameters:

Sample code

PageSizeCode.png

type

PageSize

pageSizeParamValue

  • DEFAULT : A4

  • A4

  • A3

  • A2

  • Executive

  • Ledger

  • Tabloid

  • Legal

  • Letter

  • Landscape

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