Package com.helger.pdflayout.base
Class PLPageSet
- java.lang.Object
-
- com.helger.pdflayout.base.AbstractPLObject<PLPageSet>
-
- com.helger.pdflayout.base.PLPageSet
-
- All Implemented Interfaces:
com.helger.commons.id.IHasID<String>,com.helger.commons.traits.IGenericImplTrait<PLPageSet>,IPLHasBorder<PLPageSet>,IPLHasFillColor<PLPageSet>,IPLHasMargin<PLPageSet>,IPLHasMarginBorderPadding<PLPageSet>,IPLHasOutline,IPLHasPadding<PLPageSet>,IPLObject<PLPageSet>,IPLVisitable
@NotThreadSafe public class PLPageSet extends AbstractPLObject<PLPageSet> implements IPLHasMarginBorderPadding<PLPageSet>, IPLHasFillColor<PLPageSet>
Represents a single page layout as element. It consists of a page size, a page header and footer as well as a set of page body elements.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_DIFFERENT_FIRST_PAGE_FOOTERstatic booleanDEFAULT_DIFFERENT_FIRST_PAGE_HEADER-
Fields inherited from interface com.helger.pdflayout.base.IPLHasBorder
DEFAULT_BORDER
-
Fields inherited from interface com.helger.pdflayout.base.IPLHasFillColor
DEFAULT_FILL_COLOR
-
Fields inherited from interface com.helger.pdflayout.base.IPLHasMargin
DEFAULT_MARGIN
-
Fields inherited from interface com.helger.pdflayout.base.IPLHasPadding
DEFAULT_PADDING
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PLPageSetaddElement(IPLRenderableObject<?> aElement)Add an element to this page set.voidforEachElement(Consumer<? super IPLRenderableObject<?>> aConsumer)com.helger.commons.collection.impl.ICommonsList<? extends IPLRenderableObject<?>>getAllElements()floatgetAvailableHeight()floatgetAvailableWidth()BorderSpecgetBorder()intgetElementCount()ColorgetFillColor()IPLRenderableObject<?>getFirstPageFooter()IPLRenderableObject<?>getFirstPageHeader()MarginSpecgetMargin()PaddingSpecgetPadding()IPLRenderableObject<?>getPageFooter()IPLRenderableObject<?>getPageHeader()floatgetPageHeight()SizeSpecgetPageSize()floatgetPageWidth()IPreRenderContextCustomizergetPreRenderContextCustomizer()IRenderContextCustomizergetRenderContextCustomizer()floatgetYTop()booleanhasFirstPageFooter()booleanhasFirstPageHeader()booleanhasPageFooter()booleanhasPageHeader()booleanisDifferentFirstPageFooter()booleanisDifferentFirstPageHeader()PLPageSetPrepareResultprepareAllPages(PreparationContextGlobal aGlobalCtx)voidrenderAllPages(PLPageSetPrepareResult aPrepareResult, org.apache.pdfbox.pdmodel.PDDocument aDoc, boolean bCompressPDF, int nPageSetIndex, int nPageSetCount, int nTotalPageStartIndex, int nTotalPageCount)Render all pages of this layout to the specified PDDocumentPLPageSetsetBorder(BorderSpec aBorder)Set the border values.PLPageSetsetDifferentFirstPageFooter(boolean bDifferentFirstPageFooter)Enable/disable usage of special footer on the first page.PLPageSetsetDifferentFirstPageHeader(boolean bDifferentFirstPageHeader)Enable/disable usage of special header on the first page.PLPageSetsetFillColor(Color aFillColor)Set the element fill color.PLPageSetsetFirstPageFooter(IPLRenderableObject<?> aFirstPageFooter)Set the global page footer.PLPageSetsetFirstPageHeader(IPLRenderableObject<?> aPageHeader)Set the global first page header.PLPageSetsetMargin(MarginSpec aMargin)Set the margin values.PLPageSetsetPadding(PaddingSpec aPadding)Set the padding values.PLPageSetsetPageFooter(IPLRenderableObject<?> aPageFooter)Set the global page footerPLPageSetsetPageHeader(IPLRenderableObject<?> aPageHeader)Set the global page headerPLPageSetsetPreRenderContextCustomizer(IPreRenderContextCustomizer aPRCCustomizer)PLPageSetsetRenderContextCustomizer(IRenderContextCustomizer aRCCustomizer)StringtoString()com.helger.commons.state.EChangevisit(IPLVisitor aVisitor)Visit this object and all descendants-
Methods inherited from class com.helger.pdflayout.base.AbstractPLObject
getDebugID, getID, onAfterSetID, setBasicDataFrom, setID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasBorder
getBorderBottomWidth, getBorderLeftWidth, getBorderRightWidth, getBorderTopWidth, getBorderXSumWidth, getBorderYSumWidth, setBorder, setBorder, setBorder, setBorder, setBorderBottom, setBorderLeft, setBorderRight, setBorderTop, setBorderX, setBorderY
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasFillColor
hasFillColor
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasMargin
addMarginBottom, addMarginLeft, addMarginRight, addMarginTop, addMarginX, addMarginY, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMarginXSum, getMarginYSum, setMargin, setMargin, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMarginTop, setMarginX, setMarginY
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasMarginBorderPadding
getOutlineBottom, getOutlineLeft, getOutlineRight, getOutlineTop, getOutlineXSum, getOutlineYSum
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasPadding
addPaddingBottom, addPaddingLeft, addPaddingRight, addPaddingTop, addPaddingX, addPaddingY, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getPaddingXSum, getPaddingYSum, setPadding, setPadding, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRight, setPaddingTop, setPaddingX, setPaddingY
-
Methods inherited from interface com.helger.pdflayout.base.IPLObject
getAsSplittable, hasID, isVertSplittable
-
-
-
-
Field Detail
-
DEFAULT_DIFFERENT_FIRST_PAGE_HEADER
public static final boolean DEFAULT_DIFFERENT_FIRST_PAGE_HEADER
- See Also:
- Constant Field Values
-
DEFAULT_DIFFERENT_FIRST_PAGE_FOOTER
public static final boolean DEFAULT_DIFFERENT_FIRST_PAGE_FOOTER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PLPageSet
public PLPageSet(@Nonnull org.apache.pdfbox.pdmodel.common.PDRectangle aPageRect)
-
PLPageSet
public PLPageSet(@Nonnegative float fWidth, @Nonnegative float fHeight)
-
-
Method Detail
-
getPageSize
@Nonnull public final SizeSpec getPageSize()
- Returns:
- The page size as specified in the constructor. Never
null. - See Also:
getPageWidth(),getPageHeight()
-
getPageWidth
public final float getPageWidth()
- Returns:
- The page width as specified in the constructor. Never
null. - See Also:
getPageSize(),getPageHeight()
-
getPageHeight
public final float getPageHeight()
- Returns:
- The page height as specified in the constructor. Never
null. - See Also:
getPageSize(),getPageWidth()
-
getMargin
@Nonnull public final MarginSpec getMargin()
- Specified by:
getMarginin interfaceIPLHasMargin<PLPageSet>- Returns:
- The current margin. Never
null.
-
setMargin
@Nonnull public final PLPageSet setMargin(@Nonnull MarginSpec aMargin)
Description copied from interface:IPLHasMarginSet the margin values.- Specified by:
setMarginin interfaceIPLHasMargin<PLPageSet>- Parameters:
aMargin- Margin to use. May not benull.- Returns:
- this
-
getPadding
@Nonnull public final PaddingSpec getPadding()
- Specified by:
getPaddingin interfaceIPLHasPadding<PLPageSet>- Returns:
- The current padding. Never
null.
-
setPadding
@Nonnull public final PLPageSet setPadding(@Nonnull PaddingSpec aPadding)
Description copied from interface:IPLHasPaddingSet the padding values.- Specified by:
setPaddingin interfaceIPLHasPadding<PLPageSet>- Parameters:
aPadding- Padding to use. May not benull.- Returns:
- this
-
getBorder
@Nonnull public final BorderSpec getBorder()
- Specified by:
getBorderin interfaceIPLHasBorder<PLPageSet>- Returns:
- The current border. Never
null.
-
setBorder
@Nonnull public final PLPageSet setBorder(@Nonnull BorderSpec aBorder)
Description copied from interface:IPLHasBorderSet the border values. This method may not be called after an element got prepared!- Specified by:
setBorderin interfaceIPLHasBorder<PLPageSet>- Parameters:
aBorder- Border to use. May not benull.- Returns:
- this
-
getFillColor
@Nullable public final Color getFillColor()
- Specified by:
getFillColorin interfaceIPLHasFillColor<PLPageSet>- Returns:
- The current fill color. May be
null.
-
setFillColor
@Nonnull public final PLPageSet setFillColor(@Nullable Color aFillColor)
Description copied from interface:IPLHasFillColorSet the element fill color.- Specified by:
setFillColorin interfaceIPLHasFillColor<PLPageSet>- Parameters:
aFillColor- The fill color to use. May benull.- Returns:
- this
-
getPreRenderContextCustomizer
@Nullable public final IPreRenderContextCustomizer getPreRenderContextCustomizer()
-
setPreRenderContextCustomizer
@Nonnull public final PLPageSet setPreRenderContextCustomizer(@Nullable IPreRenderContextCustomizer aPRCCustomizer)
-
getRenderContextCustomizer
@Nullable public final IRenderContextCustomizer getRenderContextCustomizer()
-
setRenderContextCustomizer
@Nonnull public final PLPageSet setRenderContextCustomizer(@Nullable IRenderContextCustomizer aRCCustomizer)
-
getAvailableWidth
@Nonnegative public float getAvailableWidth()
- Returns:
- The usable page width without the x-paddings, x-borders and x-margins
-
getAvailableHeight
@Nonnegative public float getAvailableHeight()
- Returns:
- The usable page height without the y-paddings, y-borders and y-margins
-
isDifferentFirstPageHeader
public boolean isDifferentFirstPageHeader()
- Returns:
trueif a special page header should be used on the first page,falseif the same header should be used.- Since:
- 5.0.2
-
setDifferentFirstPageHeader
@Nonnull public PLPageSet setDifferentFirstPageHeader(boolean bDifferentFirstPageHeader)
Enable/disable usage of special header on the first page. To have an effect,setFirstPageHeader(IPLRenderableObject)must be called- Parameters:
bDifferentFirstPageHeader-truefor special page header on the first page- Returns:
- this for chaining
- Since:
- 5.0.2
- See Also:
setFirstPageHeader(IPLRenderableObject)
-
getFirstPageHeader
@Nullable public IPLRenderableObject<?> getFirstPageHeader()
- Returns:
- The global first page header. May be
null. - Since:
- 5.0.2
-
hasFirstPageHeader
public boolean hasFirstPageHeader()
- Returns:
trueif a global first page header is present,falseif not.- Since:
- 5.0.2
-
setFirstPageHeader
@Nonnull public PLPageSet setFirstPageHeader(@Nullable IPLRenderableObject<?> aPageHeader)
Set the global first page header. Must be enabled explicitly viasetDifferentFirstPageHeader(boolean)to take effect.- Parameters:
aPageHeader- The global page header. May benull.- Returns:
- this
- Since:
- 5.0.2
- See Also:
setDifferentFirstPageHeader(boolean)
-
getPageHeader
@Nullable public IPLRenderableObject<?> getPageHeader()
- Returns:
- The global page header. May be
null.
-
hasPageHeader
public boolean hasPageHeader()
- Returns:
trueif a global page header is present,falseif not.
-
setPageHeader
@Nonnull public PLPageSet setPageHeader(@Nullable IPLRenderableObject<?> aPageHeader)
Set the global page header- Parameters:
aPageHeader- The global page header. May benull.- Returns:
- this
-
getAllElements
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<? extends IPLRenderableObject<?>> getAllElements()
-
getElementCount
@Nonnegative public int getElementCount()
-
forEachElement
public void forEachElement(@Nonnull Consumer<? super IPLRenderableObject<?>> aConsumer)
-
addElement
@Nonnull public PLPageSet addElement(@Nonnull IPLRenderableObject<?> aElement)
Add an element to this page set.- Parameters:
aElement- The element to add. May not benull.- Returns:
- this for chaining.
-
isDifferentFirstPageFooter
public boolean isDifferentFirstPageFooter()
- Returns:
trueif a special page footer should be used on the first page,falseif the same footer should be used.- Since:
- 5.0.2
-
setDifferentFirstPageFooter
@Nonnull public PLPageSet setDifferentFirstPageFooter(boolean bDifferentFirstPageFooter)
Enable/disable usage of special footer on the first page. To have an effect,setFirstPageFooter(IPLRenderableObject)must be called.- Parameters:
bDifferentFirstPageFooter-truefor special page footer on the first page- Returns:
- this for chaining
- Since:
- 5.0.2
- See Also:
setFirstPageFooter(IPLRenderableObject)
-
getFirstPageFooter
@Nullable public IPLRenderableObject<?> getFirstPageFooter()
- Returns:
- The global first page footer. May be
null. - Since:
- 5.0.2
-
hasFirstPageFooter
public boolean hasFirstPageFooter()
- Returns:
trueif a global first page footer is present,falseif not.- Since:
- 5.0.2
-
setFirstPageFooter
@Nonnull public PLPageSet setFirstPageFooter(@Nullable IPLRenderableObject<?> aFirstPageFooter)
Set the global page footer. Must be enabled explicitly viasetDifferentFirstPageFooter(boolean)to take effect.- Parameters:
aFirstPageFooter- The global first page footer. May benull.- Returns:
- this
- Since:
- 5.0.2
- See Also:
setDifferentFirstPageFooter(boolean)
-
getPageFooter
@Nullable public IPLRenderableObject<?> getPageFooter()
- Returns:
- The global page footer. May be
null.
-
hasPageFooter
public boolean hasPageFooter()
- Returns:
trueif a global page footer is present,falseif not.
-
setPageFooter
@Nonnull public PLPageSet setPageFooter(@Nullable IPLRenderableObject<?> aPageFooter)
Set the global page footer- Parameters:
aPageFooter- The global page footer. May benull.- Returns:
- this
-
getYTop
public float getYTop()
- Returns:
- The y-top of the page excluding top padding, top-border and top-margin
-
visit
@Nonnull public com.helger.commons.state.EChange visit(@Nonnull IPLVisitor aVisitor) throws IOException
Description copied from interface:IPLVisitableVisit this object and all descendants- Specified by:
visitin interfaceIPLVisitable- Parameters:
aVisitor- The visitor to use. May not benull.- Returns:
EChange.CHANGEDif something changed internally.- Throws:
IOException- on PDFBox error
-
prepareAllPages
@Nonnull public PLPageSetPrepareResult prepareAllPages(@Nonnull PreparationContextGlobal aGlobalCtx)
-
renderAllPages
public void renderAllPages(@Nonnull PLPageSetPrepareResult aPrepareResult, @Nonnull org.apache.pdfbox.pdmodel.PDDocument aDoc, boolean bCompressPDF, @Nonnegative int nPageSetIndex, @Nonnegative int nPageSetCount, @Nonnegative int nTotalPageStartIndex, @Nonnegative int nTotalPageCount) throws IOException
Render all pages of this layout to the specified PDDocument- Parameters:
aPrepareResult- The preparation result. May not benull.aDoc- The PDDocument. May not benull.bCompressPDF-truefor create enflated PDF contentnPageSetIndex- Page set index. Always ≥ 0.nPageSetCount- Page set count. Always ≥ 1.nTotalPageStartIndex- Total page index. Always ≥ 0.nTotalPageCount- Total page count. Always ≥ 1.- Throws:
IOException- In case of render errors
-
toString
public String toString()
- Overrides:
toStringin classAbstractPLObject<PLPageSet>
-
-