Php 如何使用Knp Snappy bundle设置pdf的页面大小
我有一个代码,用于使用KNP Snappy Bundlede和Symfony2生成PDF。这就是它看起来的样子: 我的问题是,我想设置页边距并将页面大小从A4更改为A1。我已经找到了这么多的例子,但每次我尝试,它似乎不再生成pdf。我怎样才能解决这个问题并使其发挥作用Php 如何使用Knp Snappy bundle设置pdf的页面大小,php,symfony,pdf,symfony-2.8,knp-snappy,Php,Symfony,Pdf,Symfony 2.8,Knp Snappy,我有一个代码,用于使用KNP Snappy Bundlede和Symfony2生成PDF。这就是它看起来的样子: 我的问题是,我想设置页边距并将页面大小从A4更改为A1。我已经找到了这么多的例子,但每次我尝试,它似乎不再生成pdf。我怎样才能解决这个问题并使其发挥作用 提前感谢您的帮助。您可以在选项中设置几个标志: $options = [ 'page-size' => 'A1', 'margin-top' => 10, 'margin-right' => 10,
提前感谢您的帮助。您可以在选项中设置几个标志:
$options = [
'page-size' => 'A1',
'margin-top' => 10,
'margin-right' => 10,
'margin-bottom' => 10,
'margin-left' => 10,
];
$this->container->get('knp_snappy.pdf')->generateFromHtml(
$this->templating->render(
$twigInclude,
[
'htmlFiles' => $htmlFiles,
'headlines' => $headlines,
]
),
$folderHistory . '/reports/' . $filename . '.pdf',
$options,
true // this flag will overwrite existing file
);
$options = [
'page-size' => 'A1',
'margin-top' => 10,
'margin-right' => 10,
'margin-bottom' => 10,
'margin-left' => 10,
];
$this->container->get('knp_snappy.pdf')->generateFromHtml(
$this->templating->render(
$twigInclude,
[
'htmlFiles' => $htmlFiles,
'headlines' => $headlines,
]
),
$folderHistory . '/reports/' . $filename . '.pdf',
$options,
true // this flag will overwrite existing file
);