mPDF Manual – mPDF functions


Shaded_box – Writes line of text surrounded by box


void Shaded_box( string $title [, string $font [, float $fontstyle [, float $fontsize [, float $width [, string $style [, float $radius [, string $backgroundcolor [, string $color [, float $padding ]]]]]]]]])

Writes a single line of text surrounded by a box directly to the PDF document at the current position. The box can have rounded corners, and be filled with background-colour.



UTF-8 encoded text (single line)

This method accepts UTF-8 encoded text, and will reverse RTL (right-to-left) text when appropriate.

Text containing HTML entities, as well as decimal and hex e.g. ' ≬ or ↤ can be used, by setting:
$mpdf->text_input_as_HTML = true; (default: false)
This will convert all the above to their apropriate characters, otherwise the text will be output as it is.


Font family

Default: '' i.e. default document font


Font style as one of

  • 'B' (bold)
  • 'I' (italic)
  • 'BI' (bold-italic)
  • or blank for normal

Default: 'B' i.e. bold


Font size in points (pt)

Default: '' i.e. default document font size


Width of the box - any units acceptable in CSS can be used e.g. pt, px, mm, % (of page width)

Default: '70%'


Box style:

  • 'D' or empty string - draw border (default);
  • 'F' - fill;
  • 'DF' or 'FD' - draw and fill

Default: 'DF' i.e. border and fill


Radius of the rounded corners

Default: 2.5


Fill colour for the box - as '#rrggbb'

Default: '#FFFFFF'


Text colour - as '#rrggbb'

Default: '#000000'


Padding between text and box border, in millimeters

Default: 2

Fork me on GitHub