Skip Navigation Links.
In this demo you can learn how to hide a HTML image from the generated PDF document and how to place a different image in the same position. By default the CSS selector selects all the images from HTML document for replacement. You can modify the CSS selector to select an image with a given ID using a selector like #ImageID.

A similar approach can be used for example to replace the HTML form elements with PDF form elements in order to create interractive PDF forms.
Server Settings
IP: Port: Password:
HTML Document URL
CSS Selector of the Images to Replace :
Skip Navigation Links
C# Code
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using HiQPdfClient;

namespace HiQPdf_Demo
    public partial class ReplaceHtmlElements : System.Web.UI.Page
        protected void buttonCreatePdf_Click(object sender, EventArgs e)
            string serverIP = textBoxServerIP.Text;
            uint serverPort = uint.Parse(textBoxServerPort.Text);
            string serverPassword = textBoxServerPassword.Text;

            HtmlToPdf htmlToPdfConverter = new HtmlToPdf(serverIP, serverPort);

            // use server password if necessary
            if (serverPassword.Length > 0)
                htmlToPdfConverter.ServerPassword = serverPassword;

            // set a demo serial number
            htmlToPdfConverter.SerialNumber = "YCgJMTAE-BiwJAhIB-EhlWTlBA-UEBRQFBA-U1FOUVJO-WVlZWQ==";

            htmlToPdfConverter.SelectedHtmlElements = new string[] { textBoxImageSelector.Text };
            htmlToPdfConverter.HiddenHtmlElements = new string[] { textBoxImageSelector.Text };

            PdfDocument document = null;
                document = htmlToPdfConverter.ConvertUrlToPdfDocument(textBoxUrl.Text);

                for (int i = 0; i < htmlToPdfConverter.ConversionInfo.SelectedHtmlElementsInfo.Count; i++)
                    HtmlElementInfo htmlImageInfo = htmlToPdfConverter.ConversionInfo.SelectedHtmlElementsInfo[i];

                    PdfPageRegion imagePdfRegion = htmlImageInfo.PdfRegions[0];
                    PdfPage imagePdfPage = document.Pages[imagePdfRegion.PageIndex];

                    // create the image element
                    PdfImage pdfImage = new PdfImage(imagePdfRegion.Rectangle, Server.MapPath("~") + @"\DemoFiles\Images\HiQPdfLogo_Modified.png");
                    pdfImage.ClipRectangle = imagePdfRegion.Rectangle;


                // write the PDF document to a memory buffer
                byte[] pdfBuffer = document.WriteToMemory();

                // inform the browser about the binary data format
                HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");

                // let the browser know how to open the PDF document and the file name
                HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment; filename=ReplaceHtmlElements.pdf; size={0}",

                // write the PDF buffer to HTTP response

                // call End() method of HTTP response to stop ASP.NET page processing

                if (document != null)

        protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)
                string pageUri = HttpContext.Current.Request.Url.AbsoluteUri;
                textBoxUrl.Text = "" + @"/DemoFiles/Html/ReplaceImage.htm";