Render Image with Rotary Pdf (Asp.net Mvc)

Asked

Viewed 487 times

2

I have an Action responsible for generating the pdf using Rotary... The action code is as follows::

public ActionResult PDFPadrao()
    {
        string header = Server.MapPath("~/Views/Relatorio/Header.html");
        string customSwitches = string.Format("--header-html \"{0}\" " , header);

        var pdf = new ViewAsPdf()
        {
            ViewName = "Modelo",
            CustomSwitches = customSwitches

        };

        return pdf;
    }

The contents of the Header.html file are as follows::

<!DOCTYPE html>
 <html>
  <head>
    <title></title>
  </head>
<body>
  <div>
     <img src="@Server.MapPath('~/Images/337946.png')"/>
  </div>
</body>
</html>

I want to render this image in the pdf, but it is not being rendered, just this appears: inserir a descrição da imagem aqui

How can I solve?

  • If memory serves me correctly scr needs to be a virtual path. Ex.: https://seudominio.com/Images/337946.png

  • Man, thank you so much! It really helped me!!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.