mPDF

Justification

Tables

Text can be justified in table cells using in-line or stylesheet CSS. (Note that <p> tags are removed within cells along with any style definition or attributes.)

Col/Row Header

Second column header p

Third column header
Row header 1 This is data This is data
Row header 2

This is data p

This is data

Row header 3

This is long data

This is data

Row header 4

<th> cell acting as header

Proin aliquet lorem id felis. Curabitur vel libero at mauris nonummy tincidunt. Donec imperdiet. Vestibulum sem sem, lacinia vel, molestie et, laoreet eget, urna. Curabitur viverra faucibus pede. Morbi lobortis. Donec dapibus. Donec tempus. Ut arcu enim, rhoncus ac, venenatis eu, porttitor mollis, dui. Sed vitae risus. In elementum sem placerat dui. Nam tristique eros in nisl. Nulla cursus sapien non quam porta porttitor. Quisque dictum ipsum ornare tortor. Fusce ornare tempus enim.

This is data

Row header 5 Also data Also data
Row header 6 Also data Also data
Row header 7 Also data Also data
Row header 8 Also data Also data

 

Testing Justification with Long Words

http://www-950.ibm.com/software/globalization/icu/demo/converters?s=ALL&snd=4356&dnd=4356

Should not split

Maecenas feugiat pede vel risus. Nulla et lectus eleifend verylongwordthatwontsplit neque sit amet erat

Maecenas feugiat pede vel risus. Nulla et lectus eleifend et verylongwordthatwontsplit neque sit amet erat

Non-breaking Space &nbsp;

The next example has a non-breaking space between eleifend and the very long word.

Maecenas feugiat pede vel risus. Nulla et lectus eleifend verylongwordthatwontsplitanywhere neque sit amet erat

Nbsp will only work in fonts that have a glyph to represent the character i.e. not in the CJK languages nor some Unicode fonts.

Testing Justification with mixed Styles

This is strikethrough in block and small strikethrough in small span and big strikethrough in big span and then underline but out of span again but blue font and ACRONYM text

This is a green reference32-47 and underlined reference32-47 then reference32-47 and underlined reference32-47 then Strikethrough reference32-47 and strikethrough reference32-47 and then more text.

Repeated in BIG: This is reference32-47 and underlined reference32-47 then reference32-47 and underlined reference32-47 but out of span again but blue font and ACRONYM text

Repeated in small: This is reference32-47 and underlined reference32-47 then reference32-47 and underlined reference32-47 but out of span again but blue font and ACRONYM text

This is strikethrough in block and big strikethrough in big span and then underline but out of span again but blue font and ACRONYM text

This is reference32-47 and underlined reference32-47 then reference32-47 and underlined reference32-47 then Strikethrough reference32-47 and strikethrough reference32-47 then more text.

Repeated in BIG: This is reference32-47 and underlined reference32-47 then reference32-47 and underlined reference32-47 but out of span again but blue font and ACRONYM text

'; //============================================================== //============================================================== //============================================================== include("../mpdf.php"); $mpdf=new mPDF('c','A4','','',32,25,27,25,16,13); $mpdf->SetDisplayMode('fullpage'); // LOAD a stylesheet $stylesheet = file_get_contents('mpdfstyletables.css'); $mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text $mpdf->WriteHTML($html); // SPACING $mpdf->WriteHTML("

Spacing

mPDF uses both letter- and word-spacing for text justification. The default is a mixture of both, set by the configurable values jSWord and jSmaxChar. (Only word spacing is used when cursive languages such as Arabic or Indic are detected.)

"); $mpdf->jSWord = 0; // Proportion (/1) of space (when justifying margins) to allocate to Word vs. Character $mpdf->jSmaxChar = 0; // Maximum spacing to allocate to character spacing. (0 = no maximum) $mpdf->WriteHTML("
Character spacing

Maecenas feugiat pede vel risus. Nulla et lectus eleifend verylongwordthatwontsplitanywhere neque sit amet erat

"); // Back to default settings $mpdf->jSWord = 0.4; $mpdf->jSmaxChar = 2; $mpdf->WriteHTML("
Word spacing

Maecenas feugiat pede vel risus. Nulla et lectus eleifend verylongwordthatwontsplitanywhere neque sit amet erat

"); $mpdf->WriteHTML("
Mixed Character and Word spacing

Maecenas feugiat pede vel risus. Nulla et lectus eleifend verylongwordthatwontsplitanywhere neque sit amet erat

"); // ORPHANS $mpdf->WriteHTML("

Orphans

Punctuation marks should not be split when the last word on a line is in <tags> eg NATO. The punctuation should go to the next line with the word if necessary.

"); $mpdf->WriteHTML("

Punctuation marks should not be split when the last word on a line is in <tags> e.g. UNESCO. The punctuation should go to the next line with the word if necessary.

"); $mpdf->WriteHTML("

Single marks .,?!;:\xe2\x80\x9e\xe2\x80\x9d should be preserved when last word on a line is in <tags> e.g. NATO? All of these are automatically protected in mPDF.

"); $mpdf->orphansAllowed = 0; $mpdf->WriteHTML("

Similarly, sub and super texts should not be split when justifying text such as references23. (Note that this sentence has the orphansAllowed set to zero.) Altering the value of \$mpdf->orphansAllowed will determine how many extra characters can be preserved on a line; the next line allows 3 (default value 5):

"); $mpdf->orphansAllowed = 3; $mpdf->WriteHTML("

Similarly, sub and super texts should not be split when justifying text such as references23. The references should go to the next line with the word if necessary, or remain on the same line.

"); $mpdf->Output(); exit; ?>