我已经从MacPorts安装了Ghostscript,并且我试图从PHP脚本调用它来从多页PDF文件中提取单页然后输出它.我的代码看起来像这样:
<?php
$cmd = '/opt/local/bin/gs -sDEVICE=pdfwrite -dNOPAUSE \
-dBATCH -dSAFER -dFirstPage=20 -dLastPage=20
-sOutputFile=%stdout "/path/to/input/pdf.pdf"';
// Will uncomment this when it works
// header("Content-Type: application/pdf");
putenv("GS_LIB=/opt/local/share/ghostscript/9.02/lib");
putenv("GS_FONTPATH=/opt/local/share/ghostscript/fonts");
putenv("TMPDIR=/tmp");
passthru($cmd);
Run Code Online (Sandbox Code Playgroud)
当我在网络浏览器中点击此脚本时,我看到:
GPL Ghostscript 9.02 (2011-03-30) Copyright (C) 2010 Artifex Software, Inc.
All rights reserved. This software comes with NO WARRANTY: see the file
PUBLIC for details. **** Unable to open the initial device, quitting.
Run Code Online (Sandbox Code Playgroud)
相同的命令来自shell.
| 归档时间: |
|
| 查看次数: |
4679 次 |
| 最近记录: |