是否可以检查 php imagick 扩展以获取 ghostscript 支持?
例如,如果它被打开/关闭,使用的 ghostscript 版本等。
有哪些可能性可以获得额外的 ghostscript / pdf 详细信息?
到目前为止,我唯一发现的是这个(imagick lib 本身的版本):
http://php.net/manual/en/imagick.getversion.php
ps:不允许从php内部调用系统调用(例如exec)
我正在尝试使用 GhostScript 从 pdf 创建图像。这是我的代码:
GhostscriptWrapper.ConvertToBMP(inputPDFFilePath, outputBMPFilePath);
Run Code Online (Sandbox Code Playgroud)
这是我的GhostscriptWrapper课:
public class GhostscriptWrapper
{
public static void ConvertToBMP(string inputPath, string outputPath)
{
CallAPI(GetArgs(inputPath, outputPath));
}
private static void CallAPI(string[] args)
{
IntPtr ptr;
CreateAPIInstance(out ptr, IntPtr.Zero);
InitAPI(ptr, args.Length, args);
Cleanup(ptr);
}
private static void Cleanup(IntPtr gsInstancePtr)
{
ExitAPI(gsInstancePtr);
DeleteAPIInstance(gsInstancePtr);
}
[DllImport("gsdll32.dll", EntryPoint="gsapi_new_instance")]
private static extern int CreateAPIInstance(out IntPtr pinstance,
IntPtr caller_handle);
[DllImport("gsdll32.dll", EntryPoint="gsapi_delete_instance")]
private static extern void DeleteAPIInstance(IntPtr instance);
[DllImport("gsdll32.dll", EntryPoint="gsapi_exit")]
private static extern int ExitAPI(IntPtr instance);
[DllImport("gsdll32.dll", EntryPoint="gsapi_init_with_args")]
private …Run Code Online (Sandbox Code Playgroud) 我需要使用PHP将PDF文件解析为图像.我是在Ghostscript的帮助下完成的.这是脚本:
$result = exec("gs -sDEVICE=png16m -sOutputFile=page-%03d.png $pdfname.pdf");
Run Code Online (Sandbox Code Playgroud)
但几乎所有最终图像都有白色边框(PDF页面没有这些边框).如何摆脱它们?也许在Ghostcript代码中有一些我找不到的方法,哪些方法会有所帮助.
这是一张图片 - > http://www.pictureshack.ru/images/88046_page-009.png
这是一个PDF文件的版画屏幕 - > http://www.pictureshack.ru/images/62869_pdf.PNG
我放了文本示例使用以下 PostScript 代码
\n\n<<\n /EndPage {\n exch pop 2 lt { \n gsave\n /Arial-Bold 120 selectfont\n .5 setgray 100 100 moveto 45 rotate (Sample) show\n grestore\n true}\n {false}\n ifelse\n } bind\n>> setpagedevice\nRun Code Online (Sandbox Code Playgroud)\n\n这会将文本置于 [100; 100]位置。但我需要将此文本居中(会计文本被旋转)。
\n\n如何在页面中央对齐45\xc2\xb0 旋转文本?
\n我有一个 10 页的 pdf 文件,我想将其每两页合并为一页,例如 1,2->1 : 3,4->2 : 等等...我了解了 Ghostscript 但是这些是压缩 .pdf 的工具,也有一些实用程序可以将两个或多个 pdf 合并为一个,但不幸的是我找不到任何可以合并同一 pdf 中的页面的工具。请帮忙!
我正在尝试使用 ghostscript 将 pdf 文档转换为图像。所需的 dpi 设置为 72 像素,这应该足够高,以便文本显示清晰,但大部分文本难以辨认。
我可以提高 dpi,但这会导致我不想拥有的非常大的图像文件。
我知道ghostscript 有一些参数可以添加抗锯齿等(例如-dDOINTERPOLATE)。如何将它们添加到以下代码中,或者有更好的方法来做到这一点?
int desired_x_dpi = 72;
int desired_y_dpi = 72;
GhostscriptRasterizer _rasterizer = new GhostscriptRasterizer();
_rasterizer.Open(inputPdfPath, localDllInfo, false);
for (int pageNumber = 1; pageNumber <= _rasterizer.PageCount; pageNumber++)
{
string pageFilePath = Path.Combine(outputPath, "Page-" + pageNumber.ToString() + ".png");
Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber);
img.Save(pageFilePath, ImageFormat.Png);
}
Run Code Online (Sandbox Code Playgroud) 如何使用 Ghostscript 创建空白页面?我想在将多个 PDF 合并在一起时执行此操作,例如:
`gs -dNOPAUSE -o /path/to/output input1.pdf <blank-page-here> input2.pdf
Run Code Online (Sandbox Code Playgroud) 使用命令行 Ghostscript,是否可以删除 PDF 中重复的嵌入对象(图像)并将其替换为单个实例?
我有一个 200 多页的 PDF,每页上都有背景图像和一些较小的徽标。该文件非常大,因为完全相同的背景图像和徽标二进制文件嵌入在每个单独的页面中,而不是嵌入一次然后在每个页面上引用。我不是 PDF 的创建者,所以我无法从源头上解决问题。
(我不想缩小或降低图像质量,也不想完全删除它们。)
在 Revolution R Enterprise 控制台中,
devtools::check("C:/Users/User/Documents/Revolution/mypackage")
Run Code Online (Sandbox Code Playgroud)
产生
checking sizes of PDF files under 'inst/doc' ... NOTE
Unable to find GhostScript executable to run checks on size reduction
Run Code Online (Sandbox Code Playgroud)
没有任何其他警告/错误/注释。所以,(尽管 AFAIK 这个注释对于最终检查来说不是那么重要),我想摆脱这个警告(因为我想把 .PDF 文件放入mypackage\inst\docR 之外生成的文件夹中)。
我的笔记本中安装了 Ghostscript。我通过以下方式获得帮助:
> help("R_GSCMD")
R_GSCMD: Optional. The path to Ghostscript, used by dev2bitmap, bitmap and embedFonts.
Consulted when those functions are invoked.
Since it will be treated as if passed to system, spaces and shell metacharacters should be escaped.
> Sys.getenv("R_GSCMD")
[1] ""
Run Code Online (Sandbox Code Playgroud)
我所做的(并再次出错)是:
> …Run Code Online (Sandbox Code Playgroud) 有没有办法用命令行在每个pdf上添加水印?因为我需要从代码中设置参数
'gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="7ed753c56994067cb0c8dc18fbf14921.pdf" "b79d2282c15b7e824cb8ee400401161d.pdf" "f21958c0b3a4a01fe22c9a60b6e15121.pdf" "d46615b5dd7b6e6565ef1ce8b117b860.pdf" "f46ea9512f5763693c84d8061eeff742.pdf"'
我只需要设置水印、不透明度、位置 x、y 和宽度\高度的路径
ghostscript ×10
pdf ×6
c# ×2
php ×2
.net ×1
asp.net ×1
border ×1
center ×1
command-line ×1
duplicates ×1
imagick ×1
linux ×1
pdftk ×1
postscript ×1
r ×1
rotation ×1
setenv ×1
shell ×1
text ×1
watermark ×1