php 如何在dompdf中应用bootstrap样式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29985728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to apply bootstrap style in dompdf
提问by MayuriS
I'm using bootstrap grid to display and i want that my client download it in pdf so for that i'm using dompdf but dompdf is not able to apply bootstrap style. I cannot go back and turn my bootstrap grid to basic html tables and using different plugin to convert to pdf i found them difficult and time consuming(especially in installing composer and then updating i'm new ) is there any way out so that i can easily apply bootstrap style to my pdf
我正在使用引导程序网格来显示,我希望我的客户端以 pdf 格式下载它,因此我使用的是 dompdf 但 dompdf 无法应用引导程序样式。我不能回去将我的引导程序网格转换为基本的 html 表并使用不同的插件转换为 pdf 我发现它们既困难又耗时(特别是在安装作曲家然后更新我是新的)有什么办法可以让我可以轻松地将引导程序样式应用于我的 pdf
$pr_dt=$_POST['hid'];//div elements which i want ot convert them to pdf and also contain bootstap lib link
include_once("../assets/converter/dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($pr_dt);
$dompdf->render();
$dompdf->stream("MRA.pdf");
or at least is there any online converter for bootstrap grid to html tables
或者至少是否有任何用于引导网格到 html 表的在线转换器
回答by alan0xd7
You need to make sure dompdf can find your CSS files. You can do this with set_base_path
, for example:
您需要确保 dompdf 可以找到您的 CSS 文件。您可以使用 来执行此操作set_base_path
,例如:
$dompdf->set_base_path("/www/public/css/");
You also need a to specify the CSS file, something like:
您还需要指定 CSS 文件,例如:
<html>
<head>
<link type="text/css" href="style.css" rel="stylesheet" />
</head>
<body>
...
回答by chemalarrea
Include before the html code:
在 html 代码前包含:
$html = '<link rel="stylesheet" href="/css/bootstrap.min.css" />';
回答by Sunil duggal
'in response to the now i'm getting Cannot find Font class fontmetrics_cls.php on line 346'
'响应现在我在第 346 行找不到字体类 fontmetrics_cls.php'
This happens as you need to add Dompdf to your applications config to include modules. In zf2 its application.config.php in the modules section I hope that helps as I went hours looking for that without any documentation.
发生这种情况是因为您需要将 Dompdf 添加到您的应用程序配置以包含模块。在 zf2 中,它在模块部分的 application.config.php 我希望能有所帮助,因为我在没有任何文档的情况下花了几个小时寻找它。