@mart_m

Modx PDFResource свой font?

Подскажите как все таки настроить свой customFont в PDFResource ??
все по инструкции от Jako и mPDF делал, мало того пришлось инлайн стили шаблону прописывать, так и шрифты не работают никакие! ВСЕГДА 'dejavusanscondensed' font

jako.github.io/PDFResource/usage/#custom-fonts
или баг github.com/Jako/PDFResource/issues/15?

мой Сниппет: PdfCreate
<?php
$date = date('Y-m-d_H-i-s', time()) . '_' .rand(1, 100);

$corePath = $modx->getOption('pdfresource.core_path', null, $modx->getOption('core_path') . 'components/pdfresource/');
$pdfresource = $modx->getService('pdfresource', 'PDFResource', $corePath . 'model/pdfresource/', array(
    'core_path' => $corePath
));

$content = $modx->getOption('content', $scriptProperties, '', true);
$title = $modx->getOption('title', $scriptProperties, '', true);
$author = $modx->getOption('author', $scriptProperties, '', true);

$aliasPath = MODX_ASSETS_PATH . 'pdf/';
$site_url = $modx->getOption('site_url');

// настройки PDFResource (подробнее почитать здесь: http://jako.github.io/PDFResource/usage/)
$pdfresource->initPDF(array(
    'mode' => 'utf-8',
    'format' => 'A4',
    'defaultFont' => 'times',
    'defaultFontSize' => intval(8),
    'mgl' => intval(5),    // margin left
    'mgr' => intval(5),    // margin right
    'mgt' => intval(6),     // margin top
    'mgb' => intval(7),     // margin bottom
    'mgh' => intval(5),    // margin header
    'mgf' => intval(5),    // margin footer
    'orientation' => 'P',   // ориентация PDF
    'customFonts' => '[times]',
));

$pdfresource->pdf->SetTitle($title);
$pdfresource->pdf->SetAuthor($author);
$pdfresource->pdf->SetCreator($modx->getOption('site_url'));

$pdfresource->pdf->WriteHTML($content, 2);

$file_name = $date;
$pdfresource->pdf->Output($aliasPath . $file_name . '.pdf', 'F');
return $site_url . ltrim($modx->getOption('assets_url'), '/') . 'pdf/' .$file_name. '.pdf';


файл config_fonts.php
"times" => array(
		'R' => "times.ttf",
		'B' => "timesbd.ttf",
	),


эти файлы лежат где надо {core_path}components/pdfresource/vendor/mpdf/mpdf/ttfonts/.

сам шаблон чанк pdf файла
<h5 style=" font-family: times !important;">ТЕКСТ текст ТЕКСТ текст ТЕКСТ текст</h5>


Что я делаю не так? может кто решал проблему? очень нужно
  • Вопрос задан
  • 165 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы