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.Documentm_Documentthe documentation that is being worked on.protected PlaceholderFilem_Outputthe output file.protected PageOrientationm_PageOrientationthe page orientation.protected PageSizem_PageSizethe page size.protected PdfProclet[]m_Procletsthe PDF processors.protected DocumentStatem_Statethe document state.protected FileOutputStreamm_Streamthe output stream.protected com.itextpdf.text.pdf.PdfWriterm_Writerthe 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 voidaddFile(File file)Adds the file.voidaddFiles(File[] files)Adds the files.voidappend()Opens the document for appending content.voidclose()Closes the document again.protected com.itextpdf.text.RectangledeterminePageSize()Returns the PageSize object based on the current setup.com.itextpdf.text.DocumentgetDocument()The current PDF document.PlaceholderFilegetOutput()Returns the output file.PageOrientationgetPageOrientation()Returns the page orientation.PageSizegetPageSize()Returns the page size.PdfProclet[]getProclets()Returns the processors.DocumentStategetState()Returns the PDF document state.com.itextpdf.text.pdf.PdfWritergetWriter()Returns the PDF writer.protected booleanisOpen()Checks whether the document is still open.booleannewPage()Adds a new page.voidopen()Opens the document for writing.protected voidreset()Resets the variables and counters.protected voidresetState()Resets the counters.protected voidresetVariables()Resets the variables.voidsetOutput(PlaceholderFile value)Sets the output file.voidsetPageOrientation(PageOrientation value)Sets the page orientation.voidsetPageSize(PageSize value)Sets the page size.voidsetProclets(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 ExceptionOpens the document for writing.- Throws:
Exception- if opening fails
-
append
public void append() throws ExceptionOpens 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.
-
-