Table of contents
Namespace: Com\Tecnick\Pdf
abstract class HTML extends JavaScript
Extends: JavaScript
Source: src/HTML.php:282
HTML PDF class
Types
THTMLTableCell
array{
cellx: float,
cellw: float,
colindex: int,
colspan: int,
contenth: float,
valign: string,
bstyles: array<int|string, BorderStyle>,
fillstyle: ?BorderStyle,
buffer: string
}
THTMLTableRowspanCell
array{
cellx: float,
cellw: float,
colindex: int,
colspan: int,
rowtop: float,
rowsremaining: int,
usedheight: float,
contenth: float,
valign: string,
bstyles: array<int|string, BorderStyle>,
fillstyle: ?BorderStyle,
buffer: string
}
THTMLTableState
array{
originx: float,
originy: float,
captiontopy: float,
width: float,
dir: string,
cols: int,
colwidth: float,
colwidths: array<int, float>,
cellspacingh: float,
cellspacingv: float,
cellpadding: float,
collapse: bool,
hascellborders: bool,
prevrowbottom: array<int, BorderStyle>,
rowtop: float,
rowheight: float,
minheight: float,
domkey: int,
colindex: int,
cells: array<int, THTMLTableCell>,
occupied: array<int, int>,
rowspans: array<int, THTMLTableRowspanCell>,
regionoffset: float
}
THTMLTableCellContext
array{
originx: float,
originy: float,
maxwidth: float,
maxheight: float,
lineadvance: float,
linebottom: float,
lineascent: float,
linewordspacing: float,
linewrapped: bool,
rowtop: float,
cellx: float,
cellw: float,
colindex: int,
colspan: int,
padding: array{'T': float, 'R': float, 'B': float, 'L': float},
margin: array{'T': float, 'R': float, 'B': float, 'L': float},
bstyles: array<int|string, BorderStyle>,
fillstyle: ?BorderStyle,
rowspan: int,
valign: string,
buffer: string
}
THTMLAttrib
array{
'align': bool|float|string,
'attribute': array<string, string|array<string, mixed>>,
'caption-top-html'?: string,
'caption-bottom-html'?: string,
'caption-side': string,
'bgcolor': bool|float|string,
'block': bool,
'border-collapse': string,
'border-spacing'?: TCSSBorderSpacing,
'border': array<string, BorderStyle>,
'clip': bool,
'cols': int,
'content': string,
'cssdata': array<string, TCSSData>,
'csssel': array<string>,
'clear': string,
'dir': string,
'display': string,
'empty-cells': string,
'elkey': int,
'fgcolor': string,
'fill': bool,
'font-size-adjust': float|string,
'font-stretch': float,
'font-variant': string,
'fontname': string,
'fontsize': float,
'fontstyle': string,
'height': float,
'hide': bool,
'letter-spacing': float,
'line-height': float,
'line-height-absolute'?: float,
'line-height-font-size-basis'?: bool,
'list-style-position': string,
'listtype': string,
'listtypeset': bool,
'float': string,
'margin': array<string, float>,
'opening': bool,
'orphans': int,
'overflow-wrap'?: string,
'page': string,
'padding': array<string, float>,
'parent': int,
'pendingcellpadding'?: float,
'pendingcellspacingh'?: float,
'pendingcellspacingv'?: float,
'pendingcolwidths'?: array<int, float>,
'position': string,
'quotes': string,
'rows': int,
'self': bool,
'stroke': float,
'strokecolor': string,
'childblockbottom'?: float,
'ctxoriginx'?: float,
'ctxmaxwidth'?: float,
'ctxregionoffset'?: float,
'inlineblocknextx'?: float,
'inlineblockrowy'?: float,
'inlineblockpageid'?: int,
'table-layout': string,
'style': array<string, string>,
'list-style-image'?: string,
'tag': bool,
'text-indent': float,
'text-transform': string,
'thead': string,
'trids': array<int>,
'valign': string,
'value': string,
'white-space': string,
'widows': int,
'word-break'?: string,
'word-spacing': float,
'width': float,
'x': float,
'y': float,
}
THTMLBlockBuf
array{
openkey: int,
bx: float,
by: float,
bw: float,
buffer: string,
celldepth: int,
decorate: bool
}
THTMLRenderContext
array{
'cellctx': array{
originx: float,
originy: float,
lineoriginx: float,
maxwidth: float,
maxheight: float,
floatrowleftw: float,
floatrowrightw: float,
floatrowtop: float,
floatrowbottom: float,
lineadvance: float,
linebottom: float,
lineascent: float,
lineascentnolookahead: bool,
linewordspacing: float,
linewrapped: bool,
textindentapplied: bool,
firstlineinset: float,
pendingblockmarginb: float,
activepage?: string,
regionoffset?: float,
basefont: string
},
'currentkey'?: int,
'fontcache': array<string, array<string, mixed>>,
'liststack': array<int, array{
type: string,
count: int,
indent: float
}>,
'tablestack': array<int, THTMLTableState>,
'bcellctx': array<int, THTMLTableCellContext>,
'blockbuf': array<int, THTMLBlockBuf>,
'linkstack': array<int, string>,
'listack': array<int, array{
originx: float,
maxwidth: float
}>,
'prelevel': int,
'quotelevel': int,
'dom': array<int, THTMLAttrib>,
}
THTMLRtlPiece
array{
key: int,
text: string,
image: bool,
src: string,
width: float,
height: float,
valign: string
}
THTMLRtlSegment
array{
key: int,
text: string,
width: float,
ascent: float,
image: bool,
height: float,
valign: string,
src: string
}
Methods
addHTMLCell()
Adds an HTML block inside a rectangular cell.
Accounts for automatic page and region breaks while appending page-specific content directly to each affected page stream.
public addHTMLCell(
string $html,
float $posx = 0,
float $posy = 0,
float $width = 0,
float $height = 0,
?TCellDef $cell = null,
array<int|string,BorderStyle> $styles = []
): void
Parameters:
$html(string): HTML code to be processed.$posx(float): Abscissa of upper-left corner.$posy(float): Ordinate of upper-left corner.$width(float): Width.$height(float): Height.$cell(?TCellDef): Optional to overwrite cell parameters for padding, margin etc. The margin and padding values are in points.$styles(array<int|string,BorderStyle>): Cell border styles (see: getCurrentStyleArray).
Throws:
Source: src/HTML.php:15916
getHTMLCell()
Returns the PDF code to render an HTML block inside a rectangular cell.
public getHTMLCell(
string $html,
float $posx = 0,
float $posy = 0,
float $width = 0,
float $height = 0,
?TCellDef $cell = null,
array<int|string,BorderStyle> $styles = []
): string
Parameters:
$html(string): HTML code to be processed.$posx(float): Abscissa of upper-left corner.$posy(float): Ordinate of upper-left corner.$width(float): Width.$height(float): Height.$cell(?TCellDef): Optional to overwrite cell parameters for padding, margin etc. The margin and padding values are in points.$styles(array<int|string,BorderStyle>): Cell border styles (see: getCurrentStyleArray).
Returns: string
Throws:
Source: src/HTML.php:15821
getHTMLDOMCSSData()
Returns the styles array that apply for the selected HTML tag.
public getHTMLDOMCSSData(
array<int,THTMLAttrib> &$dom,
array<string,string> $css,
int $key
): void
Parameters:
$dom(array<int,THTMLAttrib>)$css(array<string,string>)$key(int): Key of the current HTML tag.
Source: src/HTML.php:1863
isValidCSSSelectorForTag()
Returns true if the CSS selector is valid for the selected HTML tag.
public isValidCSSSelectorForTag(array<int,THTMLAttrib> &$dom, int $key, string $selector): bool
Parameters:
$dom(array<int,THTMLAttrib>)$key(int): key of the current HTML tag$selector(string): CSS selector string
Returns: bool: True if the selector is valid, false otherwise
Source: src/HTML.php:2047
parseHTMLAttributes()
Parst HTML DOM attributes.
public parseHTMLAttributes(array<int,THTMLAttrib> &$dom, int $key, bool $thead): void
Parameters:
$dom(array<int,THTMLAttrib>)$key(int): key of the current HTML tag.$thead(bool)
Throws:
Source: src/HTML.php:6069
parseHTMLStyleAttributes()
Parse HTML DOM Style attributes.
public parseHTMLStyleAttributes(array<int,THTMLAttrib> &$dom, int $key, int $parentkey): void
Parameters:
$dom(array<int,THTMLAttrib>)$key(int): key of the current HTML tag.$parentkey(int): Key of the parent element.
Throws:
Source: src/HTML.php:2772
setHtmlImageImportResize()
Enable or disable HTML raster image downscaling on import.
When enabled, raster images rendered smaller than their intrinsic size are imported at a reduced pixel size before placement.
public setHtmlImageImportResize(bool $enabled): void
Parameters:
$enabled(bool)
Source: src/HTML.php:12756
setHTMLMonospaceFont()
Set the monospaced font used for <pre>, <code> and <tt> elements.
PDF/UA requires every font to be embedded and the default Courier is a non-embedded standard-14 font, so an embedded monospace font must be set (after inserting it with the font stack) for tagged or accessible PDFs.
public setHTMLMonospaceFont(string $fontname): void
Parameters:
$fontname(string)
Source: src/HTML.php:6376
setHtmlVSpace()
Set custom vertical spacing for HTML block tags.
Each tag entry has two positions: [0] = space added before the opening tag (top margin) [1] = space added after the closing tag (bottom margin)
Each position is an array with optional keys: ‘h’ => float (fixed height in user units) ’n’ => int (number of line-heights to add)
Example: $pdf->setHtmlVSpace([‘p’ => [[‘h’ => 0, ’n’ => 1], [‘h’ => 0, ’n’ => 0]]]);
public setHtmlVSpace(array<string,array<int,array{h?: float|int, n?: int}>> $tagvs): void
Parameters:
$tagvs(array<string,array<int,array{h?: float|int, n?: int}>>)
Source: src/HTML.php:12745
setULLIDot()
Sets the default symbol to be used as unordered-list (UL) list-item (LI) bullet.
public setULLIDot(string $sym = '!'): void
Parameters:
$sym(string): This can be one of the values in self::LIST_SYMBOL or an image specified as:‘img|type|width|height|image.ext’).
Source: src/HTML.php:6886
strTrim()
Trim the input string.
public strTrim(string $str, string $replace = ''): string
Parameters:
$str(string): string to trim.$replace(string): string that replace spaces.
Returns: string: trimmed string.
Source: src/HTML.php:836
strTrimLeft()
Left trim the input string.
public strTrimLeft(string $str, string $replace = ''): string
Parameters:
$str(string): string to trim.$replace(string): string that replace spaces.
Returns: string: left trimmed string.
Source: src/HTML.php:810
strTrimRight()
Right trim the input string.
public strTrimRight(string $str, string $replace = ''): string
Parameters:
$str(string): string to trim.$replace(string): string that replace spaces.
Returns: string: right trimmed string.
Source: src/HTML.php:823
tidyHTML()
Cleanup HTML code (requires HTML Tidy library).
public tidyHTML(string $html, string $defcss): string
Parameters:
$html(string): htmlcode to fix.$defcss(string): CSS to add.
Returns: string: XHTML code cleaned up.
Throws:
- Exception: If Tidy cannot parse the input HTML.
Source: src/HTML.php:753
Inherited members
From Base
- BORDERPOS_DEFAULT: The default relative position of the cell origin when the border is centered on the cell edge.
- BORDERPOS_EXTERNAL: The relative position of the cell origin when the border is external to the cell edge.
- BORDERPOS_INTERNAL: The relative position of the cell origin when the border is internal to the cell edge.
- ZEROCELL: Default values for cell.
- ZEROCELLBOUND: Default values for cell boundaries.
- $barcode: Barcode object.
- $cache: Cache object.
- $color: Color object.
- $encrypt: Encrypt object.
- $file: File object.
- $font: Font object.
- $graph: Graph object.
- $image: Image Import object.
- $markupFile: File object for markup-originated resources.
- $page: Page object.
- $pon: Current PDF object number.
- $uniconv: Unicode Convert object.
- defaultFileAllowedPaths(): Returns the default array of allowed file paths.
- defaultMarkupAllowedPaths(): Returns the default array of allowed file paths for markup-originated resources.
- enableDefaultPageContent(): Enable or disable the default page content.
- getWarnings(): Return the conformance warnings raised while the document was rendered.
- initClassObjects(): Initialize dependencies class objects.
- setPDFVersion(): Set the PDF version (check PDF reference for valid values).
- setRTL(): Set the default document language direction.
- toPoints(): Convert user units to internal points unit.
- toUnit(): Convert internal points to user unit.
- toYPoints(): Convert vertical user value to internal points unit.
- toYUnit(): Convert vertical internal points value to user unit.
From Cell
- setDefaultCellBorderPos(): Sets the default cell border position.
- setDefaultCellMargin(): Set the default cell margin in user units.
- setDefaultCellPadding(): Set the default cell padding in user units.
From CSS
- addGlobalCSS(): Append CSS content to the global CSS applied as a base stylesheet to all HTML rendering calls.
- resetGlobalCSS(): Reset (clear) the global CSS so no base stylesheet is applied to HTML rendering calls.
- setDefaultCSSBorderSpacing(): Set the default CSS border spacing in user units.
- setDefaultCSSMargin(): Set the default CSS margin in user units.
- setDefaultCSSPadding(): Set the default CSS padding in user units.
- setGlobalCSS(): Set the global CSS content applied as a base stylesheet to all HTML rendering calls.
From JavaScript
- addContentAsEmbeddedFile(): Add string content as an embedded file.
- addEmbeddedFile(): Add an embedded file.
- addFFButton(): Adds an annotation button form field.
- addFFCheckBox(): Adds an annotation checkbox form field.
- addFFComboBox(): Adds an annotation combobox (select) form field.
- addFFListBox(): Adds an annotation listbox (select) form field.
- addFFRadioButton(): Adds an annotation radiobutton form field.
- addFFText(): Adds an annotation text form field.
- addInternalLink(): Defines the page and vertical position an internal link points to.
- addJSButton(): Adds a JavaScript button form field.
- addJSCheckBox(): Adds a JavaScript checkbox form field.
- addJSComboBox(): Adds a JavaScript combobox (select) form field.
- addJSListBox(): Adds a JavaScript listbox (select) form field.
- addJSRadioButton(): Adds a JavaScript radiobutton form field.
- addJSText(): Adds a JavaScript text form field.
- addRawJavaScriptObj(): Add a raw javascript string as new object.
- addXObjectContent(): Add the specified raw PDF content to the XObject template.
- addXObjectExtGStateID(): Add the specified ExtGState ID to the XObject template.
- addXObjectFontID(): Add the specified Font ID to the XObject template.
- addXObjectGradientID(): Add the specified Gradient ID to the XObject template.
- addXObjectImageID(): Add the specified Image ID to the XObject template.
- addXObjectSpotColorID(): Add the specified SpotColor ID to the XObject template.
- addXObjectXObjectID(): Add the specified XObject ID to the XObject template.
- appendRawJavaScript(): Append raw javascript string to the global one.
- exitXObjectTemplate(): Exit from the XObject template mode.
- getDefJSAnnotProp(): Returns the default Javascript Annotation properties.
- getXObjectTemplate(): Returns the PDF code to render the specified XObject template.
- newXObjectTemplate(): Create a new XObject template and return the object id.
- setAnnotation(): Add an annotation and returns the object id.
- setBookmark(): Add a bookmark entry.
- setDefJSAnnotProp(): Set the default Javascript Annotation properties.
- setLink(): Creates a link in the specified area.
- setNamedDestination(): Add a named destination.
From SVG
- addSVG(): Add a new SVG image and return its object ID.
- getSetSVG(): Get the PDF output string to print the specified SVG object.
From Text
- addArtifactContent(): Add non-semantic content wrapped as Artifact marked-content.
- addPage(): Add a new page (wrapper function for $this->page->add()).
- addTaggedFigureContent(): Add non-text graphical content as a tagged Figure block in PDF/UA mode.
- addTextCell(): Adds a text block inside a rectangular cell using relative coordinates.
- addTextCellXY(): Adds a text block inside a rectangular cell using absolute page coordinates.
- beginArtifact(): Open an Artifact marked-content block for non-semantic page content.
- beginStructElem(): Open a PDF/UA structure element bracket.
- defaultPageContent(): Sets the page common content like Header and Footer.
- enableZeroWidthBreakPoints(): Enable or disable automatic line breaking points after some non-letter character types.
- endArtifact(): Close an Artifact marked-content block opened by beginArtifact().
- endStructElem(): Close the current PDF/UA structure element bracket.
- getLastBBox(): Returns the last text fragment bounding box as {x, y, w, h} (left, top, width, height).
- getLastCellBBox(): Returns the last Cell bounding box as {x, y, w, h} (left, top, width, height).
- getLastTextBBox(): Returns the last Text bounding box as {x, y, w, h} (left, top, width, height).
- getTextCell(): Returns the PDF code to render a text block inside a rectangular cell.
- getTextLine(): Returns the PDF code to render a single line of text.
- loadTexHyphenPatterns(): Returns an array of hyphenation patterns.
- resumePdfUaTagging(): Resume structure tagging, restoring the mode returned by suspendPdfUaTagging().
- setCurrentPage(): Set the current page number (move to the specified page).
- setTexHyphenPatterns(): Sets the hyphen patterns for text.
- suspendPdfUaTagging(): Suspend structure tagging and marked-content recording.