与ghostscript c-api的接口,包括基于cTypes的高级和低级接口

python3-ghostscript的Python项目详细描述


Author:Hartmut Goebel <h.goebel@crazy-compiler.com>
Version:0.5dev
Copyright:GNU Public License v3 (GPLv3)
Homepage:http://bitbucket.org/htgoebel/python-ghostscript

Ghostscript,是postscript的著名解释器 语言和pdf格式。这个包实现了 Ghostscript C-API使用ctypes。无论是低级的还是Python的, 提供高级接口。

这个包目前只在gnu/linux下测试。请报告 它是否也适用于你的环境。谢谢。

示例

下面是一个如何使用 python鬼脚本。这实现了一个非常基本的ps2pdf工具:

import sys
import ghostscript

args = [
    "ps2pdf", # actual value doesn't matter
    "-dNOPAUSE", "-dBATCH", "-dSAFER",
    "-sDEVICE=pdfwrite",
    "-sOutputFile=" + sys.argv[1],
    "-c", ".setpdfwrite",
    "-f",  sys.argv[2]
    ]

ghostscript.Ghostscript(*args)

下面是一个将字符串文档传递给ghostscript的示例:

doc = """%!
/Helvetica findfont 20 scalefont setfont
50 50 moveto
(Hello World) show
showpage
"""

import ghostscript

args = """test.py
     -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=/tmp/out.pdf
     -c .setpdfwrite""".split()

GS = ghostscript.Ghostscript(*args)
try:
    GS.run_string(doc)
finally:
    GS.exit()

更多示例可以在 分发档案。

要求和安装

Please note:This package is meant for developers. Even if there are some usable examples included, installations instructions are meant for developers.

python ghostscript需要

安装python ghostscript

既然这个包是为开发人员准备的,我们假设您已经 有安装python包的经验。

python ghostscript列在PyPI (Python Package Index)上,因此 您可以像往常一样使用easy_installpip安装它。拜托 请参阅《简易安装手册》。pip进一步 信息。

或者我下载并解压 python ghostscript来自http://pypi.python.org/pypi/ghostscript和 运行:

python ./setup.py install

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JavaFX项目未显示   java JOGL启动时间太长   在Java中运行perl脚本   java在安卓中从json获得空字符串   java libgdx设置未设置java_主页   java Tomcat术语:停止vs杀死   java Hibernate:在数据库中将缺少参数的数据集插入为null   java如何创建一个类来扩展Android中的SparseArray?   java媒体播放器﹕ 错误(12147483648)   java将list1添加到list2并在不影响list2的情况下更新list1   java在JdbcCursorItemReader中打开CURSOR之前和关闭CURSOR之后执行SQL查询   基于注释的项目的java Spring集成“Integrationgraph”视图   java通过使用try-catch避免了无休止的空/空检查   素数序列