Formidable Forms PDF addon Arabic / RTL fix

The recently release PDF addon for Formidable Forms uses DOMPDF, which unfortunately doesn’t support Arabic or other RTL languages. UTF-8 character coding appears to be enabled, and if you select the Dejavu Sans font you can get Arabic letters rather than question marks, but they are displayed disconnected and in the wrong direction.

Fortunately, the Ar-PHP Project includes a method utf8Glyphs which can fix the encoding and direction of such strings.

First you will need to include the Ar-PHP class, and then you can use the hook frm_pdfs_export_content to modify the html content included in the generated PDF.

function jlv_ff_pdf_dompdf_rtl_fix( $content, $args ) {
	$ar   = new \ArPHP\I18N\Arabic();
	$content = $ar->utf8Glyphs( $content, null, false, false );
	return $content;
add_filter( 'frm_pdfs_export_content', 'jlv_ff_pdf_dompdf_rtl_fix', 10, 2);

Leave a Reply