public class Canvas extends RootElement<Canvas>
Modifier and Type | Field and Description |
---|---|
protected PdfPage |
page
Is initialized and used only when Canvas element autotagging is enabled, see enableAutoTagging(PdfPage) .
|
protected PdfCanvas |
pdfCanvas |
protected Rectangle |
rootArea |
childElements, defaultFont, defaultFontProvider, defaultSplitCharacters, immediateFlush, pdfDocument, rootRenderer
properties
Constructor and Description |
---|
Canvas(PdfCanvas pdfCanvas, PdfDocument pdfDocument, Rectangle rootArea)
Deprecated.
use
Canvas(PdfCanvas, Rectangle) instead.
|
Canvas(PdfCanvas pdfCanvas, PdfDocument pdfDocument, Rectangle rootArea, boolean immediateFlush)
Deprecated.
use
Canvas(PdfCanvas, Rectangle, boolean) instead.
|
Canvas(PdfCanvas pdfCanvas, Rectangle rootArea)
Creates a new Canvas to manipulate a specific content stream, which might be for example a page or PdfFormXObject stream.
|
Canvas(PdfCanvas pdfCanvas, Rectangle rootArea, boolean immediateFlush)
Creates a new Canvas to manipulate a specific document and page.
|
Canvas(PdfFormXObject formXObject, PdfDocument pdfDocument)
Creates a new Canvas to manipulate a specific PdfFormXObject .
|
Canvas(PdfPage page, Rectangle rootArea)
Creates a new Canvas to manipulate a specific page content stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the Canvas .
|
void |
enableAutoTagging(PdfPage page)
Enables canvas content autotagging.
|
protected RootRenderer |
ensureRootRendererNotNull() |
void |
flush()
Forces all registered renderers (including child element renderers) to flush their contents to the content stream.
|
PdfPage |
getPage()
The page on which this canvas will be rendered.
|
PdfCanvas |
getPdfCanvas()
Gets the PdfCanvas .
|
PdfDocument |
getPdfDocument()
Gets the PdfDocument for this canvas.
|
Rectangle |
getRootArea()
Gets the root area rectangle.
|
boolean |
isAutoTaggingEnabled() |
boolean |
isCanvasOfPage()
Defines if the canvas is exactly the direct content of the page.
|
void |
relayout()
Performs an entire recalculation of the element flow on the canvas, taking into account all its current child elements.
|
void |
setRenderer(CanvasRenderer canvasRenderer)
Sets the IRenderer for this Canvas.
|
add, add, createAndAddRendererSubTree, deleteOwnProperty, getDefaultProperty, getFontProvider, getOwnProperty, getProperty, getRenderer, hasOwnProperty, hasProperty, setFontProvider, setProperty, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAlignedKerned
getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundImage, setBaseDirection, setBold, setBorder, setBorderBottom, setBorderBottomLeftRadius, setBorderBottomRightRadius, setBorderLeft, setBorderRadius, setBorderRight, setBorderTop, setBorderTopLeftRadius, setBorderTopRightRadius, setCharacterSpacing, setDestination, setFixedPosition, setFixedPosition, setFixedPosition, setFixedPosition, setFont, setFont, setFontColor, setFontColor, setFontFamily, setFontFamily, setFontKerning, setFontScript, setFontSize, setHorizontalAlignment, setHyphenation, setItalic, setLineThrough, setOpacity, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setUnderline, setWordSpacing
protected PdfCanvas pdfCanvas
protected Rectangle rootArea
protected PdfPage page
enableAutoTagging(PdfPage)
. It is also used to determine if autotagging is enabled.
public Canvas(PdfPage page, Rectangle rootArea)
Link
elements on it (using any other constructor would result in inability to add PDF annotations, based on which, for example, links work).
If the PdfDocument.isTagged()
is true, using this constructor would automatically enable the tagging for the content. Regarding tagging the effect is the same as using enableAutoTagging(PdfPage)
.
page
- the page on which this canvas will be rendered, shall not be flushed (see PdfObjectWrapper.isFlushed()
).
rootArea
- the maximum area that the Canvas may write upon
public Canvas(PdfCanvas pdfCanvas, Rectangle rootArea)
PdfFormXObject
stream.
pdfCanvas
- the low-level content stream writer
rootArea
- the maximum area that the Canvas may write upon
@Deprecated public Canvas(PdfCanvas pdfCanvas, PdfDocument pdfDocument, Rectangle rootArea)
Canvas(PdfCanvas, Rectangle)
instead.
PdfFormXObject
stream.
pdfCanvas
- the low-level content stream writer
pdfDocument
- the document that the resulting content stream will be written to
rootArea
- the maximum area that the Canvas may write upon To be removed in 7.2
public Canvas(PdfCanvas pdfCanvas, Rectangle rootArea, boolean immediateFlush)
pdfCanvas
- The low-level content stream writer
rootArea
- The maximum area that the Canvas may write upon
immediateFlush
- Whether to flush the canvas immediately after operations, false otherwise
@Deprecated public Canvas(PdfCanvas pdfCanvas, PdfDocument pdfDocument, Rectangle rootArea, boolean immediateFlush)
Canvas(PdfCanvas, Rectangle, boolean)
instead.
pdfCanvas
- The low-level content stream writer
pdfDocument
- The document that the resulting content stream will be written to
rootArea
- The maximum area that the Canvas may write upon
immediateFlush
- Whether to flush the canvas immediately after operations, false otherwise To be removed in 7.2
public Canvas(PdfFormXObject formXObject, PdfDocument pdfDocument)
PdfFormXObject
.
formXObject
- the form
pdfDocument
- the document that the resulting content stream will be written to
public PdfDocument getPdfDocument()
PdfDocument
for this canvas.
public Rectangle getRootArea()
public PdfCanvas getPdfCanvas()
PdfCanvas
.
public void setRenderer(CanvasRenderer canvasRenderer)
IRenderer
for this Canvas.
canvasRenderer
- a renderer specific for canvas operations
public PdfPage getPage()
PdfPage
instance, might be null if this the page was not set.
public void enableAutoTagging(PdfPage page)
page
- the page, on which this canvas will be rendered.
public boolean isAutoTaggingEnabled()
public boolean isCanvasOfPage()
Canvas(PdfPage, Rectangle)
constructor overload, otherwise this method returns false.
Canvas(PdfPage, Rectangle)
constructor overload.
public void relayout()
RootElement.immediateFlush
to true
.
public void flush()
public void close()
Canvas
. Although not completely necessary in all cases, it is still recommended to call this method when you are done working with Canvas
object, as due to some properties set there might be some 'hanging' elements, which are waiting other elements to be added and processed. close()
tells the Canvas
that no more elements will be added and it is time to finish processing all the elements.
protected RootRenderer ensureRootRendererNotNull()
ensureRootRendererNotNull
in class RootElement<Canvas>
Copyright © 1998–2023 iText Group NV. All rights reserved.