Rotativa.AspNetCore icon indicating copy to clipboard operation
Rotativa.AspNetCore copied to clipboard

Images not displaying

Open CamiKaze opened this issue 6 years ago • 3 comments

I am using ViewAsPdf and I can't seem to display an image. This is in my razor file: <img src="../Images/asd.jpg" />

I am using Rotativa.AspNetCore 1.2.0 beta

I also can't seem to the view as an image.

CamiKaze avatar Jul 08 '20 15:07 CamiKaze

Hi, do you fixed?

RomarioMeireles avatar Jan 04 '21 13:01 RomarioMeireles

I also same problem..

View.cshtml

pdf

Controller.cs

public IActionResult PreviewPDF()
{
    string webRootPath = _environment.WebRootPath;

    ViewData["imgPath"] = Path.GetFullPath(Path.Combine(webRootPath, "img"));

    return View();
}

Rotativa.AspNetCore Version is same. I tried to various ways but images not displaying.

How solve this problem..?

gpflawkd2 avatar Jun 21 '21 05:06 gpflawkd2

This is an old issue, but in case anyone stumbles upon this: by default Rotativa sets the base URL, which interferes with relative paths. In the latest version, you can disable this:

return new ViewAsPdf("MyView", setBaseUrl: false);

If anyone can verify if this fixes the problem, this issue could be closed.

ArjanKw avatar Jan 16 '25 13:01 ArjanKw