While I am converting HTML content to PDF document by using render function in “Tygh\Addons\PdfDocuments\Pdf”, it can’t resize the document to given sizes.
I see default param as ‘page_size’ => ‘A4’.
When I am trying to change page_size as A6 (for example), it resize. But it can’t resize it to given mm size like:
$params[‘page_height’] = ‘100mm’;
$params[‘page_width’] = ‘100mm’;
Pdf::render($content, $exactfilepath, true, $params);
But here ( GitHub - cscart/pdf: Service that converts HTML documents to PDF ) I see that there is page_width option but it doesn’t work. Am I doing something incorrect?
app/addons/pdf_documents/src/Pdf.php
try to add
if (!empty($params['page_height'])) {
unset($params['page_size']);
}
after
$params = array_merge($default_params, $params);
(!) Not tested
Thanks for the answer. But it doesn’t work: Tried to unset $params[‘page_size’] and $default_params[‘page_size’] and even adding
$params['page_height'] = '357px';
$params['page_width'] = '357px';
to app/addons/pdf_documents/src/Pdf.php but nothing changed. Just $params[‘page_size’] is accepting up to A6 variable.
Other Optional params
- page_width (mm or px)
- page_height (mm or px)
don’t work. I guess something is wrong at converter service.
When I look at pdf/Converter.php at master · cscart/pdf · GitHub I see
foreach ($params as $key => $value) {
switch ($key) {
case 'page_size':
if (in_array($value, ['A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6'], true)) {
$options['format'] = $value;
}
break;
case 'orientation':
$options['landscape'] = strtolower($value) === 'landscape';
break;
case 'margin_left':
$options['margin']['left'] = $value;
break;
case 'margin_right':
$options['margin']['right'] = $value;
break;
case 'margin_top':
$options['margin']['top'] = $value;
break;
case 'margin_bottom':
$options['margin']['bottom'] = $value;
break;
case 'page_height':
$options['height'] = $value;
break;
case 'page_width':
$options['width'] = $value;
break;
}
}
bu page_height and page_width doen’t work.
Something is wrong here: Because page_size can’t be sent empty, page_width and page_height don’t get any value.
$options[‘format’] will be filled in every way by page_size.
Sorry, in this case I cannot help you without further code examination
Thanks. I have contact to Cs-cart via help desk and informed about the issue and will be waiting for reply.
Thank you for your report.
I see that you have already reported this issue through the Help Desk and we have confirmed it as a bug, so I will also mark the current status of your request here.