使用突出显示将源代码转换为pdf

[英]convert source code to pdf with highlighting


i have a site where people can download source code, sorta paste type site, i want them to be able to download a pdf version, sorta on the fly type.

我有一个网站,人们可以下载源代码,sorta粘贴类型网站,我希望他们能够下载PDF版本,在飞行类型sorta。

i been using dompdf for other projects, but it seems i cant do the highlighting, it tries to parse the actual php code.

我一直在使用dompdf用于其他项目,但似乎我不能突出显示,它试图解析实际的PHP代码。

ive used pdf24.org online converter and it does the highlighting, but since its not open source i cant implement it.

香港专业教育学院使用pdf24.org在线转换器,它突出显示,但由于它不是开源我不能实现它。

ive tried using highlight_file, but all it does is spit out the contents in the browser, even if i set output to false.

香港专业教育学院尝试使用highlight_file,但它只是吐出浏览器中的内容,即使我将输出设置为false。

any suggestions?

thanks.

2 个解决方案

#1


1  

highlight_file is correct,

highlight_file是正确的,

require_once("dompdf_config.inc.php");
$html = highlight_file(..., $return=true);

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");

#2


2  

Have a look at enscript. I've used it for printing source code to PDF and it does an excellent job. You can call it with a system() call if you need to do this from PHP.

看看enscript。我用它来打印源代码到PDF,它做得很好。如果需要从PHP执行此操作,可以使用system()调用来调用它。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2011/01/08/3a6b53f5115ba64950015b97b9f1220.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号