M
M
mart_m2019-02-12 18:39:08
MODX
mart_m, 2019-02-12 18:39:08

Modx PDFResource your font?

Tell me how to still set up your customFont in PDFResource ??
I did everything according to the instructions from Jako and mPDF, not only did I have to prescribe inline styles for the template, but no fonts work! ALWAYS 'dejavusanscondensed' font
jako.github.io/PDFResource/usage/#custom-fonts
or bug github.com/Jako/PDFResource/issues/15 ?
my Snippet: 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 file
"times" => array(
    'R' => "times.ttf",
    'B' => "timesbd.ttf",
  ),

these files are located where necessary {core_path}components/pdfresource/vendor/mpdf/mpdf/ttfonts/.
the pdf file chunk template itself
<h5 style=" font-family: times !important;">ТЕКСТ текст ТЕКСТ текст ТЕКСТ текст</h5>

What am I doing wrong? can anyone solve the problem? very necessary

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question