0

I followed Using Flying Saucer to Render Images to PDF In Memory. While the html to PDF conversion works fine, I'm trying to convert a html table (with image in first column of every row) to pdf. . Any help to render the image in every row of the PDF is greatly appreciated

This is how my input html looks like.

<html><body><table width="100%" border="1">
<tr>
<td width="20%">
<b>
Model Number
</b>
</td>
<td width="20%">
<b>
Model Name
</b>
</td>
<td width="20%">
<b>
Article Number
</b>
</td>
<td width="20%">
<b>
Article Name
</b>
</td>
<td width="20%">
<b>
Asset Name
</b>
</td>
</tr>

<tr>
<td>
Model0
</td>
<td>
Name0
</td>
<td>
Article0
</td>
<td>
ArticleName0
</td>
<td>
Asset Name0
</td>
</tr>

<tr>
<td rowspan="2">
<img src="http://localhost:4502/content/dam/adidas/product-assets/h/q/6/7/1/8/hq6718/7ac3406dea0b4c089e5aaf8f0092bac5.tif.renditions/card/asset.rendition"/>
</td>
<td>
<b>Image Expiry Date</b>
</td>
<td colspan="3">
<b>Disclaimer:</b>  
</td>
</tr>
<tr>
<td>
2023-08-0
</td>
<td colspan=3">
<ol>
<li>This is a disclaimer one created by Madhu for demo purposes. </li>
<li>I'm not done yet. This is another one one similar lines as above. </li>
</ol>
</td>
</tr>
</table><table width="100%" border="1">
<tr>
<td width="20%">
<b>
Model Number
</b>
</td>
<td width="20%">
<b>
Model Name
</b>
</td>
<td width="20%">
<b>
Article Number
</b>
</td>
<td width="20%">
<b>
Article Name
</b>
</td>
<td width="20%">
<b>
Asset Name
</b>
</td>
</tr>

<tr>
<td>
Model1
</td>
<td>
Name1
</td>
<td>
Article1
</td>
<td>
ArticleName1
</td>
<td>
Asset Name1
</td>
</tr>

<tr>
<td rowspan="2">
<img src="http://localhost:4502/content/dam/adidas/product-assets/h/q/6/7/1/8/hq6718/7ac3406dea0b4c089e5aaf8f0092bac5.tif.renditions/card/asset.rendition"/>
</td>
<td>
<b>Image Expiry Date</b>
</td>
<td colspan="3">
<b>Disclaimer:</b>  
</td>
</tr>
<tr>
<td>
2023-08-1
</td>
<td colspan=3">
<ol>
<li>This is a disclaimer one created by Madhu for demo purposes. Do not take this seriously</li>
<li>I'm not done yet. This is another one one similar lines as above. This is only for demo. Thank you for reading it till here</li>
</ol>
</td>
</tr>
</table>
</body>
</html>

I tried the steps as shared in Using Flying Saucer to Render Images to PDF In Memory. ITextRenderer iTextRenderer = new ITextRenderer(); iTextRenderer.getSharedContext().setReplacedElementFactory(new MediaReplacedElementFactory(iTextRenderer.getSharedContext().getReplacedElementFactory())); While debugging, the control enters MediaReplacedElementFactory.createReplacedElement() method only once and none of the images are rendered in the outputPDF

MGubby
  • 1

0 Answers0