I create a method to convert the HTML to HTMLString and convert it to pdf and I put the baseUrl; however, there are no pictures in pdf.
public FileResult PrintTest3(int id)
{
var viewModel = new StandardIndexData();
viewModel.Title = _context.Titles.Where(i => i.Id == id).FirstOrDefault();
viewModel.Sections = _context.Sections;
viewModel.FileManagers = _context.FileManagers.ToArray();
viewModel.Items = _context.Items.Include(i=>i.FileManagers);
var html = Helper.RenderRazorViewToString(this, "DisplayAll",viewModel);
HtmlToPdf oHtmlToPdf = new HtmlToPdf();
//var baseUrl = "~//Images";
PdfDocument oPdfDocument = oHtmlToPdf.ConvertHtmlString(html, _dir);
byte[] pdf = oPdfDocument.Save();
oPdfDocument.Close();
return File(pdf, "application/pdf", "Test.pdf");
}
This is because base baseUrl is not correct, the right way is:
baseUrl + relative image/css url = full absolute url
base Url=>http://domain or local host relative image/css url=>your image file address
Ex=>http://localhost:54883/images/SmartPaies/clients-logo/
still not work please let me know you can also reach me on my mail id [email protected]