我将 svg 从 gsp 传递到我的 grails Controller 。我将其呈现为 pdf 并保存文件。但是没有附加样式。这是有道理的,因为样式是使用外部样式表完成的。
我的问题是是否可以使用 grails 中使用 batik 的样式表向 svg 添加样式?
这是我的源代码:
String svg_URI_input = params.image
TranscoderInput input_svg_image = new TranscoderInput(svg_URI_input);
OutputStream pdf_ostream = new FileOutputStream("report.pdf");
TranscoderOutput output_pdf_file = new TranscoderOutput(pdf_ostream);
Transcoder transcoder = new PDFTranscoder();
transcoder.transcode(input_svg_image, output_pdf_file);
pdf_ostream.flush();
pdf_ostream.close();
File fd = new File("report.pdf")
我是 batik 新手,找不到任何我能理解的教程示例。
最佳答案
要使用外部 SVG,必须在 SVG 内容之前添加以下说明:
<?xml-stylesheet type="text/css" href="http://ww.test.com/svgstyle.css" ?>
关于java - 是否可以在 grails 中使用 batik 为 svg 设置外部样式表的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17346938/