Web reference to background image

Web reference to background image

Forum member · Nov 17, 2005
How do I use a web reference for a background image, rather than hardcoding something like c:\images\background.gif?

Re: Web reference to background image

Support · Nov 17, 2005
Hello, You can reference any image on the web using the code below: // URL to retrieve Image string url = "http://www.DynamicPDF.com/Images/CeTeLogo.gif"; // Create a MemoryStream from the URL WebClient wc = new WebClient(); byte[] webImageBytes = wc.DownloadData( url ) ; System.IO.MemoryStream webImage = new MemoryStream( webImageBytes ); Document document = new Document(); // Create first page Page page = new Page(); page.Elements.Add(new BackgroundImage( webImage ) ); // Add first page to the document document.Pages.Add( page ); // Output PDF to the browser document.DrawToWeb( this, "Test.pdf" ); Thanks, ceTe Software Support Team.

Re: Web reference to background image

Forum member · Nov 17, 2005
Thanks, I found some docuementation on MapPath that seems to be working.

Re: Web reference to background image

Support · Nov 17, 2005
Hello, The code posted above was for images that needs to be added from the web url. If the images are located anywhere on the server you can use the following code: Document document = new Document(); // Create first page Page page = new Page(); page.Elements.Add(new BackgroundImage( MapPath( "ImageName" )) ); // Add first page to the document document.Pages.Add( page ); // Output PDF to the browser document.DrawToWeb( this, "Test.pdf" ); Thanks, ceTe Software Support Team.