JPG image not showing up in PDF. When I run my code to see the MVC view I can see the JPG image, but when I run my code to convert the MVC view into PDF, then image is not shown in the PDF.
I see the JPG image in MVC view HTML page.
I don’t see the JPG image in PDF.
Here is my code to convert the MVC view HTML page into PDF.
MemoryStream stream2 = new MemoryStream();
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(HttpContext.Current.Server.MapPath("~/Aspose/Aspose.Pdf.lic"));
string html = ViewRenderer.RenderView("~/Views/Home/MyMVCview.cshtml", viewModel);
// convert string to stream
byte[] byteArray = Encoding.ASCII.GetBytes(html);
MemoryStream stream = new MemoryStream(byteArray);
// import an HTML document
Aspose.Pdf.HtmlLoadOptions options = new Aspose.Pdf.HtmlLoadOptions();
options.PageInfo.IsLandscape = false;
options.PageInfo.Margin.Top = 5;
options.PageInfo.Margin.Left = 23;
options.PageInfo.Margin.Right = 22;
options.PageInfo.Margin.Bottom = 5;
options.PageInfo.Width = Aspose.Pdf.PageSize.A4.Width;
options.PageInfo.Height = Aspose.Pdf.PageSize.A4.Height;
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(stream, options);
pdfDocument.Info.Title = "MyFile" + viewModel.RecID.ToString() + ".pdf";
pdfDocument.Save(stream2, Aspose.Pdf.SaveFormat.Pdf);
return stream2;