Я установил одинаковый размер страницы, поля и т. д.
Возможно, проблема в том, как работает метод масштабирования в gotenberg.< /p>
Вот как я устанавливаю параметры в gotenberg:
Код: Выделить всё
$chromiumRequest = Gotenberg::chromium('http://gotenberg.kanbanbox.com:3000')->pdf()->assets(...$this->getFontAssets())
->margins(
0.0 . 'mm',
0.0 . 'mm',
1.0 . 'mm',
1.0 . 'mm',
);
$chromiumRequest->scale($dimensionsTemplate->getZoom() ?? 0.5);
if ($dimensionsTemplate->getPageOrientation()->equals(Orientation::LANDSCAPE)) {
$chromiumRequest->landscape();
}
$paperFormat = $dimensionsTemplate->getPageFormat();
if ($paperFormat === PaperFormat::HALF_LETTER) {
$chromiumRequest->paperSize('140mm', '216mm');
} elseif ($paperFormat === PaperFormat::CUSTOM) {
$pageHeight = $dimensionsTemplate->getPageHeight();
$pageWidth = $dimensionsTemplate->getPageWidth();
if ($pageHeight !== null && $pageHeight > 0 && $pageWidth !== null && $pageWidth > 0) {
$chromiumRequest->paperSize($pageWidth . 'mm', $pageHeight . 'mm');
}
} else {
$chromiumRequest->paperSize(PaperFormat::getDimensions($paperFormat)['width'] . 'mm', PaperFormat::getDimensions($paperFormat)['height'] . 'mm');
}
Код: Выделить всё
$commandLine =
$commandName
. ' --orientation ' . $dimensionsTemplate->getPageOrientation()->value
. ' --zoom ' . 0.78 * ($dimensionsTemplate->getZoom() ?? 1.0)
. ' --margin-top ' . $dimensionsTemplate->getMarginTop()
. ' --margin-right ' . $dimensionsTemplate->getMarginRight()
. ' --margin-bottom ' . $dimensionsTemplate->getMarginBottom()
. ' --margin-left ' . $dimensionsTemplate->getMarginLeft();
$paperFormat = $dimensionsTemplate->getPageFormat();
if ($paperFormat === PaperFormat::HALF_LETTER) {
//half letter is the only format not supported by WkPdf, so we need to specify the width and height
$commandLine .= ' --page-height 216 --page-width 140';
} elseif ($paperFormat === PaperFormat::CUSTOM) {
$pageHeight = $dimensionsTemplate->getPageHeight();
$pageWidth = $dimensionsTemplate->getPageWidth();
if ($pageHeight !== null && $pageHeight > 0 && $pageWidth !== null && $pageWidth > 0) {
$commandLine .= ' --page-height ' . $pageHeight . ' --page-width ' . $pageWidth;
}
} else {
$commandLine .= ' --page-size ' . $paperFormat->value;
}
$commandLine .= ' --disable-smart-shrinking'
. $webArgument[$i]
. ' ' . $tmpPdfChunkName[$i]
. ' 2>&1'; // to write to STDOUT

Подробнее здесь: https://stackoverflow.com/questions/792 ... -gotenberg
Мобильная версия