对于我的项目工作,我将Inkscape用于两个任务:
File -> Document Properties --> Resize page to content...这个任务相当简单,但是对于更多的图纸来说是很费时的.
我检查了Inkscape中的宏功能,但是没有这样的功能。但是,我发现Inkscape允许使用Python实现自己的扩展脚本。
如果您有类似的经验,请帮助我实现上面列出的作为Inkscape扩展的步骤。
潜在有用的链接:http://wiki.inkscape.org/wiki/index.php/PythonEffectTutorial
编辑:接受的答案并不是使用内部python扩展来解决我的请求,而是通过使用inkscape命令行选项来解决任务。
发布于 2015-08-06 03:35:13
我从未从inkscape内部编写过脚本,但我一直使用python的inkscape (通过子流程模块)。如果在命令行中键入inkscape --help,您将看到所有选项。我相信对于您的用例,以下几点将有效:
inkscape -D -A myoutputfile.pdf myinputfile.whatever-A要求输出到PDF (需要文件名),而-D告诉它调整绘图的大小。
如果您从未使用过子流程模块,那么最简单的方法就是像这样使用subprocess.call:
subprocess.call(['inkscape', '-D', '-A', outfn, inpfn])编辑:
最无耻的脚本(未经测试!)要处理在命令行上传递的输入文件名,如下所示:
import sys
import os
# Do all files except the program name
for inpfn in sys.argv[1:]:
# Name result files 'resized_<oldname>.pdf'
# and put them in current directory
shortname = os.path.basename(inpfname).rsplit('.',1)[0]
outfn = 'resized_%s.pdf' % shortname
subprocess.call(['inkscape', '-D', '-A', outfn, inpfn])https://stackoverflow.com/questions/31841071
复制相似问题