Parser
in package
Pdf HTML parser class
Tags
Table of Contents
Properties
- $css : Css|null
- CSS object
- $defaultStyles : array<string|int, mixed>
- Default styles
- $document : Document
- PDF document
- $fileDir : string|null
- HTML file directory
- $html : Child|array<string|int, mixed>|null
- HTML object or array of HTML objects
- $page : Page|null
- Current page object
- $pageMargins : array<string|int, mixed>
- Page margins
- $pageSize : string|array<string|int, mixed>
- Page size
- $textWrap : Wrap|null
- Text wrap object
- $x : int
- Current x-position
- $y : int
- Current y-position
- $yOverride : int|null
- Y-override
Methods
- __construct() : mixed
- Constructor
- document() : Document
- Get document (alias)
- drawBox() : void
- Draw a background-filled and/or bordered box
- getCss() : Css|null
- Get styles
- getCurrentY() : int
- Get current Y-position
- getDefaultStyle() : string|null
- Get a default style
- getDefaultStyles() : array<string|int, mixed>
- Get default styles
- getDocument() : Document
- Get document
- getHtml() : array<string|int, mixed>|Child|null
- Get HTML nodes
- getPage() : Page|null
- Get the current page
- getPageBottomMargin() : int
- Get page bottom margin
- getPageLeftMargin() : int
- Get page left margin
- getPageMargins() : array<string|int, mixed>
- Get page margins
- getPageRightMargin() : int
- Get page right margin
- getPageSize() : string|array<string|int, mixed>
- Get page size
- getPageTopMargin() : int
- Get page top margin
- getStringLines() : array<string|int, mixed>
- Get string lines
- getX() : int
- Get x-position
- getY() : int
- Get y-position
- newPage() : int
- Create new page
- parseCss() : Parser
- Parse CSS string
- parseCssFile() : Parser
- Parse CSS file
- parseCssUri() : Parser
- Parse CSS URI
- parseFile() : Parser
- Parse $html from file
- parseHtml() : Parser
- Parse HTML string
- parseHtmlFile() : Parser
- Parse HTML string from file
- parseHtmlUri() : Parser
- Parse HTML string from URI
- parseString() : Parser
- Parse HTML string
- parseUri() : Parser
- Parse $html from URI
- prepare() : array<string|int, mixed>|Child|null
- Prepare for conversion of HTML into PDF objects
- prepareNodeStyles() : array<string|int, mixed>
- Prepare node styles
- process() : Document
- Process conversion of HTML into PDF objects
- setDefaultStyle() : Parser
- Set a default style
- setDocument() : Parser
- Set document
- setPageBottomMargin() : Parser
- Set page bottom margin
- setPageLeftMargin() : Parser
- Set page left margin
- setPageMargins() : Parser
- Set page margins
- setPageRightMargin() : Parser
- Set page right margin
- setPageSize() : Parser
- Set page size
- setPageTopMargin() : Parser
- Set page top margin
- setX() : Parser
- Set x-position
- setY() : Parser
- Set y-position
- setYOverride() : Parser
- Set the y-position override for the next node (mirrors the mechanism already used internally for multi-page paragraph overflow)
- addNodeToDocument() : void
- Add node to document
- createDefaultStyles() : void
- Create default styles
- getCurrentX() : int
- Get current X-position
- parseCssColorToRgbArray() : array<string|int, mixed>
- Parse a CSS color string into an RGB array, tolerating a value that Color::parse() already resolves to Color\Rgb (which has no toRgb() method to convert from itself)
- resetY() : int
- Reset Y-position
- toRgbColor() : Rgb
- Normalize any Color\ColorInterface value to Color\Rgb
Properties
$css
CSS object
protected
Css|null
$css
= null
$defaultStyles
Default styles
protected
array<string|int, mixed>
$defaultStyles
= ['font-family' => 'Arial', 'font-size' => 10, 'font-weight' => 'normal', 'color' => [0, 0, 0], 'line-height' => 14]
$document
PDF document
protected
Document
$document
$fileDir
HTML file directory
protected
string|null
$fileDir
= null
$html
HTML object or array of HTML objects
protected
Child|array<string|int, mixed>|null
$html
= null
$page
Current page object
protected
Page|null
$page
= null
$pageMargins
Page margins
protected
array<string|int, mixed>
$pageMargins
= ['top' => 80, 'right' => 60, 'bottom' => 60, 'left' => 60]
$pageSize
Page size
protected
string|array<string|int, mixed>
$pageSize
= 'LETTER'
$textWrap
Text wrap object
protected
Wrap|null
$textWrap
= null
$x
Current x-position
protected
int
$x
= 0
$y
Current y-position
protected
int
$y
= 0
$yOverride
Y-override
protected
int|null
$yOverride
= null
Methods
__construct()
Constructor
public
__construct([Document $document = new Document() ]) : mixed
Instantiate the HTML parser object
Parameters
- $document : Document = new Document()
document()
Get document (alias)
public
document() : Document
Return values
DocumentdrawBox()
Draw a background-filled and/or bordered box
public
drawBox(float $x, float $topY, float $width, float $height, array<string|int, mixed> $styles) : void
Parameters
- $x : float
- $topY : float
- $width : float
- $height : float
- $styles : array<string|int, mixed>
getCss()
Get styles
public
getCss() : Css|null
Return values
Css|nullgetCurrentY()
Get current Y-position
public
getCurrentY([int $marginBottom = 0 ]) : int
Parameters
- $marginBottom : int = 0
Return values
intgetDefaultStyle()
Get a default style
public
getDefaultStyle(string $property) : string|null
Parameters
- $property : string
Return values
string|nullgetDefaultStyles()
Get default styles
public
getDefaultStyles() : array<string|int, mixed>
Return values
array<string|int, mixed>getDocument()
Get document
public
getDocument() : Document
Return values
DocumentgetHtml()
Get HTML nodes
public
getHtml() : array<string|int, mixed>|Child|null
Return values
array<string|int, mixed>|Child|nullgetPage()
Get the current page
public
getPage() : Page|null
Return values
Page|nullgetPageBottomMargin()
Get page bottom margin
public
getPageBottomMargin() : int
Return values
intgetPageLeftMargin()
Get page left margin
public
getPageLeftMargin() : int
Return values
intgetPageMargins()
Get page margins
public
getPageMargins() : array<string|int, mixed>
Return values
array<string|int, mixed>getPageRightMargin()
Get page right margin
public
getPageRightMargin() : int
Return values
intgetPageSize()
Get page size
public
getPageSize() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>getPageTopMargin()
Get page top margin
public
getPageTopMargin() : int
Return values
intgetStringLines()
Get string lines
public
getStringLines(string $string, int $fontSize, int $wrapLength, Font $fontObject) : array<string|int, mixed>
Parameters
- $string : string
- $fontSize : int
- $wrapLength : int
- $fontObject : Font
Return values
array<string|int, mixed>getX()
Get x-position
public
getX() : int
Return values
intgetY()
Get y-position
public
getY() : int
Return values
intnewPage()
Create new page
public
newPage() : int
Return values
intparseCss()
Parse CSS string
public
parseCss(string $cssString) : Parser
Parameters
- $cssString : string
Return values
ParserparseCssFile()
Parse CSS file
public
parseCssFile(string $cssFile) : Parser
Parameters
- $cssFile : string
Tags
Return values
ParserparseCssUri()
Parse CSS URI
public
parseCssUri(string $cssUri) : Parser
Parameters
- $cssUri : string
Return values
ParserparseFile()
Parse $html from file
public
static parseFile(string $htmlFile[, Document $document = new Document() ]) : Parser
Parameters
- $htmlFile : string
- $document : Document = new Document()
Tags
Return values
ParserparseHtml()
Parse HTML string
public
parseHtml(string $htmlString[, string|null $basePath = null ]) : Parser
Parameters
- $htmlString : string
- $basePath : string|null = null
Return values
ParserparseHtmlFile()
Parse HTML string from file
public
parseHtmlFile(string $htmlFile) : Parser
Parameters
- $htmlFile : string
Tags
Return values
ParserparseHtmlUri()
Parse HTML string from URI
public
parseHtmlUri(string $htmlUri) : Parser
Parameters
- $htmlUri : string
Return values
ParserparseString()
Parse HTML string
public
static parseString(string $htmlString[, Document $document = new Document() ]) : Parser
Parameters
- $htmlString : string
- $document : Document = new Document()
Return values
ParserparseUri()
Parse $html from URI
public
static parseUri(string $htmlUri[, Document $document = new Document() ]) : Parser
Parameters
- $htmlUri : string
- $document : Document = new Document()
Return values
Parserprepare()
Prepare for conversion of HTML into PDF objects
public
prepare() : array<string|int, mixed>|Child|null
Return values
array<string|int, mixed>|Child|nullprepareNodeStyles()
Prepare node styles
public
prepareNodeStyles(string $name[, array<string|int, mixed> $attribs = [] ][, array<string|int, mixed> $currentStyles = [] ]) : array<string|int, mixed>
Parameters
- $name : string
- $attribs : array<string|int, mixed> = []
- $currentStyles : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed>process()
Process conversion of HTML into PDF objects
public
process() : Document
Tags
Return values
DocumentsetDefaultStyle()
Set a default style
public
setDefaultStyle(string $property, string $value) : Parser
Parameters
- $property : string
- $value : string
Return values
ParsersetDocument()
Set document
public
setDocument(Document $document) : Parser
Parameters
- $document : Document
Return values
ParsersetPageBottomMargin()
Set page bottom margin
public
setPageBottomMargin(int $margin) : Parser
Parameters
- $margin : int
Return values
ParsersetPageLeftMargin()
Set page left margin
public
setPageLeftMargin(int $margin) : Parser
Parameters
- $margin : int
Return values
ParsersetPageMargins()
Set page margins
public
setPageMargins(int $top, int $right, int $bottom, int $left) : Parser
Parameters
- $top : int
- $right : int
- $bottom : int
- $left : int
Return values
ParsersetPageRightMargin()
Set page right margin
public
setPageRightMargin(int $margin) : Parser
Parameters
- $margin : int
Return values
ParsersetPageSize()
Set page size
public
setPageSize(mixed $size[, mixed $height = null ]) : Parser
Parameters
- $size : mixed
- $height : mixed = null
Return values
ParsersetPageTopMargin()
Set page top margin
public
setPageTopMargin(int $margin) : Parser
Parameters
- $margin : int
Return values
ParsersetX()
Set x-position
public
setX(int $x) : Parser
Parameters
- $x : int
Return values
ParsersetY()
Set y-position
public
setY(int $y) : Parser
Parameters
- $y : int
Return values
ParsersetYOverride()
Set the y-position override for the next node (mirrors the mechanism already used internally for multi-page paragraph overflow)
public
setYOverride(int|null $y) : Parser
Parameters
- $y : int|null
Return values
ParseraddNodeToDocument()
Add node to document
protected
addNodeToDocument(Child $child[, int $i = 0 ]) : void
Parameters
- $child : Child
- $i : int = 0
Tags
createDefaultStyles()
Create default styles
protected
createDefaultStyles() : void
getCurrentX()
Get current X-position
protected
getCurrentX() : int
Return values
intparseCssColorToRgbArray()
Parse a CSS color string into an RGB array, tolerating a value that Color::parse() already resolves to Color\Rgb (which has no toRgb() method to convert from itself)
protected
parseCssColorToRgbArray(string $colorString) : array<string|int, mixed>
Parameters
- $colorString : string
Return values
array<string|int, mixed>resetY()
Reset Y-position
protected
resetY() : int
Return values
inttoRgbColor()
Normalize any Color\ColorInterface value to Color\Rgb
protected
toRgbColor(ColorInterface $color) : Rgb
ColorInterface doesn't declare toRgb() (Color\Rgb has no such method to convert from itself), so every other concrete color type it might resolve to is matched explicitly here.
Parameters
- $color : ColorInterface