使用 Batik 将 svg 转换为 pdf 在 Ubuntu 11.10 上不起作用
我正在尝试使用 Ubuntu-11.10 上的 Batik SVG 工具包将 svg 图像转换为 pdf。 我安装了 Batik 1.7 和 Fop 0.95。在终端中运行以下命令时:
java -jar /usr/java/share/batik-rasterizer.jar -m application/pdf /home/user/Batik_Test/colors.svg
-scriptSecurityOff
我收到以下错误:
转换文件时出错:
错误:无法访问 application/pdf 类型图像的转码器
我做的一件事请注意,文件 'pdf-transcoders.jar' 不在机器上,因此我将其添加到 /usr/share/java 中,以防万一这是问题所在,但这并没有什么区别。
如果有在 ubuntu 上使用 Batik 的经验,我将不胜感激。我缺少什么?
-J
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在 /usr/java/share/ 目录中有 java 可执行文件 batik-rasterizer.jar,则可以创建一个名为 的目录>lib 位于同一路径 (/usr/java/share/) 中,
以便
包含/usr/java/share/lib
在最新的目录中 (< strong>lib)您将复制pdf-transcoder.jar 因此要拥有
/usr/java/share/lib/pdf-transcoder.jar
无论如何,您还需要其他库除此之外,所以,最好复制batik二进制分发zip文件
至
/usr/java/share/lib/
仅*内容*,而非lib< /strong>,如果你想要一次复制整个lib,你需要放入
/usr/java/share/
if you have the java executable batik-rasterizer.jar in /usr/java/share/ directory, you can create a dir named lib in this same path (/usr/java/share/)
so to have
/usr/java/share/lib
in this latest dir (lib) you will copy the pdf-transcoder.jar so to have
/usr/java/share/lib/pdf-transcoder.jar
anyway, you need also other libs in addition to this, so, it is better for you, copy the whole content of lib directory contained in batik binary distribution zip file
to
/usr/java/share/lib/
only *content*, not lib, if you want copy the whole lib at once, you need to put in
/usr/java/share/
如果您使用 .jar 文件从 fedora 执行 Batik,那么由于 java 忽略 -classpath 标志,这会非常痛苦。我假设 batik 在 /usr/share/java 根据您的系统选择位置 一种解决方案可能如下:创建一个临时目录(我假设您是超级用户,无论如何您总是可以 sudo 命令)
这会输出 jar 文件的内容进入草稿,然后创建一个 MANIFEST.MF 文件或从转储中获取输出
现在编辑 MANIFEST.MF 文件(我喜欢使用 vi,任何人都使用他们喜欢的文件)
将 Class-Path: 行添加到 MANIFEST.MF 中例如:
然后关闭文件并重新创建jar文件
包含batik嵌套类的所有jar
然后就可以使用它了!
例如,就是这样!
If you are executing Batik from fedora using the .jar file it is quite painful due to the java ignoring the -classpath flag. I assume batik in /usr/share/java Select the location according to your system One solution could be the following: create a scratch directory (I assume you are superuser, anyway you always can sudo commands)
This output the content of the jar file into scratch, then create a MANIFEST.MF file or take the output one from the dump
Now edit the MANIFEST.MF file (I like to use vi, anyone use their preferred one)
Add a Class-Path: line into the MANIFEST.MF as for example:
Then close the file and recreate the jar file
Include all jar that batik has nested classes
Then you can use it!
for example, and that's it!