使用 Batik 将 svg 转换为 pdf 在 Ubuntu 11.10 上不起作用

发布于 2024-12-20 09:03:43 字数 500 浏览 5 评论 0 原文

我正在尝试使用 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

I am attempting to convert a svg image to pdf using the Batik SVG toolkit on Ubuntu-11.10.
I have Batik 1.7 and Fop 0.95 installed. When running the following in the terminal:

java -jar /usr/java/share/batik-rasterizer.jar -m application/pdf /home/user/Batik_Test/colors.svg  
-scriptSecurityOff

I get the following error:

Error while converting files:
  Error: cannot access transcoder for image of type application/pdf

The one thing I did notice was that the file 'pdf-transcoders.jar' was not on the machine so I added that to /usr/share/java on the off chance that was the problem but that did not make a difference.

I would appreciate any help from anyone out there with experience using Batik on ubuntu. What am I missing?

-J

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

っ〆星空下的拥抱 2024-12-27 09:03:43

如果您在 /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/

浮萍、无处依 2024-12-27 09:03:43

如果您使用 .jar 文件从 fedora 执行 Batik,那么由于 java 忽略 -classpath 标志,这会非常痛苦。我假设 batik 在 /usr/share/java 根据您的系统选择位置 一种解决方案可能如下:创建一个临时目录(我假设您是超级用户,无论如何您总是可以 sudo 命令)

mkdir scratch
cd scratch
jar -xf /usr/share/java/batik-rasterizer.jar

这会输出 jar 文件的内容进入草稿,然后创建一个 MANIFEST.MF 文件或从转储中获取输出

cp META-INF/MANIFEST.MF .

现在编辑 MANIFEST.MF 文件(我喜欢使用 vi,任何人都使用他们喜欢的文件)

vi MANIFEST.MF

将 Class-Path: 行添加到 MANIFEST.MF 中例如:

Class-Path: batik-all.jar xmlgraphics-commons.jar xml-commons-apis-ext.jar pdf-transcoder.jar avalon-framework.jar avalon-framework-api.jar apache-commons-logging.jar apache-commons-io.jar

然后关闭文件并重新创建jar文件

jar cmf MANIFEST.MF /usr/share/java/batik-rasterizer.jar org/*

包含batik嵌套类的所有jar

然后就可以使用它了!

java -jar /usr/share/java/batik-rasterizer.jar -scriptSecurittyOff -m image/png -d image.png image.svg

例如,就是这样!

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)

mkdir scratch
cd scratch
jar -xf /usr/share/java/batik-rasterizer.jar

This output the content of the jar file into scratch, then create a MANIFEST.MF file or take the output one from the dump

cp META-INF/MANIFEST.MF .

Now edit the MANIFEST.MF file (I like to use vi, anyone use their preferred one)

vi MANIFEST.MF

Add a Class-Path: line into the MANIFEST.MF as for example:

Class-Path: batik-all.jar xmlgraphics-commons.jar xml-commons-apis-ext.jar pdf-transcoder.jar avalon-framework.jar avalon-framework-api.jar apache-commons-logging.jar apache-commons-io.jar

Then close the file and recreate the jar file

jar cmf MANIFEST.MF /usr/share/java/batik-rasterizer.jar org/*

Include all jar that batik has nested classes

Then you can use it!

java -jar /usr/share/java/batik-rasterizer.jar -scriptSecurittyOff -m image/png -d image.png image.svg

for example, and that's it!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文