Using dompdf with absolute links

此生再无相见时 提交于 2019-12-01 12:11:26

You're loading a file via the file system. That means all references to external files that don't include a domain part in the path are rendered relative to the file system. You can reference files in three ways:

  • Full URL (including domain), e.g. http://example.com/image.png. These are always read from the URL specified.
  • Absolute path, e.g. /file/path/image.png. This is read relative to the root of the file system, not the root of the web site, or the user's home directory (in the case of shared hosting).
  • Relative path (no leading slash), e.g. file/path/image.png. This is read relative to the HTML file. So in your case the file would be read from /Volumes/Documents/VirtualSites/jasss/16/2/file/path/image.png.

Calling $dompdf->set_base_path() only affects the relative path.

You'll have to modify the absolute file references to include the path to the website root, e.g. /Volumes/Documents/VirtualSites/jasss/styles/jasssarticle.css, or load the file via the website, e.g. http://jasss.soc.surrey.ac.uk/16/2/1.html.

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