0

I am generating a pdf document using DinkToPdf and need to embed an image (present in the release folder) using img tag.

I followed this SO Post : Adding <img> HTML tag to C# String

But it only works for internet URLs and not for local disk images

What I tried is var HTML = @"<img src=""/myimage.png""/>"

But no image is displayed once the PDF is generated. But works fine if the path is an internet URL

How can I solve this?

[Edit to clarify the question] The image resides in the server and this needs to be embedded in the first page of the document

Arctic
  • 807
  • 10
  • 22

2 Answers2

0

You need to specify full path like this if you have your image in folder \wwwroot\Documents\ImgName.jpg

<img src="https://localhost:50001/Documents/ImgName.jpg">
        
Diusms
  • 1
0

Full path is not needed. Make sure your relative path is correct.

<img src=""/myimage.png""/>" Does the image resides on same executing environment?

If not use ~ to go back a directory. Image cannot exist on different project. It should be same as executing project.

A screenshot of folder structure would be helpful.