我正在尝试设置以厘米或毫米为单位的自定义尺寸,但它不起作用。我找不到可以让我了解如何做到这一点的示例。
我尝试过这段代码,但没有成功
Configure::write('CakePdf', array(
'engine' => 'CakePdf.DomPdf',
'options' => array(
'print-media-type' => false,
'outline' => true,
'dpi' => 96
),
'margin' => array(
'bottom' => 15,
'left' => 50,
'right' => 30,
'top' => 45
),
'orientation' => 'Portrait',
'download' => false,
'pageSize' => '2cm 2cm'
));
如果我写 'pageSize' => 'LETTER',那就可以了..但我需要自定义尺寸。
提前致谢!!!
最佳答案
您使用什么 pdf 引擎?
如果是wkhtmltopdf,这里是基于https://github.com/wkhtmltopdf/wkhtmltopdf/blob/master/src/lib/pdfsettings.cc支持的列表
DLL_LOCAL QMap<QString, QPrinter::PageSize> pageSizeMap() {
QMap<QString, QPrinter::PageSize> res;
res["A0"] = QPrinter::A0;
res["A1"] = QPrinter::A1;
res["A2"] = QPrinter::A2;
res["A3"] = QPrinter::A3;
res["A4"] = QPrinter::A4;
res["A5"] = QPrinter::A5;
res["A6"] = QPrinter::A6;
res["A7"] = QPrinter::A7;
res["A8"] = QPrinter::A8;
res["A9"] = QPrinter::A9;
res["B0"] = QPrinter::B0;
res["B1"] = QPrinter::B1;
res["B10"] = QPrinter::B10;
res["B2"] = QPrinter::B2;
res["B3"] = QPrinter::B3;
res["B4"] = QPrinter::B4;
res["B5"] = QPrinter::B5;
res["B6"] = QPrinter::B6;
res["B7"] = QPrinter::B7;
res["B8"] = QPrinter::B8;
res["B9"] = QPrinter::B9;
res["C5E"] = QPrinter::C5E;
res["Comm10E"] = QPrinter::Comm10E;
res["DLE"] = QPrinter::DLE;
res["Executive"] = QPrinter::Executive;
res["Folio"] = QPrinter::Folio;
res["Ledger"] = QPrinter::Ledger;
res["Legal"] = QPrinter::Legal;
res["Letter"] = QPrinter::Letter;
res["Tabloid"] = QPrinter::Tabloid;
return res;
}
确保您使用的大小写正确。 希望这可以帮助。您和其他有同样问题的人。 :D
关于php - Cakepdf页面大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22580526/