の外に取り除くのに役立ちませんしてくださいん、replacedElementFactory
とラインは必要ありません。
ここに私の実例があります。
のJava:
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.xhtmlrenderer.pdf.ITextRenderer;
public class PdfSvg {
public static void main(String[] args) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document inputDoc = builder.parse("svg.html");
ByteArrayOutputStream output = new ByteArrayOutputStream();
ITextRenderer renderer = new ITextRenderer();
ChainingReplacedElementFactory chainingReplacedElementFactory = new ChainingReplacedElementFactory();
chainingReplacedElementFactory.addReplacedElementFactory(new SVGReplacedElementFactory());
renderer.getSharedContext().setReplacedElementFactory(chainingReplacedElementFactory);
renderer.setDocument(inputDoc, "");;
renderer.layout();
renderer.createPDF(output);
OutputStream fos = new FileOutputStream("svg.pdf");
output.writeTo(fos);
}
}
HTML:
<html>
<head>
<style type="text/css">
svg {display: block;width:100mm;height:100mm}
</style>
</head>
<body>
<div>
<svg xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3"
fill="red" />
</svg>
</div>
</body>
</html>
ChainingReplacedElementFactory
、SVGReplacedElement
とSVGReplacedElementFactory
はtutorialから来ています。
すばやい返信ありがとう...上記のhtml .. svgタグでうまく動作しますが、ハイチャートAPIによって生成されたsvgがあります。サンプル入力はこちら.... http://jsfiddle.net/gh/ハイチャートのJSコードからSVG(または画像)を生成することです。次のようにしてください://jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-basic/ –
サーバー。残念ながら、私はそのための解決策はありませんが、ハイチャートのウェブサイトのこのページはあなたを助けるかもしれません:http://www.highcharts.com/news/52-serverside-generated-charts。 – obourgain