* Ex: "HelloWorld.pdf".
* @param bool $output
* FALSE to display PDF. TRUE to return as string.
- * @param null $pdfFormat
+ * @param array|int|null $pdfFormat
* Unclear. Possibly PdfFormat or formValues.
*
* @return string|void
* @return string
*/
public static function _html2pdf_dompdf($paper_size, $orientation, $html, $output, $fileName) {
- // CRM-12165 - Remote file support required for image handling.
- $options = new Options();
- $options->set('isRemoteEnabled', TRUE);
-
+ $options = self::getDompdfOptions();
$dompdf = new DOMPDF($options);
$dompdf->set_paper($paper_size, $orientation);
$dompdf->load_html($html);
}
/**
- * @param $paper_size
- * @param $orientation
- * @param $margins
- * @param $html
- * @param $output
+ * @param float|int[] $paper_size
+ * @param string $orientation
+ * @param array $margins
+ * @param string $html
+ * @param bool $output
* @param string $fileName
*/
public static function _html2pdf_wkhtmltopdf($paper_size, $orientation, $margins, $html, $output, $fileName) {
/**
* convert value from one metric to another.
*
- * @param $value
- * @param $from
- * @param $to
- * @param null $precision
+ * @param int $value
+ * @param string $from
+ * @param string $to
+ * @param int|null $precision
*
* @return float|int
*/
return $value;
}
+ /**
+ * Allow setting some dompdf options.
+ *
+ * We don't support all the available dompdf options.
+ *
+ * @return \Dompdf\Options
+ */
+ private static function getDompdfOptions(): Options {
+ $options = new Options();
+ $settings = [
+ // CRM-12165 - Remote file support required for image handling so default to TRUE
+ 'enable_remote' => \Civi::settings()->get('dompdf_enable_remote') ?? TRUE,
+ ];
+ // only set these ones if a setting exists for them
+ foreach (['font_dir', 'chroot', 'log_output_file'] as $setting) {
+ $value = \Civi::settings()->get("dompdf_$setting");
+ if (isset($value)) {
+ $settings[$setting] = $value;
+ }
+ }
+ $options->set($settings);
+ return $options;
+ }
+
}