doumu6941 2016-08-05 01:14
浏览 76

在dompdf中,相对于“setBasePath”函数是什么?

I am rendering some html pages in dompdf. But It doesn't seem to be able to include my images or external css files. If I simply print the page to the screen everything works fine. But dompdf can't find them.

I found a function called: setBasePath where the documentation states "Sets the base path used for external stylesheets and images." Sound like what I want but what is this base path relative too? I tried entering relative to root but it still doesn't find anything.

$dompdf = new Dompdf();
$dompdf->loadHtml($template);
$dompdf->setBasePath(realpath('./'));
$dompdf->render();
$dompdf->stream('note');
  • 写回答

1条回答 默认 最新

  • douniewei6346 2016-08-08 17:11
    关注

    The base path is the path used when a resource is references using a relative path (e.g. inc/site.css). For resources referenced using absolute paths or full URIs the base path would not be used.

    As with any other running script Dompdf doesn't have knowledge of any root path other than the file system root. Thus, any absolute path is read from the root of the file system. Relative paths are determined based on the current working directory (CWD) of the executing PHP script.

    In your example you set the base path relative to ./ which would be the same as the base path already used by dompdf when loading a document using $dompdf->loadHtml(). To give a more complete answer it would help to have more information on your file layout and how you reference those files in the HTML.

    Try this discussion for more information on how resource references are interpreted.

    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?