RTF
Table of Contents
Constants
- BLOCKINDENT : mixed = 720
- BORDERCEILING : mixed = 75
- CELL_DEFAULTS : mixed = [ 'BorderStyle' => 's', // Solid 'BorderWidth'...
- CELL_EMPTY : mixed = '\intbl' . LF . '{}' . LF . '\cell\pard' . LF . LF
- CELL_STUB : mixed = [ 'Border' => 'clbrdr', // Begin cell border de...
- CELL_USETABLEBORDER : mixed = 'brdrtbl'
- CELL_VALIGN : mixed = ['top' => 't', 'middle' => 'c', 'bottom' => 'b']
- CELL_VERTICALMERGE : mixed = ['start' => 'clvmgf', 'continue' => 'clvmrg']
- CELLBORDER_STYLES : mixed = [ // We only use those available in tinyMCE. I'...
- CELLPADDING : mixed = 'clpad'
- CELLPADDING_DEFAULT : mixed = 55
- CELLPADDING_UNIT : mixed = 'clpadf'
- CELLWIDTH_DEFAULT : mixed = 300
- COLOUR_NAMES : mixed = ["aliceblue" => "F0F8FF", "antiquewhite" => "FA...
- COLOURS : mixed = [ '\red0\green0\blue0', // Black (text by defau...
- DOCDEFAULTS : mixed = "\\f1\\fs24\n\\s1\\cf1\\ql\\li1\\fi1"
- FONTS : mixed = ["andale mono", "arial", "arial black", "book a...
- FONTSIZES : mixed = ['xx-small' => 16, 'x-small' => 20, 'small' =>...
- HTMLTOARRAYKEY : mixed = [ // Translate some HTML attributes to keys use...
- IGNOREDTAGS : mixed = [ // Document metadata "base", "head", "link",...
- INDENT : mixed = 18
- INDENTS : mixed = ['indentNone' => '', 'indentAll' => '\li' . BLO...
- JUSTIFY : mixed = ['center' => 'c', 'left' => 'l', 'right' => 'r'...
- LINESPACINGS : mixed = ['singleSpace' => '\sl240\slmult1', 'oneSixthSp...
- LINESPACINGSNUM : mixed = ['1' => '\sl240\slmult1', '1.15' => '\sl276\slm...
- LISTBULLETS : mixed = ['bullet', 'circle', 'square']
- LISTBULLETS_RTF : mixed = ['\ls1\fi-360\li', '\ls2\fi-360\li', '\ls3\fi-3...
- LISTINDENT : mixed = 720
- LISTINDENT_EXTRA : mixed = 360
- LISTORDERS : mixed = ['arabic', 'lower-alpha', 'lower-roman']
- LISTORDERS_RTF : mixed = ['0', '4', '2']
- LISTTYPES : mixed = ['aa' => '\ls5\fi-360', 'a' => '\ls0\fi-360', '...
- PAPERSIZES : mixed = ['A4' => '\paperh16838\paperw11906\margl1134\ma...
- ROWBORDER : mixed = 'trbrdr'
- ROWHEIGHT : mixed = 'trrh'
- ROWPADDING : mixed = 'trpadd'
- ROWPADDING_DEFAULT : mixed = 55
- ROWPADDING_UNIT : mixed = 'trpaddf'
- ROWSPACING : mixed = 'trspd'
- ROWSPACING_DEFAULT : mixed = 0
- ROWSPACING_UNIT : mixed = 'trspdf'
- ROWSTART_DEFAULT : mixed = 0
- TABLE_UNIT : mixed = 3
- The row definitions must be output for each row. 'x' refers to a variable additiion.
- TABLEWIDTH_DEFAULT : mixed = 100
- TWIPSTOPIXELS : mixed = 0.0666666667
- TWIPSTOPOINTS : mixed = 0.05
- USABLEWIDTHS : mixed = [ // Set to paper width less margin left and ma...
Functions
- header() : string
- Set some defaults and create the RTF opening tag
- footer() : string
- Create the RTF closing tag
- footnotes() : mixed
- Set RTF headers regarding footnotes/endnotes
- citation() : mixed
- Citation stuff The options for $citeStyle are: 'inText' In-text citations (needs bibliography appended) 'ftInc' Footnotes: the footnotes order increments from 1 (needs bibliography appended) 'endInc' Endnotes: the endnotes order increments from 1 'endSameId' Endnotes using the same ID for the same resource: the endnotes order increments from 1 'endSameIdOrdered' Endnotes using the same ID for the same resource: the endnotes order is set in the bibliography settings
- documentSettings() : mixed
- Deal with document defaults. This function has various roles depending on the value of $method Must be called before traverseDOM()
- cleanHtml() : string
- Clean up HTML before parsing and do some initial conversion
- specialCharsToRTF() : string
- Convert special characters.
- cleanBlockquotes() : string
- TinyMCE always puts p tags within blockquote—remove them!
- fonts() : mixed
- Deal with fonts. This function has various roles depending on the value of $method
- colours() : mixed
- Deal with colours. This function has various roles depending on the value of $method
- lists() : mixed
- Deal with lists. This function has various roles depending on the value of $method
- listToRTF() : string
- Convert lists to RTF (deals with nested lists too and recognizes unordered or ordered)
- newListTableItem() : string
- Create new listtable item
- textDecoration() : mixed
- text-decoration styling
- fontWeight() : string
- Convert font-weight
- fontSize() : string
- Convert font size to RTF
- traverseDOM() : string
- Traverse the DOM and produce RTF code
- nodeAttributes() : mixed
- Convert attributes
- tables() : mixed
- Deal with tables and their elements. This function has various roles depending on the value of $method
- setCellEdgeDefaults() : array<string|int, mixed>
- Set cell edge defaults in the table matrix.
- tableCellToRTF() : array<string|int, mixed>
- Convert table cell to RTF cell property string
- inheritParentBorders() : array<string|int, mixed>
- Transfer the parent's border properties to a spanned child
- getCellBorderParams() : array<string|int, mixed>
- Get cell border parameters
- updateCellEdges() : array<string|int, mixed>
- Update cell edge in the table matrix for one cell. i.e. border has been set for this table cell
- cellBordersToString() : string
- Create a string of cell border properties from an array
- calculateTableMatrix() : array<string|int, mixed>
- We need to set up a table matrix counting number of rows and number of their children so we can deal with various properties.
- getCellWidth() : string
- Get cell width
- startCellToRTF() : array<string|int, mixed>
- Start the process of converting a td or th element
- utf8_2_rtfansicpg1252() : string
- UTF-8 to ANSI Windows 1252 strings for RTF only
- domImageToRtfImagePlaceholders() : string
- Replace HTML image src attribute by a placeholder pointing to a cached file on disk
- domNodeAttributes2Array() : array<string|int, string>
- Convert attributes of a DOMNode to an array of attributes
Constants
BLOCKINDENT
public
mixed
BLOCKINDENT
= 720
BORDERCEILING
public
mixed
BORDERCEILING
= 75
CELL_DEFAULTS
public
mixed
CELL_DEFAULTS
= [
'BorderStyle' => 's',
// Solid
'BorderWidth' => 20,
// 1pt = 20 twips
'BorderColor' => 1,
]
CELL_EMPTY
public
mixed
CELL_EMPTY
= '\intbl' . LF . '{}' . LF . '\cell\pard' . LF . LF
CELL_STUB
public
mixed
CELL_STUB
= [
'Border' => 'clbrdr',
// Begin cell border definition — add one of 't', 'l', 'b', 'r'
'BorderStyle' => 'brdr',
// Add from CELLBORDER_STYLES[]
'BorderWidth' => 'brdrw',
// Add a number in twips
'BorderColor' => 'brdrcf',
// Add a number from colour table
'Padding' => 'clpad',
// Add one of 't', 'l', 'b', 'r' and a number in twips
'PaddingUnit' => 'clpadf',
// Add one of 't', 'l', 'b', 'r' and a number in twips
'BackgroundColor' => 'clcbpat',
// Add a number from colour table
'TextAlign' => 'q',
// Add a letter from JUSTIFY[]
'VAlign' => 'clvertal',
// Add a letter from CELLVALING[]
'CellX' => 'cellx',
]
CELL_USETABLEBORDER
public
mixed
CELL_USETABLEBORDER
= 'brdrtbl'
CELL_VALIGN
public
mixed
CELL_VALIGN
= ['top' => 't', 'middle' => 'c', 'bottom' => 'b']
CELL_VERTICALMERGE
public
mixed
CELL_VERTICALMERGE
= ['start' => 'clvmgf', 'continue' => 'clvmrg']
CELLBORDER_STYLES
public
mixed
CELLBORDER_STYLES
= [
// We only use those available in tinyMCE. I've tried to match these to RTF . . .
'solid' => 's',
'dotted' => 'dot',
'dashed' => 'dash',
'double' => 'db',
'groove' => 'emboss',
'ridge' => 'engrave',
'inset' => 'tnthlg',
// Thick thin large
'outset' => 'thtnlg',
// Thin thick large
'none' => FALSE,
'hidden' => FALSE,
]
CELLPADDING
public
mixed
CELLPADDING
= 'clpad'
CELLPADDING_DEFAULT
public
mixed
CELLPADDING_DEFAULT
= 55
CELLPADDING_UNIT
public
mixed
CELLPADDING_UNIT
= 'clpadf'
CELLWIDTH_DEFAULT
public
mixed
CELLWIDTH_DEFAULT
= 300
COLOUR_NAMES
public
mixed
COLOUR_NAMES
= ["aliceblue" => "F0F8FF", "antiquewhite" => "FAEBD7", "aqua" => "00FFFF", "aquamarine" => "7FFFD4", "azure" => "F0FFFF", "beige" => "F5F5DC", "bisque" => "FFE4C4", "black" => "000000", "blanchedalmond" => "FFEBCD", "blue" => "0000FF", "blueviolet" => "8A2BE2", "brown" => "A52A2A", "burlywood" => "DEB887", "cadetblue" => "5F9EA0", "chartreuse" => "7FFF00", "chocolate" => "D2691E", "coral" => "FF7F50", "cornflowerblue" => "6495ED", "cornsilk" => "FFF8DC", "crimson" => "DC143C", "cyan" => "00FFFF", "darkblue" => "00008B", "darkcyan" => "008B8B", "darkgoldenrod" => "B8860B", "darkgray" => "A9A9A9", "darkgreen" => "006400", "darkgrey" => "A9A9A9", "darkkhaki" => "BDB76B", "darkmagenta" => "8B008B", "darkolivegreen" => "556B2F", "darkorange" => "FF8C00", "darkorchid" => "9932CC", "darkred" => "8B0000", "darksalmon" => "E9967A", "darkseagreen" => "8FBC8F", "darkslateblue" => "483D8B", "darkslategray" => "2F4F4F", "darkslategrey" => "2F4F4F", "darkturquoise" => "00CED1", "darkviolet" => "9400D3", "deeppink" => "FF1493", "deepskyblue" => "00BFFF", "dimgray" => "696969", "dimgrey" => "696969", "dodgerblue" => "1E90FF", "firebrick" => "B22222", "floralwhite" => "FFFAF0", "forestgreen" => "228B22", "fuchsia" => "FF00FF", "gainsboro" => "DCDCDC", "ghostwhite" => "F8F8FF", "gold" => "FFD700", "goldenrod" => "DAA520", "gray" => "808080", "green" => "008000", "greenyellow" => "ADFF2F", "grey" => "808080", "honeydew" => "F0FFF0", "hotpink" => "FF69B4", "indianred" => "CD5C5C", "indigo" => "4B0082", "ivory" => "FFFFF0", "khaki" => "F0E68C", "lavender" => "E6E6FA", "lavenderblush" => "FFF0F5", "lawngreen" => "7CFC00", "lemonchiffon" => "FFFACD", "lightblue" => "ADD8E6", "lightcoral" => "F08080", "lightcyan" => "E0FFFF", "lightgoldenrodyellow" => "FAFAD2", "lightgray" => "D3D3D3", "lightgreen" => "90EE90", "lightgrey" => "D3D3D3", "lightpink" => "FFB6C1", "lightsalmon" => "FFA07A", "lightseagreen" => "20B2AA", "lightskyblue" => "87CEFA", "lightslategray" => "778899", "lightslategrey" => "778899", "lightsteelblue" => "B0C4DE", "lightyellow" => "FFFFE0", "lime" => "00FF00", "limegreen" => "32CD32", "linen" => "FAF0E6", "magenta" => "FF00FF", "maroon" => "800000", "mediumaquamarine" => "66CDAA", "mediumblue" => "0000CD", "mediumorchid" => "BA55D3", "mediumpurple" => "9370DB", "mediumseagreen" => "3CB371", "mediumslateblue" => "7B68EE", "mediumspringgreen" => "00FA9A", "mediumturquoise" => "48D1CC", "mediumvioletred" => "C71585", "midnightblue" => "191970", "mintcream" => "F5FFFA", "mistyrose" => "FFE4E1", "moccasin" => "FFE4B5", "navajowhite" => "FFDEAD", "navy" => "000080", "oldlace" => "FDF5E6", "olive" => "808000", "olivedrab" => "6B8E23", "orange" => "FFA500", "orangered" => "FF4500", "orchid" => "DA70D6", "palegoldenrod" => "EEE8AA", "palegreen" => "98FB98", "paleturquoise" => "AFEEEE", "palevioletred" => "DB7093", "papayawhip" => "FFEFD5", "peachpuff" => "FFDAB9", "peru" => "CD853F", "pink" => "FFC0CB", "plum" => "DDA0DD", "powderblue" => "B0E0E6", "purple" => "800080", "red" => "FF0000", "rosybrown" => "BC8F8F", "royalblue" => "4169E1", "saddlebrown" => "8B4513", "salmon" => "FA8072", "sandybrown" => "F4A460", "seagreen" => "2E8B57", "seashell" => "FFF5EE", "sienna" => "A0522D", "silver" => "C0C0C0", "skyblue" => "87CEEB", "slateblue" => "6A5ACD", "slategray" => "708090", "slategrey" => "708090", "snow" => "FFFAFA", "springgreen" => "00FF7F", "steelblue" => "4682B4", "tan" => "D2B48C", "teal" => "008080", "thistle" => "D8BFD8", "tomato" => "FF6347", "turquoise" => "40E0D0", "violet" => "EE82EE", "wheat" => "F5DEB3", "white" => "FFFFFF", "whitesmoke" => "F5F5F5", "yellow" => "FFFF00", "yellowgreen" => "9ACD32"]
COLOURS
public
mixed
COLOURS
= [
'\red0\green0\blue0',
// Black (text by default)
'\red0\green0\blue255',
// Blue (hyperlinks)
'\red255\green0\blue0',
// Red
'\red211\green211\blue211',
// Light grey used for <code>...</code> background colour
'\red0\green0\blue0',
]
DOCDEFAULTS
public
mixed
DOCDEFAULTS
= "\\f1\\fs24\n\\s1\\cf1\\ql\\li1\\fi1"
FONTS
public
mixed
FONTS
= ["andale mono", "arial", "arial black", "book antiqua", "comic sans ms", "courier new", "georgia", "helvetica", "impact", "symbol", "tahoma", "terminal", "times new roman", "trebuchet ms", "verdana", "webdings", "wingdings"]
FONTSIZES
public
mixed
FONTSIZES
= ['xx-small' => 16, 'x-small' => 20, 'small' => 24, 'medium' => 28, 'large' => 36, 'x-large' => 48, 'xx-large' => 72]
HTMLTOARRAYKEY
public
mixed
HTMLTOARRAYKEY
= [
// Translate some HTML attributes to keys used in the table array constants
'border-style' => 'BorderStyle',
'border-color' => 'BorderColor',
'border' => 'BorderWidth',
'background-color' => 'BackgroundColor',
'text-align' => 'TextAlign',
'vertical-align' => 'VAlign',
]
IGNOREDTAGS
public
mixed
IGNOREDTAGS
= [
// Document metadata
"base",
"head",
"link",
"meta",
"style",
"title",
// Content sectioning
"aside",
// Image and multimedia
"area",
"audio",
"map",
"track",
"video",
// Embedded content
"embed",
"iframe",
"object",
"portal",
"source",
// Scripting
"canvas",
"script",
// Forms
"button",
"datalist",
"fieldset",
"form",
"input",
"label",
"legend",
"meter",
"optgroup",
"option",
"output",
"progress",
"select",
"textarea",
// Interactive elements
"details",
"dialog",
"summary",
// Web Components
"slot",
"template",
// Obsolete and deprecated elements
"applet",
"bgsound",
"content",
"frame",
"frameset",
"hgroup",
"image",
"keygen",
"marquee",
"menuitem",
"noembed",
"noframes",
"param",
"plaintext",
"rb",
"rtc",
"shadow",
"spacer",
]
INDENT
public
mixed
INDENT
= 18
INDENTS
public
mixed
INDENTS
= ['indentNone' => '', 'indentAll' => '\li' . BLOCKINDENT, 'indentAllLeft' => '\li' . BLOCKINDENT, 'indentAllRight' => '\ri' . BLOCKINDENT, 'indentFL' => '\fi' . BLOCKINDENT, 'indentNotFL' => '\fi-' . BLOCKINDENT . '\li' . BLOCKINDENT, 'indentBoth' => '\ri' . BLOCKINDENT . '\li' . BLOCKINDENT]
JUSTIFY
public
mixed
JUSTIFY
= ['center' => 'c', 'left' => 'l', 'right' => 'r', 'justify' => 'j']
LINESPACINGS
public
mixed
LINESPACINGS
= ['singleSpace' => '\sl240\slmult1', 'oneSixthSpace' => '\sl276\slmult1', 'oneHalfSpace' => '\sl360\slmult1', 'doubleSpace' => '\sl480\slmult1']
LINESPACINGSNUM
public
mixed
LINESPACINGSNUM
= ['1' => '\sl240\slmult1', '1.15' => '\sl276\slmult1', '1.5' => '\sl360\slmult1', '2' => '\sl480\slmult1']
LISTBULLETS
public
mixed
LISTBULLETS
= ['bullet', 'circle', 'square']
LISTBULLETS_RTF
public
mixed
LISTBULLETS_RTF
= ['\ls1\fi-360\li', '\ls2\fi-360\li', '\ls3\fi-360\li']
LISTINDENT
public
mixed
LISTINDENT
= 720
LISTINDENT_EXTRA
public
mixed
LISTINDENT_EXTRA
= 360
LISTORDERS
public
mixed
LISTORDERS
= ['arabic', 'lower-alpha', 'lower-roman']
LISTORDERS_RTF
public
mixed
LISTORDERS_RTF
= ['0', '4', '2']
LISTTYPES
public
mixed
LISTTYPES
= ['aa' => '\ls5\fi-360', 'a' => '\ls0\fi-360', 'ii' => '\ls3\fi-360', 'i' => '\ls2\fi-360', '1' => '\ls4\fi-360', 'bullet' => '\ls1\fi-360']
PAPERSIZES
public
mixed
PAPERSIZES
= ['A4' => '\paperh16838\paperw11906\margl1134\margr1134\margt1134\margb1134', 'letter' => '\paperh15840\paperw12240\margl1134\margr1134\margt1134\margb1134', 'A5' => '\paperh11906\paperw8391\margl1134\margr1134\margt1134\margb1134', 'legal' => '\paperh20160\paperw12240\margl1134\margr1134\margt1134\margb1134', 'executive' => '\paperw10440\paperh15120\margl1134\margr1134\margt1134\margb1134']
ROWBORDER
public
mixed
ROWBORDER
= 'trbrdr'
ROWHEIGHT
public
mixed
ROWHEIGHT
= 'trrh'
ROWPADDING
public
mixed
ROWPADDING
= 'trpadd'
ROWPADDING_DEFAULT
public
mixed
ROWPADDING_DEFAULT
= 55
ROWPADDING_UNIT
public
mixed
ROWPADDING_UNIT
= 'trpaddf'
ROWSPACING
public
mixed
ROWSPACING
= 'trspd'
ROWSPACING_DEFAULT
public
mixed
ROWSPACING_DEFAULT
= 0
ROWSPACING_UNIT
public
mixed
ROWSPACING_UNIT
= 'trspdf'
ROWSTART_DEFAULT
public
mixed
ROWSTART_DEFAULT
= 0
TABLE_UNIT
The row definitions must be output for each row. 'x' refers to a variable additiion.
public
mixed
TABLE_UNIT
= 3
The minimum are: \trowd (starts the row definition) \trleftx (position in twips from the left margin of the left edge of the first cell) \trpaddxx (padding for each edge of the row: emit 4 times adding one of 't', 'l', 'b', 'r' then number in twips) \trpaddfxx (units for each edge of the row: emit 4 times adding one of 't', 'l', 'b', 'r' then TABLE_UNIT)
The cell definitions must be output for each cell. 'x' refers to a variable addition. Padding is not necessary when the row has default padding defined but it is a good idea to do this for each cell The minimum are: \clpadxx (padding for each edge of the row: emit 4 times adding one of 't', 'l', 'b', 'r' then number in twips) \clpadfxx (units for each edge of the row: emit 4 times adding one of 't', 'l', 'b', 'r' then TABLE_UNIT)
Borders are part of cell definitions. If no borders are required, emit no border definitions. HTML only does borders around the whole table or around each cell. RTF does borders for each cell edge. If a border is required for a cell, define it for each cell edge. Although RTF cell borders can each have their own style, this is not possible in HTML tables so apply the table cell style to each RTF cell. Note that, if a table border is specified (with no cell borders), the borders must be set appropriately for the cells in each row. See the note in tableCellToRTF() If no width attribute in a table cell, use a reasonable number and \RTF\tables("fixCellWidths") will sort it out based on the number of cells in the row, the table width (default 100%) and the usable margin. Note that, because of the missing width information for some or all cells, the result might not be the same as in tinyMCE. A failsafe.
TABLEWIDTH_DEFAULT
public
mixed
TABLEWIDTH_DEFAULT
= 100
TWIPSTOPIXELS
public
mixed
TWIPSTOPIXELS
= 0.0666666667
TWIPSTOPOINTS
public
mixed
TWIPSTOPOINTS
= 0.05
USABLEWIDTHS
public
mixed
USABLEWIDTHS
= [
// Set to paper width less margin left and margin right. For e.g., table and hr widths
'A4' => 9638,
'letter' => 9972,
'A5' => 6123,
'legal' => 9972,
'executive' => 12852,
]
Functions
header()
Set some defaults and create the RTF opening tag
header() : string
Return values
stringfooter()
Create the RTF closing tag
footer() : string
Return values
stringfootnotes()
Set RTF headers regarding footnotes/endnotes
footnotes(string $method[, mixed $extra = false ]) : mixed
See notes at the beginning of this file. But especially remember that endSameId and endSameIdOrdered are fake endnotes (span data-wikindxbib is removed in RTFEXPORT::parseHTML())
Parameters
- $method : string
- $extra : mixed = false
-
Default FALSE
citation()
Citation stuff The options for $citeStyle are: 'inText' In-text citations (needs bibliography appended) 'ftInc' Footnotes: the footnotes order increments from 1 (needs bibliography appended) 'endInc' Endnotes: the endnotes order increments from 1 'endSameId' Endnotes using the same ID for the same resource: the endnotes order increments from 1 'endSameIdOrdered' Endnotes using the same ID for the same resource: the endnotes order is set in the bibliography settings
citation(string $method[, mixed $extra1 = false ][, mixed $extra2 = false ]) : mixed
Most of the formatting of citations is accomplished by the citation engine and formatting in HTML and a bibliography is appended where appropriate.
Parameters
- $method : string
- $extra1 : mixed = false
-
Default FALSE
- $extra2 : mixed = false
-
Default FALSE
documentSettings()
Deal with document defaults. This function has various roles depending on the value of $method Must be called before traverseDOM()
documentSettings(string $method[, mixed $extra = false ][, string $paperSize = 'A4' ][, string $lineSpacing = 'singleSpace' ]) : mixed
Parameters
- $method : string
- $extra : mixed = false
-
Default FALSE
- $paperSize : string = 'A4'
-
Default 'A4'
- $lineSpacing : string = 'singleSpace'
-
Default 'singleSpace'
cleanHtml()
Clean up HTML before parsing and do some initial conversion
cleanHtml(string $text) : string
Parameters
- $text : string
Return values
stringspecialCharsToRTF()
Convert special characters.
specialCharsToRTF(string $text, bool $protectCurlyBrace) : string
For RTF, for escaping special characters used to build control words, it is recommended to convert to hex
Parameters
- $text : string
- $protectCurlyBrace : bool
Return values
stringcleanBlockquotes()
TinyMCE always puts p tags within blockquote—remove them!
cleanBlockquotes(string $text) : string
Parameters
- $text : string
Return values
stringfonts()
Deal with fonts. This function has various roles depending on the value of $method
fonts(string $method[, string $font = '' ]) : mixed
Parameters
- $method : string
- $font : string = ''
-
Default ''
colours()
Deal with colours. This function has various roles depending on the value of $method
colours(string $method[, string $colour = '' ]) : mixed
Parameters
- $method : string
- $colour : string = ''
-
Default ''
lists()
Deal with lists. This function has various roles depending on the value of $method
lists(string $method[, string $string = '' ]) : mixed
Parameters
- $method : string
- $string : string = ''
-
Default ''
listToRTF()
Convert lists to RTF (deals with nested lists too and recognizes unordered or ordered)
listToRTF(array<string|int, mixed> $stack, string $listType) : string
Although list items might have style attributes such as align right, these are ignored by RTF so ignore them here too.
Parameters
- $stack : array<string|int, mixed>
- $listType : string
Return values
stringnewListTableItem()
Create new listtable item
newListTableItem(int $levelnfc, int $listIndex) : string
Parameters
- $levelnfc : int
- $listIndex : int
Return values
stringtextDecoration()
text-decoration styling
textDecoration(string $style) : mixed
Parameters
- $style : string
fontWeight()
Convert font-weight
fontWeight(string $style) : string
Parameters
- $style : string
Return values
stringfontSize()
Convert font size to RTF
fontSize(string $size) : string
Parameters
- $size : string
Return values
stringtraverseDOM()
Traverse the DOM and produce RTF code
traverseDOM(DOMNode $domNode[, mixed $listLevel = 0 ][, int $tableNestLevel = 0 ]) : string
Parameters
- $domNode : DOMNode
- $listLevel : mixed = 0
- $tableNestLevel : int = 0
-
Default = 0
Return values
stringnodeAttributes()
Convert attributes
nodeAttributes(DOMNode $node[, bool $wantArray = false ]) : mixed
Parameters
- $node : DOMNode
- $wantArray : bool = false
-
Default = FALSE
tables()
Deal with tables and their elements. This function has various roles depending on the value of $method
tables(string $method[, mixed $extra = false ][, mixed $extra2 = false ]) : mixed
For each table, there is a $tableObject, and each nested table gets a new $tableObject
Parameters
- $method : string
- $extra : mixed = false
-
Default = FALSE
- $extra2 : mixed = false
-
Default FALSE
setCellEdgeDefaults()
Set cell edge defaults in the table matrix.
setCellEdgeDefaults(array<string|int, mixed> $tableMatrix, string $key, mixed $value) : array<string|int, mixed>
Done when first encountering a table tag.
Also used to set the table parameter 'cellpadding' on all cells.
Parameters
- $tableMatrix : array<string|int, mixed>
- $key : string
- $value : mixed
Return values
array<string|int, mixed>tableCellToRTF()
Convert table cell to RTF cell property string
tableCellToRTF(array<string|int, mixed> $attributes, array<string|int, mixed> $cellArray, int $thisRowNumber, int $thisCellNumber[, bool $th = false ]) : array<string|int, mixed>
Parameters
- $attributes : array<string|int, mixed>
- $cellArray : array<string|int, mixed>
- $thisRowNumber : int
- $thisCellNumber : int
- $th : bool = false
-
(Default FALSE)
Return values
array<string|int, mixed>inheritParentBorders()
Transfer the parent's border properties to a spanned child
inheritParentBorders(array<string|int, mixed> $childCell, int $childRowNumber) : array<string|int, mixed>
Child can never have top edge
Parameters
- $childCell : array<string|int, mixed>
- $childRowNumber : int
Return values
array<string|int, mixed>getCellBorderParams()
Get cell border parameters
getCellBorderParams(string $key, string $value[, array<string|int, mixed> $attributes = [] ]) : array<string|int, mixed>
Parameters
- $key : string
- $value : string
- $attributes : array<string|int, mixed> = []
-
Default [] (used only if $key == 'border-style')
Return values
array<string|int, mixed>updateCellEdges()
Update cell edge in the table matrix for one cell. i.e. border has been set for this table cell
updateCellEdges(array<string|int, mixed> $cellArray, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $cellArray : array<string|int, mixed>
- $params : array<string|int, mixed>
-
($style, $width, $color)
Return values
array<string|int, mixed>cellBordersToString()
Create a string of cell border properties from an array
cellBordersToString(array<string|int, mixed> $cellArray, array<string|int, mixed> $edges) : string
We also deal with rowspans where there may or may not be padding and borders
Parameters
- $cellArray : array<string|int, mixed>
- $edges : array<string|int, mixed>
Return values
stringcalculateTableMatrix()
We need to set up a table matrix counting number of rows and number of their children so we can deal with various properties.
calculateTableMatrix(DOMNode $domNode) : array<string|int, mixed>
Need to count max row cells in a table before we can set up the matrix. Note that the HTML code for vertical spanning ('rowspan') is likely to have uneven numbers of cells. Where there are gaps, we must insert the child cell. Note the relationship (Parent/Child) row no./cell no. for each member of a spanned group to be able to deal with inserted cell properties later on. Cell borders, background colours, properties and so on inherit from the table properties but can override them with individual cell settings. This function is called on an opening table or tbody tag, so, here, we first set up the table matrix consisting of rows where the key is the row count for the table and the value is an array comprising an array of default properties for each cell. These properties can then be overriden in tableCellToRTF().
Parameters
- $domNode : DOMNode
Return values
array<string|int, mixed>getCellWidth()
Get cell width
getCellWidth(array<string|int, mixed> $attributes) : string
Parameters
- $attributes : array<string|int, mixed>
Return values
stringstartCellToRTF()
Start the process of converting a td or th element
startCellToRTF(DOMNode $domNode, bool $rowSpanParent, int $tableNestLevel) : array<string|int, mixed>
Parameters
- $domNode : DOMNode
- $rowSpanParent : bool
- $tableNestLevel : int
-
// > 1 == nested
Return values
array<string|int, mixed>utf8_2_rtfansicpg1252()
UTF-8 to ANSI Windows 1252 strings for RTF only
utf8_2_rtfansicpg1252(string $string) : string
Returns a string encoded accordingly to Rich Text Format (RTF) Specification Version 1.9.1.
Parameters
- $string : string
-
UTF-8 encoded string
Tags
Return values
string —plain ASCII with RTF specific sequences for others characters
domImageToRtfImagePlaceholders()
Replace HTML image src attribute by a placeholder pointing to a cached file on disk
domImageToRtfImagePlaceholders(DOMNode $domNode) : string
The file is hex encoded in cache/files and its filename is inserted inside src, using a pattern as "##
Online resources are dwnloaded and included like others images.
The real insertion is postponed and delegated to \UTILS\insertExportImages() that consumes less memory.
Parameters
- $domNode : DOMNode
Return values
stringdomNodeAttributes2Array()
Convert attributes of a DOMNode to an array of attributes
domNodeAttributes2Array(DOMNode $domNode) : array<string|int, string>
Parameters
- $domNode : DOMNode