Package com.storedobject.pdf
Class PDFReport
java.lang.Object
com.storedobject.pdf.PDF
com.storedobject.pdf.PDFReport
- All Implemented Interfaces:
Executable
,ContentProducer
,ContentType
,Closeable
,AutoCloseable
,Runnable
- Direct Known Subclasses:
AccountStatement
,CombinedPDFReport
,FileCirculationStatus
,FileExpiryReport
,ItemMovementReport
,JournalReport
,ObjectGridReport
,ObjectList
,PDFObjectReport
,StockAvailability
,StockMovementReport
,StockReport
,TrialBalance
A PDF class used for generating reports.
- Author:
- Syam
-
Nested Class Summary
Nested classes/interfaces inherited from class com.storedobject.pdf.PDF
PDF.ObjectFormTable<T extends StoredObject>, PDF.ObjectTable<T extends StoredObject>, PDF.PDFContent, PDF.Text
-
Field Summary
Fields inherited from class com.storedobject.pdf.PDF
ORIENTATION_LANDSCAPE, ORIENTATION_PORTRAIT, pageSizes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateTitleTable
(HasContacts hasContacts, Iterable<String> captions) This is a helper method to create a "title table" from aHasContacts
instance.createTitleTable
(HasContacts hasContacts, String... captions) This is a helper method to create a "title table" from aHasContacts
instance.createTitleTable
(Iterable<String> captions) This is a helper method to create a "title table" from a list of captions.createTitleTable
(String... captions) This is a helper method to create a "title table" from a list of captions.void
execute()
The functional interface method specified by this interface.void
Generate the content and view it on the device with a caption.Get the device on which content will be rendered on.getLogo()
Get the configured logo of the organization (could benull
).Get the name of the configured logo of the organization.int
Get the position of the logo in this report.Get the configured logo of the product (could benull
).Get the name of the configured product logo of the organization.getTitle()
Get the "title" part of the report.Get the "title table" part of the report.Get the "title text" part that was set bysetTitleText(Object)
.getUser()
Get the user for which this PDF is being generated.void
setTitleText
(Object title) Set the "title text" part of the report.void
view()
View the content on the device.Methods inherited from class com.storedobject.pdf.PDF
aboutToAddExternalContent, add, add, add, add, addBlankRow, addBlankRow, addBlankRow, addCentered, addContent, addContent, addContent, addContent, addContent, addContent, addContent, addContent, addContent, addContent, addGap, addHTML, addHTML, addHTML, addHTML, addHTML, addHTML, addImage, addImage, addImage, addingExternalContent, addTitles, addTitles, addTitles, addTitles, addTitles, addTitles, addToTable, addToTable, addToTable, addToTable, addToTable, addToTable, addToTable, addToTable, addToTableCentered, addToTableCentered, chainTo, close, createCell, createCell, createCell, createCell, createCell, createCell, createCell, createCell, createCenteredCell, createCenteredCell, createGraphics, createGraphics, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createImageFromHTML, createImageFromHTML, createImageFromHTML, createImageFromHTML, createImageFromSVG, createImageFromSVG, createTable, createTable, createText, createText, createText, createTitleText, createTitleText, createTitleText, drawTable, drawTable, drawTable, dumpError, generateContent, getBottomMargin, getContent, getContentType, getEntity, getEntityLocation, getEntityName, getFileExtension, getFileName, getFontSize, getFooter, getHeight, getLeftMargin, getPageNumber, getPageOrientation, getPageSize, getPageSize, getPageSizeIndex, getReportFormat, getReportStage, getRightMargin, getTopMargin, getTransactionManager, getWaterMark, getWidth, getY, getY, log, newPage, newReportStage, newReportStage, open, pageCompleted, pageStarted, printAuditTrail, printLetterHeadOnEveryPage, printLetterHeadOnEveryPage, printPageNumber, printPageNumber, printTotalPageNumber, printTotalPageNumber, produce, readContent, setDefaultCellCustomizer, setEntity, setError, setFontSize, setLanguage, setLanguage, setLogo, setLogo, setPageNumber, setPageSizeIndex, setPassword, setReportFormat, setTransactionManager, setWaterMark, showText, toCharCount
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.storedobject.core.ContentProducer
abort, getError, getStreamData, getStreamDataProvider, getSystemEntity, saveTo, saveTo, saveTo, saveTo
Methods inherited from interface com.storedobject.core.ContentType
getLink, getMimeType, isAudio, isHTML, isImage, isLink, isMedia, isPDF, isText, isVideo
Methods inherited from interface com.storedobject.common.Executable
act, run
-
Constructor Details
-
PDFReport
Constructor.- Parameters:
device
- Device on which the output will be rendered when viewing.
-
PDFReport
Constructor.- Parameters:
device
- Device on which the output will be rendered when viewing.letterhead
- Whether default letterhead needs to be printed or not.
-
PDFReport
Constructor.- Parameters:
device
- Device on which the output will be rendered when viewing.letterhead
- Whether default letterhead needs to be printed or not.printLogo
- Whether default logo needs to be printed or not.
-
-
Method Details
-
extractContent
- Throws:
Exception
-
execute
public void execute()Description copied from interface:Executable
The functional interface method specified by this interface. -
execute
Generate the content and view it on the device with a caption.- Parameters:
caption
- Caption.
-
view
public void view()View the content on the device. -
getUser
Description copied from class:PDF
Get the user for which this PDF is being generated. This information will be used for formatting the money values. -
getDevice
-
getLogo
Get the configured logo of the organization (could benull
).- Returns:
- The configured logo.
-
getLogoName
Get the name of the configured logo of the organization.- Returns:
- Name of the logo. You may override this to print another logo.
-
getProductLogo
Get the configured logo of the product (could benull
).- Returns:
- The configured product logo.
-
getProductLogoName
Get the name of the configured product logo of the organization.- Returns:
- Name of the product logo. You may override this to print another logo.
-
getLogoPosition
public int getLogoPosition()Get the position of the logo in this report. By default, it looks for the "report format" configuration from which this value can be obtained. SeeReportFormat
.- Returns:
- Position.
-
getTitle
Get the "title" part of the report. By default, title part is aPDFTable
created from the configured logos (customer logo and product logo) and the "title table" part returned by thegetTitleTable()
method. However, this method is usually not overridden unless you want to create a report that doesn't include printing of logos etc. So, if you override this method, then, thegetTitleTable()
is never used (unless you use it within your overridden method). -
setTitleText
Set the "title text" part of the report. The value set by this method is returned by thegetTitleText()
method and used by thegetTitleTable()
method.Note: Please make sure that this method is invoked from within the constructor itself because it will not have any effect if invoked from any other position.
- Parameters:
title
- Title text part of the report. Can be anything and will be converted appropriately.
-
getTitleText
Get the "title text" part that was set bysetTitleText(Object)
. (If nothing was ever set,null
will be returned.- Returns:
- "Title text" part of the report. (This is used by
getTitleTable()
method).
-
getTitleTable
Get the "title table" part of the report. It builds a
PDFTable
from the "title text" part returned by thegetTitleText()
method. ThegetTitle()
method uses the return value of this to build the "title" part of the report.Typically, you may override this method and return one of the createTitleTable methods
Example:
public PDFTable getTitleTable() { return createTitleTable("Stock Report", "Dated: Nov 15, 2021", "Store: Main Store"); }
- Returns:
- "Title table" part of the report.
-
createTitleTable
This is a helper method to create a "title table" from a list of captions. ThegetTitleTable()
can use this to create a "title table" quickly with noHasContacts
details because the address part of the "letter head" is already in the header-image.- Parameters:
captions
- Caption to be printed. The fist caption will be more highlighted than the subsequent ones.- Returns:
- A table instance that can be used as a "title table".
-
createTitleTable
This is a helper method to create a "title table" from a list of captions. ThegetTitleTable()
can use this to create a "title table" quickly with noHasContacts
details because the address part of the "letter head" is already in the header-image.- Parameters:
captions
- Caption to be printed. The fist caption will be more highlighted than the subsequent ones.- Returns:
- A table instance that can be used as a "title table".
-
createTitleTable
This is a helper method to create a "title table" from aHasContacts
instance. ThegetTitleTable()
can use this to create a "title table" quickly.- Parameters:
hasContacts
- Contact instance. The name and address will be printed from this.captions
- Caption to be printed. The fist caption will be more highlighted than the subsequent ones.- Returns:
- A table instance that can be used as a "title table".
-
createTitleTable
This is a helper method to create a "title table" from aHasContacts
instance. ThegetTitleTable()
can use this to create a "title table" quickly.- Parameters:
hasContacts
- Contact instance. The name and address will be printed from this.captions
- Caption to be printed. The fist caption will be more highlighted than the subsequent ones.- Returns:
- A table instance that can be used as a "title table".
-