Package org.kissweb
Class Groff
java.lang.Object
org.kissweb.Groff
Class to interface with the groff typesetting system. This is an easy way to generate nicely formatted reports.
Of course, the underlying system must have groff/tbl/mm installed.
See: https://www.gnu.org/software/groff
There are two classes in Kiss used to create PDF reports: PDF and Groff. PDF is used when graphics and images are needed. Groff is used when text and tables are needed. It is possible to use both in the same report by creating the PDF with one and appending with the other.
See: https://www.gnu.org/software/groff
There are two classes in Kiss used to create PDF reports: PDF and Groff. PDF is used when graphics and images are needed. Groff is used when text and tables are needed. It is possible to use both in the same report by creating the PDF with one and appending with the other.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPageTitleLine
(String line) Add an additional line to the page title.void
Output a numeric double column
msk
is aString
consisting of the following characters: B = blank if zero C = add commas L = left justify number P = put parentheses around negative numbers Z = zero fill D = floating dollar sign U = uppercase letters in conversion R = add a percent sign to the end of the numbervoid
Output a numeric integer column
msk
is aString
consisting of the following characters: B = blank if zero C = add commas L = left justify number P = put parentheses around negative numbers Z = zero fill D = floating dollar sign U = uppercase letters in conversion R = add a percent sign to the end of the numbervoid
Output a column (title or body of table)void
columnWrap
(String col) Output a column that may wrap vertically.void
dateColumn
(int date) Output an integer date column.void
dateColumn
(Date date) Output a Date date column.void
dateColumn2
(int date) Output an integer date column.void
Prevent the deletion of the intermediate files for debugging purposes.void
endRow()
Normally not needed.void
endTable()
To be called at the end of the tablevoid
endTitle()
Mark the end of the titleFor debugging.The file name returned elsewhere is one convenient for web applications.void
needLines
(int n) Force a new page if there isn't at leastn
lines available on the current page.static Groff
newTemplate
(String fnamePrefix, String mmTemplateFileName, boolean landscape) Initialize a new MM template.void
Do not auto-generate the page title, or if already printed, stop.void
Write a line to the groff input file.void
Output a line in bold text.void
Output a Postscript image.process()
Process the groff/tbl/mm input, produce the PDF output file, and return the path to the PDF file.process
(float sideMargin) Process the groff/tbl/mm input, produce the PDF output file, and return the path to the PDF file.void
Ability to customize what shows on the bottom of each page.void
setRuntime
(String rt) Manually set the run date string.void
setVariable
(String name, String value) Used to assign values to template variables.void
setWaitMinutes
(long m) Set the number of minutes to wait for groff to finish.void
startTable
(String colFmt) Mark the start of a table.
-
Constructor Details
-
Groff
Initialize a new report. The files it uses are put in temporary files that are auto-cleaned and in a place that can be served to the front-end. On the front-end side, see JavaScript Utils.showReport()- Parameters:
fnamePrefix
- final PDF file name prefixtitle
- report title or nulllandscape
- true if landscape format, portrait otherwise- Throws:
IOException
-
-
Method Details
-
newTemplate
public static Groff newTemplate(String fnamePrefix, String mmTemplateFileName, boolean landscape) throws IOException Initialize a new MM template. When utilizing a template rather than generating a report, there are only two methods used besides this one:setVariable
andprocess
.- Parameters:
fnamePrefix
- final PDF file name prefixmmTemplateFileName
- path to the MM templatelandscape
- true if landscape format, portrait otherwise- Returns:
- Throws:
IOException
- See Also:
-
setVariable
Used to assign values to template variables. Note, this method is only used when processing an MM template.- Parameters:
name
- name of the variablevalue
- value to assign to it- See Also:
-
noAutoPageHeader
public void noAutoPageHeader()Do not auto-generate the page title, or if already printed, stop. -
startTable
Mark the start of a table.
colFmt
is a string specifying the layout for each column as specified by tbl.- Parameters:
colFmt
-
-
setRuntime
Manually set the run date string. An empty string (but not null) will cause no run date to be printed.- Parameters:
rt
-
-
column
Output a column (title or body of table)- Parameters:
col
-
-
endRow
public void endRow()Normally not needed. Done automatically. However, is needed to end a row prematurely. -
needLines
public void needLines(int n) Force a new page if there isn't at leastn
lines available on the current page.- Parameters:
n
- number of lines needed
-
columnWrap
Output a column that may wrap vertically.- Parameters:
col
-
-
column
Output a numeric double column
msk
is aString
consisting of the following characters:- B = blank if zero
- C = add commas
- L = left justify number
- P = put parentheses around negative numbers
- Z = zero fill
- D = floating dollar sign
- U = uppercase letters in conversion
- R = add a percent sign to the end of the number
- Parameters:
num
- the number to be outputmsk
- Format maskdp
- number of decimal places (-1 means auto)
-
column
Output a numeric integer column
msk
is aString
consisting of the following characters:- B = blank if zero
- C = add commas
- L = left justify number
- P = put parentheses around negative numbers
- Z = zero fill
- D = floating dollar sign
- U = uppercase letters in conversion
- R = add a percent sign to the end of the number
- Parameters:
num
- the number to be outputmsk
- Format mask
-
dateColumn
public void dateColumn(int date) Output an integer date column. Formats date as MM/DD/YYYY- Parameters:
date
- integer date formatted as YYYYMMDD
-
dateColumn2
public void dateColumn2(int date) Output an integer date column. Formats date as MM/DD/YY- Parameters:
date
- integer date formatted as YYYYMMDD
-
dateColumn
Output a Date date column. Formats date as MM/DD/YYYY- Parameters:
date
-
-
endTitle
public void endTitle()Mark the end of the title -
endTable
public void endTable()To be called at the end of the table -
outBold
Output a line in bold text.- Parameters:
txt
-
-
addPageTitleLine
Add an additional line to the page title.- Parameters:
line
-
-
dontDeleteIntermediateFiles
public void dontDeleteIntermediateFiles()Prevent the deletion of the intermediate files for debugging purposes. -
out
Write a line to the groff input file.- Parameters:
str
-
-
outPSPIC
Output a Postscript image. The height of the picture is calculated for the picture to retain its aspect ratio along with the width specification.- Parameters:
fname
- the path to the postscript image filewitdh
- the output width of this picture
-
process
Process the groff/tbl/mm input, produce the PDF output file, and return the path to the PDF file. The file name returned is suitable for a web server and not the absolute file path.- Parameters:
sideMargin
- size of the margin on the left side of the page in inches- Returns:
- Throws:
IOException
InterruptedException
- See Also:
-
process
Process the groff/tbl/mm input, produce the PDF output file, and return the path to the PDF file. Defaults to a 1-inch side margin.- Returns:
- Throws:
IOException
InterruptedException
- See Also:
-
getRealFileName
The file name returned elsewhere is one convenient for web applications. This method returns the real file name - not relative to a web server. -
getGroffFileName
For debugging. Returns the intermediate groff file. This only makes sense ifdontDeleteGroffFile()
is called.- Returns:
- The intermediate troff/groff source file.
-
setWaitMinutes
public void setWaitMinutes(long m) Set the number of minutes to wait for groff to finish. The default is 1 minute.- Parameters:
m
-
-