Class PDFGenerator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.flow.transformer.pdfproclet.PDFGenerator
-
- All Implemented Interfaces:
LoggingLevelHandler
,LoggingSupporter
,SizeOfHandler
,Serializable
public class PDFGenerator extends CustomLoggingLevelObject
A helper class for PDF generation.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected com.itextpdf.text.Document
m_Document
the documentation that is being worked on.protected PlaceholderFile
m_Output
the output file.protected PageOrientation
m_PageOrientation
the page orientation.protected PageSize
m_PageSize
the page size.protected PdfProclet[]
m_Proclets
the PDF processors.protected DocumentState
m_State
the document state.protected FileOutputStream
m_Stream
the output stream.protected com.itextpdf.text.pdf.PdfWriter
m_Writer
the writer.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description PDFGenerator()
Initializes the PDF generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFile(File file)
Adds the file.void
addFiles(File[] files)
Adds the files.void
append()
Opens the document for appending content.void
close()
Closes the document again.protected com.itextpdf.text.Rectangle
determinePageSize()
Returns the PageSize object based on the current setup.com.itextpdf.text.Document
getDocument()
The current PDF document.PlaceholderFile
getOutput()
Returns the output file.PageOrientation
getPageOrientation()
Returns the page orientation.PageSize
getPageSize()
Returns the page size.PdfProclet[]
getProclets()
Returns the processors.DocumentState
getState()
Returns the PDF document state.com.itextpdf.text.pdf.PdfWriter
getWriter()
Returns the PDF writer.protected boolean
isOpen()
Checks whether the document is still open.boolean
newPage()
Adds a new page.void
open()
Opens the document for writing.protected void
reset()
Resets the variables and counters.protected void
resetState()
Resets the counters.protected void
resetVariables()
Resets the variables.void
setOutput(PlaceholderFile value)
Sets the output file.void
setPageOrientation(PageOrientation value)
Sets the page orientation.void
setPageSize(PageSize value)
Sets the page size.void
setProclets(PdfProclet[] value)
Sets the processors.-
Methods inherited from class adams.core.logging.CustomLoggingLevelObject
setLoggingLevel
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Output
protected PlaceholderFile m_Output
the output file.
-
m_PageSize
protected PageSize m_PageSize
the page size.
-
m_PageOrientation
protected PageOrientation m_PageOrientation
the page orientation.
-
m_Proclets
protected PdfProclet[] m_Proclets
the PDF processors.
-
m_Document
protected com.itextpdf.text.Document m_Document
the documentation that is being worked on.
-
m_Stream
protected transient FileOutputStream m_Stream
the output stream.
-
m_State
protected DocumentState m_State
the document state.
-
m_Writer
protected com.itextpdf.text.pdf.PdfWriter m_Writer
the writer.
-
-
Method Detail
-
reset
protected void reset()
Resets the variables and counters.
-
resetVariables
protected void resetVariables()
Resets the variables.
-
resetState
protected void resetState()
Resets the counters.
-
setPageSize
public void setPageSize(PageSize value)
Sets the page size.- Parameters:
value
- the size
-
getPageSize
public PageSize getPageSize()
Returns the page size.- Returns:
- the size
-
setPageOrientation
public void setPageOrientation(PageOrientation value)
Sets the page orientation.- Parameters:
value
- the orientation
-
getPageOrientation
public PageOrientation getPageOrientation()
Returns the page orientation.- Returns:
- the orientation
-
setOutput
public void setOutput(PlaceholderFile value)
Sets the output file.- Parameters:
value
- the file
-
getOutput
public PlaceholderFile getOutput()
Returns the output file.- Returns:
- the file
-
setProclets
public void setProclets(PdfProclet[] value)
Sets the processors.- Parameters:
value
- the processors
-
getProclets
public PdfProclet[] getProclets()
Returns the processors.- Returns:
- the processors
-
getDocument
public com.itextpdf.text.Document getDocument()
The current PDF document.- Returns:
- the document
-
getState
public DocumentState getState()
Returns the PDF document state.- Returns:
- the state
-
getWriter
public com.itextpdf.text.pdf.PdfWriter getWriter()
Returns the PDF writer.- Returns:
- the writer
-
newPage
public boolean newPage()
Adds a new page.- Returns:
- true if successfully added (or not necessary)
-
determinePageSize
protected com.itextpdf.text.Rectangle determinePageSize()
Returns the PageSize object based on the current setup.- Returns:
- the page size rectangle
-
open
public void open() throws Exception
Opens the document for writing.- Throws:
Exception
- if opening fails
-
append
public void append() throws Exception
Opens the document for appending content.- Throws:
Exception
- if opening fails
-
isOpen
protected boolean isOpen()
Checks whether the document is still open.- Returns:
- true if the document is still open
-
addFile
public void addFile(File file) throws Exception
Adds the file. Chooses the type of import based on the extension of the file.- Parameters:
file
- the file to add- Throws:
Exception
- if adding fails
-
addFiles
public void addFiles(File[] files) throws Exception
Adds the files. Chooses the type of import based on the extension of the file.- Parameters:
files
- the files to add- Throws:
Exception
- if adding fails
-
close
public void close()
Closes the document again.
-
-