itextsharp + image in pdf

Posted on 2009-12-21
Last Modified: 2013-11-07
Dear Friends,

you can see the related question, which is solved but the only problem is image,
the image is generating on the fly (barcode image) and added successfully in html but not rendering in pdf.

1. please see the codes in related question
2. the only problem occured is image is not adding in pdf by using the related question solution code.

please let me know the solution asap.

Question by:virafh
    LVL 15

    Accepted Solution

    hI VIRAFH,

    Imports iTextSharp.text
    Imports iTextSharp.text.pdf
    Imports System.IO

    Protected Sub ImageswithPDFButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ImageswithPDFButton.Click
            Dim imagepath As String = Server.MapPath("Images")
            Dim pdfpath As String = Server.MapPath("PDFs")
            Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
            Dim wri As PdfWriter
            wri = PdfWriter.GetInstance(doc, New FileStream(pdfpath & "/Image1.pdf", FileMode.Create))
            doc.Add(New Paragraph("GIF"))
            Dim gif As Image = Image.GetInstance(imagepath & "/calendar.gif")
        End Sub
    LVL 22

    Assisted Solution

    try this:

    string _ImagePath = Server.MapPath("images/") + "Logo.JPG";
                        iTextSharp.text.Image imgLogo = iTextSharp.text.Image.GetInstance(_ImagePath);
                        imgLogo.Alignment = Element.ALIGN_LEFT;
                        Chunk ckLogo = new Chunk(imgLogo, 0, -75);  // 70 : distance from top to bottom end of image
                        Phrase pLogo = new Phrase();

    Author Closing Comment


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now