Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Images Not Showing in PDF

$
0
0
I am unable to get the image to render in the PDF output. I am using an explicit url, as I thought that would work, but it still doesn't produce any output. below is my code. Everything works except the image is not in the PDF output. The image appears if I point the image src to our development environment, but I have elevated permissions on that server. Do you need more than read permissions on that directory to be able to view the images?

Image in html:

<img src="http://portal.hcmlp.com/img/highland_logo_new.gif" />

C# to generate PDF:

Aspose.Pdf.License license = new Aspose.Pdf.License();
            license.SetLicense("Siepe.Portal.Web.Aspose.Pdf.lic");
            license.Embedded = true;

            string url = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + ":" + Request.Url.Port + "/Wires/Wire/Print/" + id;
            System.Net.HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Timeout = 3000;
            request.Credentials = System.Net.CredentialCache.DefaultCredentials;

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Encoding encoding = Encoding.GetEncoding(1252);
            StreamReader reader = new StreamReader(response.GetResponseStream(), encoding);

            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            pdf.PageSetup.Margin.Left = pdf.PageSetup.Margin.Right = pdf.PageSetup.Margin.Bottom = pdf.PageSetup.Margin.Top = 5;
            pdf.CompressionLevel = 9;

            Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
            section.TextInfo.FontName = "Helvetica";
            Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, reader.ReadToEnd());

            text2.IsHtmlTagSupported = true;
            text2.IsFitToPage = true;


            section.Paragraphs.Add(text2);

            byte[] buffer = pdf.GetBuffer();
            return File(buffer, "application/pdf");

Viewing all articles
Browse latest Browse all 3131

Trending Articles