mPDF Manual – mPDF Variables

useLang

(mPDF >= 2.3  <= 5.7)

useLang – Specify whether to recognise/support the HTML attribute $lang

Description

void useLang

Specify whether to recognise/support the HTML attribute $lang.

See lang for more details.

Note: $lang is a useful way to select appropriate fonts for some languages. Automatic font selection using SetAutoFont() marks up the HTML with the $lang attribute, so useLang is required. Using automatic font selection adds considerable processing time when creating a large document. Automatic font selection is only valid when using UTF-8 as the codepage for the document.

Values

$useLangTRUE FALSE

Values

TRUE : recognise/support the HTML attribute $lang.

FALSE: does not recognise/support the HTML attribute $lang.

DEFAULT: TRUE

Changelog

VersionDescription
2.3 Variable was added.
4.0 Default value changed to TRUE

Examples

Example #1

<?php

// Require composer autoload
require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new mPDF('utf-8');

$html = '

Start with some English text

 هل ستسفر الجهود الدبلوماسية الجارية عن حلول؟ وكيف تنظر للاتهامات لبعض هذه الدول بالتدخل في الشأن العراقي، والتورط في دعم عمليات العنف؟ والى اي مدى يبدو الوضع في العراق انعكاسا للصراعات الإقليمية في المنطقة؟

And again in English

';

$mpdf->useLang = true;

$mpdf->WriteHTML($html);

$mpdf->Output();

?>

See Also

  • SetAutoFont() - Use AutoFont to auto-detect text language in HTML input
  • autoFontGroupSize - Specify the text chunk size to group when autodetecting text language
  • disableMultilingualJustify - Specify whether to disable text justification in multilingual documents
  • lang - Information on mPDF support for the HTML attribute lang