标签: ghostscript

将PCL转换为PDF

我希望创建(作为概念验证)OCaml(最好)程序,将PCL代码转换为PDF格式.我不知道从哪里开始.这样做有标准化的算法吗?是否有其他建议可用于完成此任务?

谢谢!

pdf ocaml printer-control-language ghostscript

6
推荐指数
1
解决办法
9267
查看次数

防止Ghostscript将错误写入标准输出

我正在使用Ghostscript将PDF文件的第一页栅格化为JPEG.为避免创建临时文件,PDF数据通过管道传输到Ghoscripts的stdin中,JPEG在stdout上"耗尽".这个管道就像一个魅力,直到GS收到无效的PDF数据:而不是像我期望的那样在stderr上报告所有错误消息,它仍然将一些消息写入stdout.

重现:

$ echo "Not a PDF" >test.txt
$ /usr/bin/gs -q -sDEVICE=jpeg -dBATCH -dNOPAUSE -dFirstPage=1 -dLastPage=1 \
    -r300 -sOutputFile=- - < test.txt 2>/dev/null
Error: /undefined in Not
Operand stack:

Execution stack:
...
Run Code Online (Sandbox Code Playgroud)

请注意,2>/dev/null上述内容不会抑制错误消息.Ghostscript的文档已经警告过,写入stdout需要使用-q标志来抑制stdout上的消息,但我似乎仍然缺少一些东西.

stdout ghostscript stderr

6
推荐指数
1
解决办法
7041
查看次数

是否可以使用ghostscript检查pdf是否受密码保护?

是否可以使用ghostscript检查pdf是否受密码保护?什么是命令?我知道你可以使用ghostscript删除pdf密码,但我想做的只是检查PDF是否受密码保护或启用安全性.

ghostscript

6
推荐指数
1
解决办法
5493
查看次数

如何在linux中的postscript或pdf文件的每一页底部添加页脚?

所以我想在pdf文件的每一页的底部添加一个"页脚"(一个属性),我通过linux中的groff通过postscript生成.我正在使用ps2pdf工具将文件从ps转换为pdf,因此我可以访问这两种格式.

这两个帖子有点帮助:

如何将页码添加到Postscript/PDF

如何在postscript文件上创建程序覆盖文本?

我并不反对使用第一种方法,但我无法访问pdflatex第一个脚本中提到的实用程序,也无法在需要执行此操作的计算机上安装它.

看起来第二种方法可能会起作用,但我安装了版本8.15的ghostscript,并且我没有看到手册页上列出的许多标志(http://unix.browserdebug.com/man/gs/).我想我可以访问"-c"标志来插入一些postscript代码,即使它没有列出.无论如何,这是我尝试过的两个命令:

gs -o output.pdf -sDEVICE=pdfwrite -g5030x5320 \
-c "/Helvetica-Italic findfont 15 scalefont setfont 453 482 moveto (test-string) show" \
-f input.ps

这给了我这个:

Unknown switch -o - ignoring
ESP Ghostscript 815.02 (2006-04-19)
Copyright (C) 2004 artofcode LLC, Benicia, CA.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
ERROR: /undefinedfilename in (output.pdf)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval-- …

unix linux pdf postscript ghostscript

6
推荐指数
2
解决办法
6386
查看次数

通过调用名称在Windows中调用Ghostscript?

我应该怎么做才能通过其调用名称在Windows中调用Ghostscript?我将Ghostscript bin文件夹添加到Windows PATH和Path变量,但它不起作用,'gswin32c.exe'和'gswin32c'都没有.注销然后重新登录也没有用.我该如何解决这个问题?也许我使用了错误的调用名称?

windows command-line path ghostscript

6
推荐指数
2
解决办法
2万
查看次数

将可搜索的PDF转换为不可搜索的PDF

我有一个可搜索的PDF,我需要将其转换为不可搜索的PDF.

我尝试使用Ghostscript并将其更改为JPEG,然后返回到PDF,这样可以解决问题,但文件大小太大而且不可接受.

我尝试使用Ghostscript将PDF首先转换为PS,然后使用PDF将其转换为诀窍,但质量不够好.

gswin32.exe -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -r1000 -sOutputFile=out.ps in.pdf
gswin32.exe -q -dNOPAUSE -dBATCH -dSAFER -dDEVICEWIDTHPOINTS=596 -dDEVICEHEIGHTPOINTS=834 -dPDFSETTINGS=/ebook -sDEVICE=pdfwrite -sOutputFile=out.pdf out.ps
Run Code Online (Sandbox Code Playgroud)

有没有办法为PDF提供高质量的产品?

或者,是否有更简单的方法将可搜索的PDF转换为不可搜索的PDF?

pdf ghostscript

6
推荐指数
1
解决办法
5631
查看次数

使用记录的ghostscript语法时,继续在ghostscript中获取错误消息

我是ghostscript的新手,我无法弄清楚语法.每当我尝试最简单的命令ex -h或 - ?我收到错误,我已经尝试了各种组合.

    GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.

GS>-h
Error: /undefined in -h
Operand stack:

Execution stack:
  %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval-
-   2   %stopped_push   --nostringval--   --nostringval--   %loop_continue   --n
ostringval--   --nostringval--   false   1   %stopped_push   .runexec2   --nostr
ingval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval
--
Dictionary stack:
   --dict:1166/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file …
Run Code Online (Sandbox Code Playgroud)

windows ghostscript

6
推荐指数
2
解决办法
1万
查看次数

使用Ghostscript密码保护PDF

我需要在php中使用ghostscript对PDF文件进行密码保护.

这些文件将使用简单的形式上传到服务器(我不需要任何帮助),但它们起初没有任何保护.所以我想使用exec函数和ghostscript为它们设置密码保护.但我找不到ghostscript查询应该是什么样的地方.

例如,我有一个名为File.pdf的PDF文件.我上传它然后我需要保护它并称之为File_protected.pdf.

我试图这样做,但'.ps'文件权重太大,最终File_protected.pdf中没有密码:

exec("gs -dNOPAUSE -dBATCH -sDEVICE=pswrite -sOutputFile=File.ps File.pdf");
exec("gs -dNOPAUSE -dBATCH -sPDFPassword=password -sDEVICE=pdfwrite -sOutputFile=File_protected.pdf File.ps");
Run Code Online (Sandbox Code Playgroud)

php pdf ghostscript password-protection

6
推荐指数
3
解决办法
8135
查看次数

使用Ghostscript将PDF转换为JPEG

我正在使用Ghostscript使用Ghostscript将我的PDF文件转换为JPEG,效果很好。

对于我的输出图像我正在使用%03d的文件名,这样的文件名出来001002...等根据页码。

但在某些情况下,我希望数字从更高的数字开始。

例如,我处理了两页的文件,因此输出图像是page001.jpgpage002.jpg

现在,我要处理其它PDF和,而不是替换这些文件,我想创建page003.jpgpage004.jpg

如何才能做到这一点?

这是我现在使用的完整命令行:

'C:\gs\gs9.14\bin \gswin64c -dNOPAUSE -sDEVICE=png16m \
  -sOutputFile=page-%03d.jpg -r100x100 -q' . $pdf_file. '-c quit'
Run Code Online (Sandbox Code Playgroud)

pdf image ghostscript

6
推荐指数
2
解决办法
1万
查看次数

将扫描的pdf转换为文本python

我有一个扫描的pdf文件,我尝试从中提取文本。我尝试使用pypdfocr在其上进行ocr,但出现错误:

“在通常的地方找不到ghostscript”

搜索后,我找到了在Windows平台中将Ghostscript链接到pypdfocr的解决方案,我尝试下载GhostScript并将其放入环境变量中,但仍然存在相同的错误。

如何使用python在扫描的pdf文件中查找文本?

谢谢。

编辑:这是我的代码示例:

import os
import sys
import re
import json
import shutil
import glob
from pypdfocr import pypdfocr_gs
from pypdfocr import pypdfocr_tesseract 
from PIL import Image

path = PATH_TO_MY_SCANNED_PDF
mainL = []
kk = {}


def new_init(self, kk):
    self.lang = 'heb'   
    self.binary = "tesseract"
    self.msgs = {
            'TS_MISSING': """ 
                Could not execute %s
                Please make sure you have Tesseract installed correctly
                """ % self.binary,
            'TS_VERSION':'Tesseract version is too old',
            'TS_img_MISSING':'Cannot find specified tiff …
Run Code Online (Sandbox Code Playgroud)

python pdf ocr ghostscript

6
推荐指数
3
解决办法
2万
查看次数