2

I am using this open source library for html to pdf. Everything is working, but when it comes to adding a <img src> tag, it is not showing the image I want in PDF. For example,

string image = "~/images/test.png";
string htmlToConvert = string.Format(@"
<div>
    <table>     
        <tr>
            <td>
                <img srcset='{0}'>
            </td>
        </tr>        
    </table>
</div>", image);

Is there anything wrong with my format or is it simply just not supporting images? If it is true, any working library for asp.net core 1.1? (important because some libraries/suggestions were based on 1.0 which contained project.json file)

p.s. I am going to deploy it via Azure web app service

bbusdriver
  • 1,577
  • 3
  • 26
  • 58

1 Answers1

1

The image must be in the same folder as where the phantomjs executabels are.

Just take a look at method PdfGenerator.WriteHtmlToTempFile

There you can see that your html is stored into a file in the phantomjs-installation directory. And this is the root of your html-file, which means that the images must be there too.

https://github.com/TheSalarKhan/PhantomJs.NetCore/blob/master/PdfGenerator.cs.

I suggest that you use the phantomjs-executabels directly to better understand what is going on.

Community
  • 1
  • 1
Aedvald Tseh
  • 1,757
  • 16
  • 31