mPDF Manual – mPDF Variables


mPDF Variables by Category

Most of the following variables are set as defaults in the configuration file config.php  When set there, they are written as e.g.:


$this->variablename = true;

Alternatively you can redefine the variable in individual scripts; here it will be written as e.g. (assuming your class object is “mpdf”):


$mpdf->variablename = true;
Category Variable Default value Scope[1] Version Notes
Paging mirrorMargins 0 DOCUMENT 4.0 The alias $useOddEven was used before v4.0
  restoreBlockPagebreaks FALSE   2.3  Removed v6.0
  forcePortraitMargins FALSE DOCUMENT 2.3  
  displayDefaultOrientation FALSE DOCUMENT 2.3  
  autoPageBreak TRUE DOCUMENT 3.1  
  setAutoTopMargin FALSE DOCUMENT 4.0  
  setAutoBottomMargin FALSE DOCUMENT 4.0  
  autoMarginPadding 2 DOCUMENT 4.0  
  margBuffer 2 DOCUMENT 5.5 Allows an (empty) end of block to extend beyond the bottom margin by this amount (mm)
  printers_info FALSE   5.1 Adds date and page info for printer when using @page and "marks:crop;"
  bleedMargin 5   5.1  
  crossMarkMargin 5   5.1 Distance of cross mark from margin in mm
  cropMarkMargin 8   5.1 Distance of crop mark from margin in mm
  cropMarkLength 18   5.1 Default length in mm of crop line
  nonPrintMargin 8   5.1 Non-printable border at edge of paper sheet in mm
Page numbering aliasNbPg "{nb}" DOCUMENT   NB The default value will not appear correctly in a PDF version of this page; it is substituted by the number of pages.
  aliasNbPgGp "{nbpg}" DOCUMENT   NB The default value will not appear correctly in a PDF version of this page; it is substituted by the number of pages.
pagenumPrefix "" DOCUMENT 3.0  
  pagenumSuffix "" DOCUMENT 3.0  
  nbpgPrefix "" DOCUMENT 3.0  
  nbpgSuffix "" DOCUMENT 3.0  
  defaultPageNumStyle "1" DOCUMENT 6.0  
Fonts, Languages and Character sets percentSubset 30 DOCUMENT 5.0 Control subsetting behaviour for fonts
  useKerning FALSE DOCUMENT 5.4 Set to TRUE to enable CSS support for $font-kerning
  maxTTFFilesize 2000 DOCUMENT 5.0 Control subsetting behaviour for fonts
  allow_charset_conversion TRUE      
  charset_in *NULL*      
  biDirectional FALSE      
  use_CJK_only FALSE     Removed mPDF 5.0
  useAdobeCJK TRUE DOCUMENT* 5.0 * You must only change this variable in the config.php file. Use initial parameter to change at runtime e.g. `$mpdf = new mPDF('+aCJK');`
  autoFontGroupSize 2   2.3 Removed in v6.0
  useLang TRUE   2.3 Default value FALSE before v4.0 Removed in v6.0
  autoScriptToLang FALSE DOCUMENT 6.0 Replaces SetAutoFont function
  autoLangToFont FALSE DOCUMENT 6.0 Replaces useLang
  baseScript 1 DOCUMENT 6.0  
  autoArabic FALSE DOCUMENT 6.0  
  autoVietnamese FALSE DOCUMENT 6.0  
  disableMultilingualJustify TRUE   2.3  Removed in v6.0
  falseBoldWeight 5   4.2 Weight for bold text when using an artificial (outline) bold
  smCapsScale 0.75   5.0 Factor of 1 to scale capital letters
  smCapsStretch 115   5.0 % to stretch small caps horizontally
  backupSubsFont array('dejavusanscondensed')   5.0 **Set in config_fonts.php**
  backupSIPFont NOT DEFINED   5.0 **Set in config_fonts.php**
Configuration useOnlyCoreFonts FALSE DOCUMENT (3.0) Removed mPDF 5.0 - Use `$mpdf = new mPDF('c');` The alias $use_embeddedfonts_1252 was used before v4.0
  repackageTTF FALSE DOCUMENT 5.2  
  useSubstitutions FALSE   (4.0) NB Altered behaviour mPDF >= 5.0 Default value TRUE before v4.0
  useSubstitutionsMB FALSE   4.2 Removed in mPDF 5.0 Use useSusbstitutions instead. Substitute missing characters in UTF-8(multibyte) documents - from core fonts
  collapseBlockMargins TRUE   4.2 Allows top and bottom margins to collapse between block elements
  dpi 96   4.5 Specifies size conversion for objects with size set by "px"
  enableImports FALSE DOCUMENT* 4.3 Enable Imported PDF files (templates) [was mPDFI] * You must only change this variable in the config.php file. Use SetImportUse() to change at runtime.
  allow_output_buffering FALSE DOCUMENT 3.0  
  allow_html_optional_endtags TRUE DOCUMENT    
  ignore_invalid_utf8 FALSE      
  text_input_as_HTML FALSE DOCUMENT    
  showStats FALSE DOCUMENT 4.0  
  progressBar FALSE DOCUMENT* 4.2 Shows progress-bars whilst generating file * You must only change this variable in the config.php file. Use StartProgressBarOutput() to set at runtime.
  progbar_heading "mPDF file progress" DOCUMENT 5.0 Customise the use of progress-bars
  progbar_altHTML "" DOCUMENT 5.0 Customise the use of progress-bars
  incrementFPR1 [1-4] 10,20,30,50   4.2  
Debugging debug FALSE DOCUMENT 3.1  
  debugfonts FALSE DOCUMENT 5.0 Show errors and warning notes for fonts
  showImageErrors FALSE DOCUMENT 3.0  
PDF/A1-b, PDF/X-1a Colorspaces PDFA FALSE DOCUMENT 4.3  
  ICCProfile "" DOCUMENT 4.3  
  restrictColorSpace 0 DOCUMENT 5.1  
Annotations title2annots FALSE DOCUMENT 2.2  
  annotMargin *NULL* DOCUMENT 2.2  
  annotOpacity 0.5 DOCUMENT 2.2  
Bookmarks (Outlines) anchor2Bookmark 0 DOCUMENT    
  h2bookmarks array() DOCUMENT 5.7 Automatically generate bookmarks from Heading elements H1-H6
  h2toc array() DOCUMENT 5.7 Automatically generate ToC entries from Heading elements H1-H6
CSS & Styles CSSselectMedia "print" DOCUMENT 4.4  
  disablePrintCSS *NULL* DOCUMENT   DEPRACATED from >= 4.4
  rtlCSS 2 DOCUMENT    REMOVED from v 5.1
  useDefaultCSS2   DOCUMENT   DEPRACATED from >= 2.2
Page Headers & Footers defaultfooterfontsize 8      
  defaultfooterfontstyle "BI"      
  defaultfooterline 1      
  defaultheaderfontsize 8      
  defaultheaderfontstyle "BI"      
  defaultheaderline 1      
  footer_line_spacing 0.25      
  header_line_spacing 0.25      
  forcePortraitHeaders FALSE DOCUMENT    
  headerPageNoMarker "!|" DOCUMENT   DEPRACATED from >= 4.0
Tables simpleTables FALSE DOCUMENT 4.3  
  packTableData FALSE DOCUMENT 4.4  
  cacheTables FALSE DOCUMENT 5.4 Removed v6.0
  tableMinSizePriority FALSE   4.6  
  ignore_table_percents FALSE   2.2  
  ignore_table_widths FALSE   2.2  
  keep_table_proportions FALSE   2.2  
  shrink_tables_to_fit 1.4      
  table_error_report FALSE      
  table_error_report_param ""      
  use_kwt FALSE   2.0  
  iterationCounter FALSE DOCUMENT 5.0 Enables the use of a replaceable iteration counter in table headers or footers
  decimal_align cf. DOCUMENT 5.7 Array of characters enabled to align table columns
Images img_dpi 96      
Text Spacing & Justification normalLineheight 1.33   4.2 Value used for line-height when CSS specified as 'normal'
  useFixedNormalLineHeight FALSE   6.0  
  useFixedTextBaseline FALSE   6.0  
  adjustFontDescLineheight 1.14   6.0  
jSmaxChar 2      
  jSmaxWordLast 2   5.1  
  jSmaxCharLast 1   5.1  
  jSpacing *NULL*      DEPRACATED from >= 5.1
  jSWord 0.4      
  orphansAllowed 5      Removed mPDF 5.7
  allowCJKorphans TRUE   5.2 Wrapping of CJK text
  allowCJKoverflow FALSE   5.2 Wrapping of CJK text
  CJKforceend FALSE   5.7 Wrapping of CJK text
  tabSpaces 8   2.3  
  justifyB4br FALSE   4.4 Justify the line before a <br> when using text-align: justify
Hyphenation hyphenate FALSE   2.5  Removed mPDF 5.7
  hyphenateTables FALSE   2.5  Removed mPDF 5.7
  SHYlang "en"   2.5  
Columns keepColumns FALSE      
  max_colH_correction 1.15      
Lists list_auto_mode "browser"   6.0  
  list_indent_default "40px"   6.0  
  list_indent_default_mpdf "0em"   6.0  
  list_marker_offset "5.5pt"   6.0  
  list_symbol_size "3.6pt"   6.0  
  list_align_style "R"   2.1 Removed mPDF 6.0
  list_indent_first_level 0      
  list_number_suffix  "."   2.1  
Watermarks showWatermarkImage  *NULL*   2.2  
  showWatermarkText  *NULL*   2.2  
  watermark_font  ""      
  watermarkImageAlpha  0.2   2.2 Can be changed by SetWatermarkImage()
  watermarkImgAlphaBlend "Normal"   4.5  
  watermarkImgBehind FALSE   4.4 Place watermark images behind page contents
  watermarkTextAlpha  0.2   2.2  
Borders autoPadding FALSE DOCUMENT 3.0  
Bookmarks bookmarkStyles array() DOCUMENT 5.4 Specify appearance of Bookmarks in PDF reader

[1] Variables with scope marked as DOCUMENT should only be set once at the beginning of the document. All others can be changed during the course of creating the document.