0

I need add image for each page on pdf file generated by ItextSharp library.

I have tried this article without success because on pdf file the image is present on only first page in the document.

Can you help me?

Thank you in advance.

My code below.

    try
    {
        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        pdfDoc.Open();
        iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(imagepath);            
        image.ScalePercent(50f);
        pdfDoc.Add(image);
        htmlparser.Parse(sr);
    }
    catch (Exception ex)
    {
        throw ex;
    }
    finally
    {
        pdfDoc.Close();
        Response.End();
    }
Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
Antonio Mailtraq
  • 1,397
  • 5
  • 34
  • 82
  • It's a mystery to me why you'd copy code from third party documentation that doesn't meet your needs, while the [official documentation](http://developers.itextpdf.com) contains an answer to the question [How can I add an image to all pages of my PDF?](http://developers.itextpdf.com/question/how-can-i-add-image-all-pages-my-pdf) I am the author of the official documentation. It is important for me to know if (1) you didn't know the official web site, (2) you know the official web site, but didn't find the information, (3) you found the information, but it was not clear, of (4) another reason. – Bruno Lowagie Aug 08 '16 at 09:03
  • Your first link is to the SourceForge page, but SourceForge is obsolete. Mind if I edit that link to point to GitHub? Also, as Bruno already wrote, you are using subpar documentation. It is outdated (written in 2008). The bad code still uses `HTMLWorker`, which has long been deprecated in favor of `XMLWorker`. – Amedee Van Gasse Aug 08 '16 at 09:33

0 Answers0