Package com.helger.pdflayout.base
Class 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
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final booleanFields inherited from interface com.helger.pdflayout.base.IPLHasBorder
DEFAULT_BORDERFields inherited from interface com.helger.pdflayout.base.IPLHasFillColor
DEFAULT_FILL_COLORFields inherited from interface com.helger.pdflayout.base.IPLHasMargin
DEFAULT_MARGINFields inherited from interface com.helger.pdflayout.base.IPLHasPadding
DEFAULT_PADDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddElement(IPLRenderableObject<?> aElement) Add an element to this page set.voidforEachElement(Consumer<? super IPLRenderableObject<?>> aConsumer) com.helger.commons.collection.impl.ICommonsList<? extends IPLRenderableObject<?>>floatfloatfinal BorderSpecintfinal PLColorfinal MarginSpecfinal PaddingSpecfinal floatfinal SizeSpecfinal floatfinal IRenderContextCustomizerfloatgetYTop()booleanbooleanbooleanbooleanbooleanbooleanprepareAllPages(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 PDDocumentfinal PLPageSetsetBorder(BorderSpec aBorder) Set the border values.setDifferentFirstPageFooter(boolean bDifferentFirstPageFooter) Enable/disable usage of special footer on the first page.setDifferentFirstPageHeader(boolean bDifferentFirstPageHeader) Enable/disable usage of special header on the first page.final PLPageSetsetFillColor(PLColor aFillColor) Set the element fill color.setFirstPageFooter(IPLRenderableObject<?> aFirstPageFooter) Set the global page footer.setFirstPageHeader(IPLRenderableObject<?> aPageHeader) Set the global first page header.final PLPageSetsetMargin(MarginSpec aMargin) Set the margin values.final PLPageSetsetPadding(PaddingSpec aPadding) Set the padding values.setPageFooter(IPLRenderableObject<?> aPageFooter) Set the global page footersetPageHeader(IPLRenderableObject<?> aPageHeader) Set the global page headerfinal PLPageSetsetPreRenderContextCustomizer(IPreRenderContextCustomizer aPRCCustomizer) final PLPageSetsetRenderContextCustomizer(IRenderContextCustomizer aRCCustomizer) toString()com.helger.commons.state.EChangevisit(IPLVisitor aVisitor) Visit this object and all descendantsMethods inherited from class com.helger.pdflayout.base.AbstractPLObject
getDebugID, getID, onAfterSetID, setBasicDataFrom, setIDMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsTMethods inherited from interface com.helger.pdflayout.base.IPLHasBorder
getBorderBottomWidth, getBorderLeftWidth, getBorderRightWidth, getBorderTopWidth, getBorderXSumWidth, getBorderYSumWidth, setBorder, setBorder, setBorder, setBorder, setBorderBottom, setBorderLeft, setBorderRight, setBorderTop, setBorderX, setBorderYMethods inherited from interface com.helger.pdflayout.base.IPLHasFillColor
hasFillColorMethods 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, setMarginYMethods inherited from interface com.helger.pdflayout.base.IPLHasMarginBorderPadding
getOutlineBottom, getOutlineLeft, getOutlineRight, getOutlineTop, getOutlineXSum, getOutlineYSumMethods 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, setPaddingYMethods inherited from interface com.helger.pdflayout.base.IPLObject
getAsSplittable, hasID, isVertSplittable
-
Field Details
-
DEFAULT_DIFFERENT_FIRST_PAGE_HEADER
public static final boolean DEFAULT_DIFFERENT_FIRST_PAGE_HEADER- See Also:
-
DEFAULT_DIFFERENT_FIRST_PAGE_FOOTER
public static final boolean DEFAULT_DIFFERENT_FIRST_PAGE_FOOTER- See Also:
-
-
Constructor Details
-
PLPageSet
-
PLPageSet
-
PLPageSet
-
-
Method Details
-
getPageSize
- Returns:
- The page size as specified in the constructor. Never
null. - See Also:
-
getPageWidth
public final float getPageWidth()- Returns:
- The page width as specified in the constructor. Never
null. - See Also:
-
getPageHeight
public final float getPageHeight()- Returns:
- The page height as specified in the constructor. Never
null. - See Also:
-
getMargin
- Specified by:
getMarginin interfaceIPLHasMargin<PLPageSet>- Returns:
- The current margin. Never
null.
-
setMargin
Description copied from interface:IPLHasMarginSet the margin values.- Specified by:
setMarginin interfaceIPLHasMargin<PLPageSet>- Parameters:
aMargin- Margin to use. May not benull.- Returns:
- this
-
getPadding
- Specified by:
getPaddingin interfaceIPLHasPadding<PLPageSet>- Returns:
- The current padding. Never
null.
-
setPadding
Description copied from interface:IPLHasPaddingSet the padding values.- Specified by:
setPaddingin interfaceIPLHasPadding<PLPageSet>- Parameters:
aPadding- Padding to use. May not benull.- Returns:
- this
-
getBorder
- Specified by:
getBorderin interfaceIPLHasBorder<PLPageSet>- Returns:
- The current border. Never
null.
-
setBorder
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
- Specified by:
getFillColorin interfaceIPLHasFillColor<PLPageSet>- Returns:
- The current fill color. May be
null.
-
setFillColor
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
-
setPreRenderContextCustomizer
@Nonnull public final PLPageSet setPreRenderContextCustomizer(@Nullable IPreRenderContextCustomizer aPRCCustomizer) -
getRenderContextCustomizer
-
setRenderContextCustomizer
@Nonnull public final PLPageSet setRenderContextCustomizer(@Nullable IRenderContextCustomizer aRCCustomizer) -
getAvailableWidth
- Returns:
- The usable page width without the x-paddings, x-borders and x-margins
-
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
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:
-
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
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:
-
getPageHeader
- Returns:
- The global page header. May be
null.
-
hasPageHeader
public boolean hasPageHeader()- Returns:
trueif a global page header is present,falseif not.
-
setPageHeader
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
-
forEachElement
-
addElement
Add an element to this page set.- Parameters:
aElement- The element to add. May not benull.- Returns:
- this for chaining.
-
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
- Overrides:
toStringin classAbstractPLObject<PLPageSet>
-