与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如何修复尝试将用户签名到服务器主机时出现的“字符串无法转换为json对象”错误?   控制台Java:不使用新行更新命令行中的文本   java servlet接收xml数据时,出现错误   使用REST API在Bitbucket中复制或复制存储库   java如何在JavaFX中对齐一行?   java如何在活动中显示通过服务获得的数据?   返回BigDecimal作为字符串:返回int   java组织。openqa。硒。InvalidSelectorException:尝试查找元素时选择器无效   java仅在阻塞状态下通知和通知所有影响线程   java JBOSS无法启动部署   java方法的返回值能保证类型安全吗?   JavaeShadoop序列化组织。阿帕奇。hadoop。木卫一。短写失败   java如果我在同一个类上同步了两个方法,它们能同时运行吗?   不使用java数据库的spring分页实现   java如何将字符串切碎成这样的数组?