MVCRazorTOPDf:- How to add images

463 views Asked by At

I have implemented a module where i m trying to generate a PDF.PDF is generated successfully using MVCRAZORtppdf.

But now I want to add a image on PDF as well.How to add a image on PDF. And I want to add image on controller level.

1

There are 1 answers

0
Kenan Zahirovic On BEST ANSWER

Here is my solution done completely inside view:

@{
    Layout = null;
    var imagePath = Server.MapPath("~/Content/images");
    ....
}

<body>
    ....
        <img src="@imagePath\Cert_back.bmp" />
    ....
</body>

If you want to set an image in Controller, I guess you can use ViewBag to set value in imagePath variable.

However, keep in mind that you can use Razor's if-then-else statement and set value dynamically in View.