SetaPDF_Stamper_Stamp_RichText The rich-text stamp class
File: /SetaPDF v2/Stamper/Stamp/RichText.php
With the stamp class you can add rich-text to an existing PDF document.
The text can be created by a subset of HTML and CSS style attributes.
Internally the class uses a SetaPDF_Core_Text_RichTextBlock
object. Most methods of this class are proxy
methods to the RichTextBlock
instance.
Class hierarchy
Summary
Methods
- __construct()
- _cacheStampData()
- _ensureResources()
- _getOpacityGraphicState()
- _getVisibilityGroup()
- _postStamp()
- _preStamp()
- _putAction()
- _stamp()
- _stampByCache()
- getAction()
- getAlign()
- getBackgroundColor()
- getBorderColor()
- getBorderWidth()
- getDefaultFontFamily()
- getDefaultFontSize()
- getDefaultLineHeight()
- getDefaultTextColor()
- getDimensions()
- getHeight()
- getOpacity()
- getOpacityBlendMode()
- getOptionalContentGroup()
- getOriginX()
- getOriginY()
- getPaddingBottom()
- getPaddingLeft()
- getPaddingRight()
- getPaddingTop()
- getRichTextBlock()
- getText()
- getTextWidth()
- getVisibility()
- getWidth()
- setAction()
- setAlign()
- setBackgroundColor()
- setBorderColor()
- setBorderWidth()
- setDefaultFontFamily()
- setDefaultFontSize()
- setDefaultLineHeight()
- setDefaultTextColor()
- setLink()
- setOpacity()
- setOptionalContentGroup()
- setPadding()
- setPaddingBottom()
- setPaddingLeft()
- setPaddingRight()
- setPaddingTop()
- setText()
- setTextWidth()
- setVisibility()
- stamp()
- updateCacheCounter()
Constants
VISIBILITY_ALL
Visibility constant
VISIBILITY_PRINT
Visibility constant
VISIBILITY_VIEW
Visibility constant
Properties
$_dataCache
$_opacityGs
Graphic state objects for handling transparency
Array of SetaPDF_Core_Resource_ExtGState
objects
Methods
__construct()
The constructor.
Parameters
- $document : SetaPDF_Core_Document
- $fontLoader : callable
_cacheStampData()
Caches a content stream part.
Parameters
- $cacheKey : string
- $stream : string
- $quadPoints : array
_ensureResources()
Ensures that all stamp resources are added to the page.
This is needed to reuse a cached stamp stream.
Parameters
- $document : SetaPDF_Core_Document
- $page : SetaPDF_Core_Document_Page
Return Values
An array of resource names
See
_getOpacityGraphicState()
Get and caches opacity graphic states.
Parameters
- $document : SetaPDF_Core_Document
- $opacity : float
_getVisibilityGroup()
Get and adds the visibility group of this stamp to a document.
Parameters
- $document : SetaPDF_Core_Document
_postStamp()
Method which is called after the main stamp method is executed.
Parameters
- $document : SetaPDF_Core_Document
- $page : SetaPDF_Core_Document_Page
- $stampData : array
_preStamp()
Method which is called before the main stamp method is executed.
Parameters
- $document : SetaPDF_Core_Document
- $page : SetaPDF_Core_Document_Page
- $stampData : array
_putAction()
Put the action via an link annotation above the stamp object.
Parameters
- $document : SetaPDF_Core_Document
- $page : SetaPDF_Core_Document_Page
- $stampData : array
- $xy1 : number
- $xy2 : number
- $xy3 : number
- $xy4 : number
_stamp()
Writes the content of this stamp onto the page canvas.
Parameters
- $document : SetaPDF_Core_Document
- $page : SetaPDF_Core_Document_Page
- $stampData : array
Exceptions
Throws SetaPDF_Core_Exception
Throws SetaPDF_Core_Font_Exception
Throws SetaPDF_Core_Type_Exception
_stampByCache()
Parameters
- $document : SetaPDF_Core_Document
- $page : SetaPDF_Core_Document_Page
- $stampData : array
Exceptions
Throws SetaPDF_Core_Exception
Throws SetaPDF_Stamper_Exception
getDefaultTextColor()
See
getHeight()
Get the height of this stamp.
Proxy method to SetaPDF_Core_Text_RichTextBlock::getHeight()
of the rich-text block instance.
Exceptions
Throws SetaPDF_Core_Exception
See
getOptionalContentGroup()
Get the optional content group for this stamp.
getOriginX()
Get the x-origin in view to the position of the stamp object.
Parameters
- $page : SetaPDF_Core_Document_Page
The page instance
- $position : string
Position constant
SetaPDF_Stamper::POSITION_XXX
getOriginY()
Get the y-origin in view to the position of the stamp object.
Parameters
- $page : SetaPDF_Core_Document_Page
The page instance
- $position : string
Position constant
SetaPDF_Stamper::POSITION_XXX
getRichTextBlock()
Access the rich-text block instance.
IF YOU MAKE CHANGES OUTSIDE THE STAMP CLASS, MAKE SURE THAT YOU CALL {updateCacheCounter()} AFTERWARDS.
getTextWidth()
Returns the width of the rich-text stamp without padding.
Exceptions
Throws SetaPDF_Core_Exception
See
getWidth()
Get the width of this stamp.
Proxy method to SetaPDF_Core_Text_RichTextBlock::getWidth()
of the rich-text block instance.
Exceptions
Throws SetaPDF_Core_Exception
See
setAction()
Add an action object to the stamp object.
Parameters
- $action : SetaPDF_Core_Document_Action
The action object
setBackgroundColor()
Set the background color.
Parameters
- $color : SetaPDF_Core_DataStructure_Color|int|float|string|array|SetaPDF_Core_Type_Array
See
setBorderColor()
Set the border color.
Parameters
- $color : SetaPDF_Core_DataStructure_Color|int|float|string|array|SetaPDF_Core_Type_Array
See
setDefaultLineHeight()
Parameters
- $lineHeight : int|float
Only unitless line-heights are supported here like 1 or 1.4
setDefaultTextColor()
Parameters
- $color : int|float|string|array|SetaPDF_Core_Type_Array|SetaPDF_Core_DataStructure_Color
See
setOpacity()
Set the opacity and blend mode of the stamp object.
Parameters
- $alpha : float
A value between 0 and 1, whereas 1 is defined as 100% opacity
- $blendMode : string
A blend mode defined in PDF 32000-1:2008 - 11.3.5, "Blend Mode"
Exceptions
Throws InvalidArgumentException
setOptionalContentGroup()
Set the optional content group for this stamp.
Parameters
- $optionalContentGroup : SetaPDF_Core_Document_OptionalContent_Group|null
setText()
Parameters
- $text : string
A UTF-8 string with a subset of HTML tags and CSS properties in style-parameter.
- $locale : string
INTL locale used for the break behaviour
See
setTextWidth()
Set the width of the text in the rich-text stamp. Padding is not included in this width.
Parameters
- $width : int|float
See
setVisibility()
Set the visibility of the stamp object.
This method controls the visibility of the stamp object on screen view and/or printer output.
Parameters
- $visibility : null|string
Use the constants VISIBILITY_XXX or null(equal to VISIBILITY_ALL)
Exceptions
Throws InvalidArgumentException
stamp()
Stamp this stamp object onto a page.
Parameters
- $document : SetaPDF_Core_Document
The document object
- $page : SetaPDF_Core_Document_Page
The page object
- $stampData : array
The stampData array