问题
I am using DomPDF to generate PDF-Files. This works fine, but I want to set the default page layout which is used by opening the document. I want to have a 100% view when the document is viewed. Actually the page is streched to the max width of the window. Does anybody know a solution how to set the page layout to "single site"?
Regards, Lothron
回答1:
You can do this in dompdf by specifying the view in a meta element, e.g.
<meta name="dompdf.view" content="FitV" />
or
<meta name="dompdf.view" content="XYZ,0,0,1" />
You can also call the set_default_view()
method of the canvas class, e.g.
$dompdf->get_canvas()->set_default_view('FitV')
Using the above method can only be done after the PDF document has been instantiated. As of dompdf 0.6.1 that is done after calling $dompdf->render()
.
Ref: https://groups.google.com/d/msg/dompdf/7L2xMLwmH-Y/Et2mBNny51QJ
来源:https://stackoverflow.com/questions/26323882/set-the-default-page-layout-of-a-pdf-file-with-dompdf