From 40b9de0b77866e24c95402faf8d172a120c118d4 Mon Sep 17 00:00:00 2001 From: Brady Miller Date: Sat, 30 Jun 2018 18:19:58 -0700 Subject: [PATCH] mPDF fixes for the new version of mPDF --- interface/forms/LBF/printable.php | 38 +++++++++-------- interface/forms/eye_mag/php/taskman_functions.php | 35 ++++++++-------- interface/forms/eye_mag/save.php | 50 ++++++++++++----------- interface/patient_file/report/custom_report.php | 45 +++++++++----------- 4 files changed, 84 insertions(+), 84 deletions(-) diff --git a/interface/forms/LBF/printable.php b/interface/forms/LBF/printable.php index 1a0f88486..dd4d688a2 100644 --- a/interface/forms/LBF/printable.php +++ b/interface/forms/LBF/printable.php @@ -12,6 +12,8 @@ require_once("$srcdir/options.inc.php"); require_once("$srcdir/patient.inc"); require_once($GLOBALS['fileroot'] . '/custom/code_types.inc.php'); +use Mpdf\Mpdf; + // Font size in points for table cell data. $FONTSIZE = 9; @@ -71,28 +73,28 @@ $PDF_OUTPUT = ($formid && $isform) ? false : true; //$PDF_OUTPUT = false; // debugging if ($PDF_OUTPUT) { - $pdf = new mPDF( - $GLOBALS['pdf_language'], - $GLOBALS['pdf_size'], - '', // default font size (pt) - '', - $GLOBALS['pdf_left_margin'], - $GLOBALS['pdf_right_margin'], - $GLOBALS['pdf_top_margin'], - $GLOBALS['pdf_bottom_margin'], - '', // default header margin - '', // default footer margin - $GLOBALS['pdf_layout'] + $config_mpdf = array( + 'mode' => $GLOBALS['pdf_language'], + 'format' => $GLOBALS['pdf_size'], + 'default_font_size' => '', + 'default_font' => '', + 'margin_left' => $GLOBALS['pdf_left_margin'], + 'margin_right' => $GLOBALS['pdf_right_margin'], + 'margin_top' => $GLOBALS['pdf_top_margin'], + 'margin_bottom' => $GLOBALS['pdf_bottom_margin'], + 'margin_header' => '', + 'margin_footer' => '', + 'orientation' => $GLOBALS['pdf_layout'], + 'shrink_tables_to_fit' => 1, + 'use_kwt' => true, + 'autoScriptToLang' => true, + 'keep_table_proportions' => true ); + $pdf = new mPDF($config_mpdf); $pdf->SetDisplayMode('real'); - $pdf->shrink_tables_to_fit = 1; - $keep_table_proportions = true; - $pdf->use_kwt = true; - $pdf->autoScriptToLang = true; if ($_SESSION['language_direction'] == 'rtl') { $pdf->SetDirectionality('rtl'); } - ob_start(); } @@ -465,7 +467,7 @@ while ($frow = sqlFetchArray($fres)) { } else { echo " $GLOBALS['pdf_language'], + 'format' => $GLOBALS['pdf_size'], + 'default_font_size' => '9', + 'default_font' => '', + 'margin_left' => $GLOBALS['pdf_left_margin'], + 'margin_right' => $GLOBALS['pdf_right_margin'], + 'margin_top' => $GLOBALS['pdf_top_margin'], + 'margin_bottom' => $GLOBALS['pdf_bottom_margin'], + 'margin_header' => '', + 'margin_footer' => '', + 'orientation' => $GLOBALS['pdf_layout'], + 'shrink_tables_to_fit' => 1, + 'use_kwt' => true, + 'keep_table_proportions' => true ); + $pdf = new mPDF($config_mpdf); if ($_SESSION['language_direction'] == 'rtl') { $pdf->SetDirectionality('rtl'); } - $pdf->shrink_tables_to_fit = 1; - $keep_table_proportions = true; - $pdf->use_kwt = true; - ob_start(); ?> diff --git a/interface/forms/eye_mag/save.php b/interface/forms/eye_mag/save.php index 9a2c3a60c..3f69d68bd 100644 --- a/interface/forms/eye_mag/save.php +++ b/interface/forms/eye_mag/save.php @@ -58,6 +58,8 @@ require_once("$srcdir/lists.inc"); require_once("$srcdir/report.inc"); require_once("$srcdir/html2pdf/html2pdf.class.php"); +use Mpdf\Mpdf; + $returnurl = 'encounter_top.php'; if (isset($_REQUEST['id'])) { @@ -114,17 +116,17 @@ if ($_REQUEST['AJAX_PREFS']) { VALUES ('PREFS','CTL','Contact Lens',?,'CTL','55',?,'5')"; sqlQuery($query, array($_SESSION['authId'],$_REQUEST['PREFS_CTL'])); - + $query = "REPLACE INTO ".$table_name."_prefs (PEZONE,LOCATION,LOCATION_text,id,selection,ZONE_ORDER,GOVALUE,ordering) VALUES ('PREFS', 'VAX', 'Visual Acuities', ?, 'VAX','65', ?,'15')"; sqlQuery($query, array($_SESSION['authId'],$_REQUEST['PREFS_VAX'])); - + $query = "REPLACE INTO ".$table_name."_prefs (PEZONE,LOCATION,LOCATION_text,id,selection,ZONE_ORDER,GOVALUE,ordering) VALUES ('PREFS', 'RXHX', 'Prior Refractions', ?, 'RXHX','65', ?,'115')"; sqlQuery($query, array($_SESSION['authId'],$_REQUEST['PREFS_RXHX'])); - + $query = "REPLACE INTO ".$table_name."_prefs (PEZONE,LOCATION,LOCATION_text,id,selection,ZONE_ORDER,GOVALUE,ordering) VALUES ('PREFS','ADDITIONAL','Additional Data Points',?,'ADDITIONAL','56',?,'6')"; @@ -360,26 +362,26 @@ if ($_REQUEST["mode"] == "new") { array($GLOBALS['pdf_left_margin'],$GLOBALS['pdf_top_margin'],$GLOBALS['pdf_right_margin'],$GLOBALS['pdf_bottom_margin']), $_SESSION['language_direction'] == 'rtl' ? true : false );*/ - $pdf = new mPDF( - $GLOBALS['pdf_language'], - $GLOBALS['pdf_size'], - '9', - '', - $GLOBALS['pdf_left_margin'], - $GLOBALS['pdf_right_margin'], - $GLOBALS['pdf_top_margin'], - $GLOBALS['pdf_bottom_margin'], - '', // default header margin - '', // default footer margin - $GLOBALS['pdf_layout'] + $config_mpdf = array( + 'mode' => $GLOBALS['pdf_language'], + 'format' => $GLOBALS['pdf_size'], + 'default_font_size' => '9', + 'default_font' => '', + 'margin_left' => $GLOBALS['pdf_left_margin'], + 'margin_right' => $GLOBALS['pdf_right_margin'], + 'margin_top' => $GLOBALS['pdf_top_margin'], + 'margin_bottom' => $GLOBALS['pdf_bottom_margin'], + 'margin_header' => '', + 'margin_footer' => '', + 'orientation' => $GLOBALS['pdf_layout'], + 'shrink_tables_to_fit' => 1, + 'use_kwt' => true, + 'keep_table_proportions' => true ); + $pdf = new mPDF($config_mpdf); if ($_SESSION['language_direction'] == 'rtl') { $pdf->SetDirectionality('rtl'); } - $pdf->shrink_tables_to_fit = 1; - $keep_table_proportions = true; - $pdf->use_kwt = true; - ob_start(); ?> @@ -459,7 +461,7 @@ if ($_REQUEST["mode"] == "new") { if ($_REQUEST['action'] == 'docs') { $query = "update patient_data set providerID=?,ref_providerID=? where pid =?"; sqlQuery($query, array($_REQUEST['pcp'],$_REQUEST['rDOC'],$pid)); - + if ($_REQUEST['pcp']) { //return PCP's data to end user to update their form $query = "SELECT * FROM users WHERE id =?"; @@ -471,7 +473,7 @@ if ($_REQUEST["mode"] == "new") { $DOCS['pcp']['address'] = $DOC1['organization'] . "
" . $DOC1['street'] . "
" . $DOC1['city'] . ", " . $DOC1['state'] . " " . $DOC1['zip'] . "
"; $DOCS['pcp']['fax'] = $DOC1['fax']; $DOCS['pcp']['phone'] = $DOC1['phonew1']; - + // does the fax already exist? $query = "SELECT * FROM form_taskman WHERE TO_ID=? AND PATIENT_ID=? AND ENC_ID=?"; $FAX_PCP = sqlQuery($query, array($_REQUEST['pcp'], $pid, $encounter)); @@ -492,7 +494,7 @@ if ($_REQUEST["mode"] == "new") { '; } } - + if ($_REQUEST['rDOC']) { //return referring Doc's data to end user to update their form $query = "SELECT * FROM users WHERE id =?"; @@ -507,7 +509,7 @@ if ($_REQUEST["mode"] == "new") { $DOCS['ref']['address'] .= $DOC2['street'] . "
" . $DOC2['city'] . ", " . $DOC2['state'] . " " . $DOC2['zip'] . "
"; $DOCS['ref']['fax'] = $DOC2['fax']; $DOCS['ref']['phone'] = $DOC2['phonew1']; - + // does the fax already exist? $query = "SELECT * FROM form_taskman WHERE TO_ID=? AND PATIENT_ID=? AND ENC_ID=?"; $FAX_REF = sqlQuery($query, array($_REQUEST['rDOC'], $pid, $encounter)); @@ -528,7 +530,7 @@ if ($_REQUEST["mode"] == "new") { '; } } - + echo json_encode($DOCS); exit; } diff --git a/interface/patient_file/report/custom_report.php b/interface/patient_file/report/custom_report.php index 1755eec9a..3063263a5 100644 --- a/interface/patient_file/report/custom_report.php +++ b/interface/patient_file/report/custom_report.php @@ -31,6 +31,7 @@ if ($GLOBALS['gbl_portal_cms_enable']) { require_once("$srcdir/appointments.inc.php"); use ESign\Api; +use Mpdf\Mpdf; use OpenEMR\Services\FacilityService; $facilityService = new FacilityService(); @@ -41,33 +42,27 @@ $GLOBALS['PATIENT_REPORT_ACTIVE'] = true; $PDF_OUTPUT = empty($_POST['pdf']) ? 0 : intval($_POST['pdf']); if ($PDF_OUTPUT) { -/* composer bootstrap loads classes for mPDF */ - $pdf = new mPDF( - $GLOBALS['pdf_language'], // codepage or language/codepage or language - this can help auto determine many other options such as RTL - $GLOBALS['pdf_size'], // Globals default is 'letter' - '9', // default font size (pt) - '', // default_font. will set explicitly in script. - $GLOBALS['pdf_left_margin'], - $GLOBALS['pdf_right_margin'], - $GLOBALS['pdf_top_margin'], - $GLOBALS['pdf_bottom_margin'], - '', // default header margin - '', // default footer margin - $GLOBALS['pdf_layout'] - ); // Globals default is 'P' - - $pdf->shrink_tables_to_fit = 1; - $keep_table_proportions = true; - $pdf->use_kwt = true; - - // set 'dejavusans' for now. which is supported by a lot of languages - http://dejavu-fonts.org/wiki/Main_Page - // TODO: can have this selected as setting in globals after we have more experience with this to fully support internationalization. Don't think this is issue here. - $pdf->setDefaultFont('dejavusans'); // see config_fonts.php/config_lang2fonts.php for OTL font declarations for different languages/fonts. Important for auto font select getting right font for lanaguage. - $pdf->autoScriptToLang = true; // will sense font based on language used in html i.e if hebrew text is sent the proper font will be selected. IMPORTANT: this affects performance. + $config_mpdf = array( + 'mode' => $GLOBALS['pdf_language'], + 'format' => $GLOBALS['pdf_size'], + 'default_font_size' => '9', + 'default_font' => 'dejavusans', + 'margin_left' => $GLOBALS['pdf_left_margin'], + 'margin_right' => $GLOBALS['pdf_right_margin'], + 'margin_top' => $GLOBALS['pdf_top_margin'], + 'margin_bottom' => $GLOBALS['pdf_bottom_margin'], + 'margin_header' => '', + 'margin_footer' => '', + 'orientation' => $GLOBALS['pdf_layout'], + 'shrink_tables_to_fit' => 1, + 'use_kwt' => true, + 'autoScriptToLang' => true, + 'keep_table_proportions' => true + ); + $pdf = new mPDF($config_mpdf); if ($_SESSION['language_direction'] == 'rtl') { - $pdf->SetDirectionality('rtl'); // direction from html will still be honored. + $pdf->SetDirectionality('rtl'); } - ob_start(); } // end pdf conditional. -- 2.11.4.GIT