标签: ghostscript

C#Ghostscript Wrapper

有没有人在C#中遇到过GhostScript的好包装器.我的具体用途是采取附言并将其转换成PDF格式

c# ghostscript wrapper

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

将GhostScript 9.02升级到9.05

实际上我想将我现有的Ghostscript从版本9.02更新到9.05最新版本.当我在9.05包内运行make时,我得到以下错误:

if [ x != x ]; then LD_RUN_PATH=; export LD_RUN_PATH; fi; \     XCFLAGS= XINCLUDE= XLDFLAGS= XLIBDIRS= XLIBS= \     FEATURE_DEVS= DEVICE_DEVS= DEVICE_DEVS1= DEVICE_DEVS2= DEVICE_DEVS3= \  DEVICE_DEVS4= DEVICE_DEVS5= DEVICE_DEVS6= DEVICE_DEVS7= DEVICE_DEVS8= \     DEVICE_DEVS9= DEVICE_DEVS10= DEVICE_DEVS11= DEVICE_DEVS12= \    DEVICE_DEVS13= DEVICE_DEVS14= DEVICE_DEVS15= DEVICE_DEVS16= \   DEVICE_DEVS17= DEVICE_DEVS18= DEVICE_DEVS19= DEVICE_DEVS20= \   DEVICE_DEVS_EXTRA= \    /bin/sh <./obj/ldt.tr Undefined symbols for architecture x86_64:   "_iconv_open", referenced from:
      _opvp_to_utf8 in gdevopvp.o   "_iconv", referenced from:
      _opvp_to_utf8 in gdevopvp.o   "_iconv_close", referenced from:
      _opvp_to_utf8 in gdevopvp.o ld: symbol(s) not found for architecture x86_64 …
Run Code Online (Sandbox Code Playgroud)

macos ghostscript

5
推荐指数
1
解决办法
1345
查看次数

查询Ghostscript以获取输出设备的默认选项/设置(例如'pdfwrite'或'tiffg4')

这个答案中'GhostScript命令行参数将EPS转换为PDF' ; 据说pdfwriteGhostscript设备的默认分辨率是720x720,我最初觉得难以置信!

有没有办法列出Ghostscript设备的默认选项?

ghostscript

5
推荐指数
1
解决办法
6651
查看次数

Ghostscript转换PDF并输出文本文件

1.我需要将PDF文件转换为txt.file.我的命令似乎工作,因为我在屏幕上获得转换后的文本,但不知何故,我无法将输出定向到文本文件.

public static string[] GetArgs(string inputPath, string outputPath)
{ 
    return new[] {
                "-q", "-dNODISPLAY", "-dSAFER",
                "-dDELAYBIND", "-dWRITESYSTEMDICT", "-dSIMPLE",
                "-c", "save", "-f",
                "ps2ascii.ps", inputPath, "-sDEVICE=txtwrite",
                String.Format("-sOutputFile={0}", outputPath),
                "-c", "quit"
    }; 
}
Run Code Online (Sandbox Code Playgroud)

2.有一个unicode speficic .ps吗?

更新: 发布我的完整代码,可能错误在其他地方.

public static string[] GetArgs(string inputPath, string outputPath)
{
    return new[]    
    {   "-o c:/test.txt",    
        "-dSIMPLE",
        "-sFONTPATH=c:/windows/fonts",
        "-dNODISPLAY",
        "-dDELAYBIND",
        "-dWRITESYSTEMDICT",
        "-f",
        "C:/Program Files/gs/gs9.05/lib/ps2ascii.ps",               
        inputPath,
    };
}

[DllImport("gsdll64.dll", EntryPoint = "gsapi_new_instance")]
private static extern int CreateAPIInstance(out IntPtr pinstance, IntPtr caller_handle);

[DllImport("gsdll64.dll", EntryPoint = "gsapi_init_with_args")]
private static extern int …
Run Code Online (Sandbox Code Playgroud)

c# pdf ghostscript text-files

5
推荐指数
1
解决办法
7435
查看次数

CentOS 5.3上的GhostScript - 无法处理JPXDecode数据

我正在尝试让我们的服务器将PDF转换为图像文件.这是一个CentOS 5.3系统,已经安装了最新版本的ghostscript(8.70).

当我尝试转换PDF时,我会为每个页面重复以下错误,结果是加载了空白图像.

**** ERROR: Unable to process JPXDecode data. Page will be missing data.
Run Code Online (Sandbox Code Playgroud)

所以,我在这里找到了答案似乎回答了这个问题:

iText PDF; 如何使用Java将jpeg2000转换为jpg

之后我下载了iText 5.3.4和jai_imageio-1.1.jar,并在我的本地机器上编译了提供的脚本.当我在PDF上运行最终转换命令时,我得到:

java.lang.NullPointerException
at com.itextpdf.text.pdf.parser.PdfImageObject.decodeImageBytes(PdfImageObject.java:296)
at com.itextpdf.text.pdf.parser.PdfImageObject.<init>(PdfImageObject.java:199)
at com.itextpdf.text.pdf.parser.PdfImageObject.<init>(PdfImageObject.java:158)
at PDFConverter.hasJpeg2000(PDFConverter.java:36)
at PDFConverter.main(PDFConverter.java:15)
Doesn't contain any JPEG2000 images: Nothing to be done...
Run Code Online (Sandbox Code Playgroud)

我不确定这是否肯定说PDF没有任何JPEG2000图像,或者我编译脚本时是否做错了什么.也许我的iText版本错误,因为在其他问题的答案中没有提供链接.

所以现在我需要帮助来转换我的PDF以删除任何JPEG2000图像,或者我需要帮助才能使我们的服务器正常运行ghostscript.

centos5 ghostscript

5
推荐指数
0
解决办法
1588
查看次数

将PDF页面打印到网络打印机(IP地址)

我正在尝试将PDF页面打印到我们的网络打印机上.

我搜索并发现了大量类似的查询但是每个人都建议将网络打印机添加为本地打印机,它应该没问题.

我完全一样,能够打印,但使用打印机名称(而不是IP).

我的问题是,我们可以使用IP而不是打印机的名称打印它吗?

我需要这个,因为如果明天我们更改打印机然后我必须再次在代码中更改它.我目前正在使用GhostScript使用以下代码进行打印.

 string PrinterIP = "10.0.6.251"; //OKI B430(PL) - When I specify the name it works fine. but it gives me error with IP
 System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
 startInfo.Arguments = @" -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=" + Convert.ToString(1) + @" -sDEVICE=ljet4 -sOutputFile=""\\spool\" + PrinterIP + @""" """ + PDFFilePath + @"""";
 startInfo.FileName = "C:\\Program Files\\gs\\gs9.07\\bin\\gswin64c";//GhostScriptPath; 
 startInfo.UseShellExecute = false;
 system.Diagnostics.Process process = Process.Start(startInfo);
Run Code Online (Sandbox Code Playgroud)

c# ghostscript

5
推荐指数
0
解决办法
1408
查看次数

PHP未捕获异常'ImagickException',消息'FailedToExecuteCommand'

我已经通过pecl在MAC上安装了ImageMagick PHP扩展.它出现在phpinfo()下,并将PDF列为支持的格式.

我正在尝试阅读PDF并将其转换为图像.但是,当源是PDF时,构造函数会引发异常.图像文件成功运行.

$im = new imagick('TestDoc.pdf[0]'); // Throws Exception when PDF specified.
//$im = new imagick('TestImage.png'); // Succeeds.
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;


Fatal error: Uncaught exception 'ImagickException' with message 'FailedToExecuteCommand 
`"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -
dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 
"-r72x72" -dFirstPage=1 -dLastPage=1 "-sOutputFile=/var/tmp/magick-43594XlaRxeGWg1ps%d" "-
f/var/tmp/magick-43594O_WVqnAJTgzr" "-f/var/tmp/magick-43594ivJ_pKBcF3s7"' (-1) @ 
error/utility.c/SystemCommand/2029' in 
/Users/garys/Documents/Projects/accrivia/code/test/test.php:8 Stack trace: #0 
/Users/garys/Documents/Projects/accrivia/code/test/test.php(8): Imagick-
>__construct('../TestDoc.pdf[...') #1 {main} thrown in 
/Users/garys/Documents/Projects/accrivia/code/test/test.php on line 8
Run Code Online (Sandbox Code Playgroud)

输出中提到的tmp文件已创建,但为0字节.如果我在命令行中的消息中执行完整的'gs'命令(使用实际文件),它将成功运行.

使用brew安装ImageMagick和GhostScript.

在PHP中,系统('echo $ PATH'); 给/ usr/bin:/ bin:/ …

php pdf imagemagick ghostscript

5
推荐指数
1
解决办法
2391
查看次数

如何缩小tesseract生成的PDF的大小?

我的(网络)应用程序的设置如下:我得到用户上传的PDF文件,在它们上运行OCR并向他们显示OCRed PDF。由于所有内容都在线,因此最小化生成的PDF文件的大小是减少用户加载和等待时间的关键。

我从用户那里收到的文件是sample.pdf(我创建了一个包含原始文件以及在此处生成的文件的存档:https : //dl.dropboxusercontent.com/u/1390155/tess-files/sample .zip)。我使用tesseract 3.04并执行以下操作:

gs -r300 -sDEVICE=tiff24nc -dBATCH -dNOPAUSE -sOutputFile=sample.tiff sample.pdf
tesseract sample.tiff sample-tess -l fra -psm 1 pdf
Run Code Online (Sandbox Code Playgroud)

OCR的结果很好,但是现在生成的PDF的大小约为2.5倍

  • 原始pdf文件大小:60k
  • 最终PDF大小:14.7万

所以我问你,如何在保持OCR结果的同时减小生成的PDF的大小?

一种明显的解决方案是在生成tiff时降低分辨率,但是我不想这样做,因为它可能会影响OCR结果。

我尝试的第二件事是使用ghostscript减少了tesseract后的PDF大小:

gs -o sample-down-300.pdf   -sDEVICE=pdfwrite   -dDownsampleColorImages=true \
   -dDownsampleGrayImages=true   -dDownsampleMonoImages=true  \
   -dColorImageResolution=300   -dGrayImageResolution=300  \
   -dMonoImageResolution=300   -dColorImageDownsampleThreshold=1.0  \
   -dGrayImageDownsampleThreshold=1.5   -dMonoImageDownsampleThreshold=1.0 \
    sample-tess.pdf 
Run Code Online (Sandbox Code Playgroud)

这会有所帮助,生成的文件只有101K,因此约为原始文件的1.5倍。我可以接受,但它似乎也会影响OCR结果。例如,现在缺少“餐厅”和“比萨店”(第二行)之间的空白。

带有ghostscript的另一个(更简单)选项(使用ebook参数)导致PDF文件中的质量较差的43k文件,并且存在缺少空白的相同问题:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \
    -dNOPAUSE -dBATCH  -dQUIET -sOutputFile=sample-ebook.pdf \
     sample-tess.pdf
Run Code Online (Sandbox Code Playgroud)

较低质量的PDF很好,但是我还是不想在OCR上妥协。

我已经使用PNG和JPEG完成了其他测试,但是OCR结果总是下降(甚至略有下降),并且结果PDF不会更小。例如,使用PNG:

convert -density 300 sample.pdf -transparent white sample.png
tesseract sample.png sample-tess-png -l fra -psm 1 pdf
Run Code Online (Sandbox Code Playgroud)

总数(55.50)丢失,最终PDF大小为149k。 …

pdf ocr pdf-generation tesseract ghostscript

5
推荐指数
1
解决办法
2976
查看次数

R无法识别GhostScript嵌入eps图

我正在尝试为期刊出版要求嵌入.eps文件.

我使用ggplot2创建我的情节:

p=ggplot(data=sim, aes(x=TIME,y=DV,group=ID))+
  theme_few()+
  geom_point(aes(shape=as.factor(SEASON2)),size=3,fill="white")+
  geom_point(aes(color=as.factor(AGE2),shape=as.factor(SEASON2)),size=3,fill="white",show_guide=F)+
  scale_shape_manual(name="Season",values=c(25,24))+
  geom_line(aes(color=as.factor(AGE2),linetype=as.factor(MODEL2)),size=0.75)+
  scale_linetype_manual(name="Model [Population]",values=c("dotted","solid"))+
  scale_color_manual(name="Age",values=as.vector(c(ggthemes_data$few$medium[5],ggthemes_data$few$medium[4])))+
  theme(legend.position="bottom",legend.direction="vertical",legend.box="horizontal")+
  guides(color=guide_legend(order=1), shape=guide_legend(order=2), linetype=guide_legend(order=3))+
  xlab("Clock time [hours]")+
  ylab("Testosterone levels [ng/dL]")+
  geom_hline(yintercept=300,linetype="dashed",color="black")
print(p)
Run Code Online (Sandbox Code Playgroud)

然后,我生成.eps

postscript(file.path(directory,"Script","Figure5.eps"),
           width=10,
           height=12.25,
           paper="a4",
           horizontal=T,
           onefile=TRUE)
print(p)
dev.off()
Run Code Online (Sandbox Code Playgroud)

当我尝试提交剧情时,这个.eps不被在线应用程序接受,因为我必须让ADQ Advisor可以使用这些字体.

为了做到这一点,我用过:

install.packages("extrafont")
library("extrafont")
font_import()
fonts()
loadfonts(device = "postscript") ## for postscript()

embed_fonts("./Figure5.eps", outfile = "./Figure5-embed.eps", options = "-dEPSCrop")

embedFonts(file="Figure5.eps",
          outfile="Figure5EMB.eps",
          options="-dEPSCrop")
Run Code Online (Sandbox Code Playgroud)

这两个函数都失败了,并给了我以下错误:

embedFonts出错(file ="Figure5.eps",outfile ="Figure5EMB.eps",:找不到GhostScript

我在以下路径中安装了GhostScript 9.18:C:\ Program Files(x86)\ gs\gs9.18

有什么建议?

r ghostscript eps

5
推荐指数
1
解决办法
2021
查看次数

ghostscript pdfwrite指定jpeg质量

我正在尝试连接多个pdf文件,这些文件基本上是包含jpg图像的相册的页面。对于我的输出pdf文件,我希望将图像分辨率调整为300 dpi,并希望保持最佳质量。我正在使用的命令是:

gswin64c.exe -dNOPAUSE -dBATCH ^-dDownsampleColorImages=true -dColorImageResolution=300 ^-dDownsampleGrayImages=true -dGrayImageResolution=300 ^-dDownsampleMonoImages=true -dMonoImageResolution=300 ^-sDEVICE=pdfwrite -dJPEGQ=100 -sOutputFile=out.pdf in1.pdf in2.pdf
Run Code Online (Sandbox Code Playgroud)

但是,似乎-dJPEGQ = 100对输出没有影响。更改此参数将导致相同的文件大小,并且在所有值的图像中都可以看到伪像。使用-dPDFSETTINGS = / printer选项运行命令可以获得更好的结果,没有伪影,但是此选项也应产生300 dpi。那么在输出文件中指定jpg图像质量的正确命令是什么?

pdf-generation ghostscript

5
推荐指数
1
解决办法
2123
查看次数

标签 统计

ghostscript ×10

c# ×3

pdf ×3

pdf-generation ×2

centos5 ×1

eps ×1

imagemagick ×1

macos ×1

ocr ×1

php ×1

r ×1

tesseract ×1

text-files ×1

wrapper ×1