I'm parsing pdf from html with ITextRenderer as follows:
private void createPdf(File file, String content) throws IOException, DocumentException {
OutputStream os = new FileOutputStream(file);
content = tidyUpHTML(content);
ITextRenderer renderer = new ITextRenderer();
renderer.setDocumentFromString(content);
renderer.layout();
renderer.createPDF(os);
os.close();
}
Now, if the html contains a local path to an image, it doesn't show in the pdf. However, if the img tag's src-value is an URL to an image online, it does work.
As follows: Doesn't show on the pdf:
<img src="C:\path\to\image\image.png" />
Does show correctly on the pdf:
<img src="http://flagpedia.net/data/currency/jpy/100jpy.jpg" />
The path to the local file is correct, as it shows the image if I copy paste that path to my web browser for example.
How to get it to show on the pdf?
UPDATE: This all is running in a JSF / Primefaces Web Application on a WildFly10 Application server. So it seems that direct paths to a file system won't work. Then, which directory in the war should I use to use static resources, such as this image. Currently it is in webapp/resources/images
.