Set the default page layout of a PDF file with DomPDF

你。 提交于 2021-02-10 19:43:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!