私は、テンプレートの html ドキュメントをロードし、その上でキーワードの置換を行い、それを出力するものを書いています。テンプレートに画像が含まれている場合を除いて、これは正常に機能します。テンプレート .html を参照すると、画像は正常に表示されますが (パスは問題ないと思います)、最終出力では空のスペースとして表示されます。
テンプレート html は次のようなものです。
<html>
<body>
<img src="file://c:/temp/my-logo.png" width="50" height="50"/>
[[[some stuff I want to replace]]]
</body>
</html>
十分に単純です。このテンプレートを次のようにロードします。
public void test() {
JEditorPane text = new JEditorPane("text/html", "default");
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
HTMLDocument htmlDocument = (HTMLDocument)htmlEditorKit.createDefaultDocument();
text.setEditorKit(htmlEditorKit);
// read the html template into the JEditorPane's text
text.read(new BufferedReader(new InputStreamReader(new FileInputStream(new File("path to my template html")))), htmlDocument);
// then do some replacements
text.setText(magicReplacements(text.getText()));
text.repaint();
// and then print job stuff, fire off the job, check if it worked etc...
}
テキストは正しく表示およびフォーマットされますが、画像だけが表示されることはありません。誰が何が間違っているかを見つけることができますか?
乾杯。