How to add Image in pdf using iText?

Hello experts !
I have a scenario where i need to add company stamp on a pdf where it has only 1 page. I found iText but there are lots of iText, which one i should use i dont know.

Also i need the code to add stamp on the pdf at bottom of page. Can someone help me with this ? I have tried chatGPT for that but as always it never gives correct answer.

Thanks in Advance.

@RobotUi
Option 1
Hope this will help you, Did you search in Market place custom activities? I found one pls try

Option 2You can create the custom activity by referring this below code


Document doc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);

        string pdfFilePath = Server.MapPath(".") + "/PDFFiles";      

        PdfWriter writer = PdfAWriter.GetInstance(doc, new FileStream(pdfFilePath + "/Default.pdf", FileMode.Create));

        doc.Open();

        try

        {

            Paragraph paragraph = new Paragraph("Getting Started ITextSharp.");

            string imageURL = Server.MapPath(".") + "/image2.jpg";

            iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageURL);

            //Resize image depend upon your need

            jpg.ScaleToFit(140f, 120f);

            //Give space before image

            jpg.SpacingBefore = 10f;

            //Give some space after the image

            jpg.SpacingAfter = 1f;

            jpg.Alignment = Element.ALIGN_LEFT;

 

            doc.Add(paragraph);

            doc.Add(jpg);

 

        }

        catch (Exception ex)

        { }

        finally

        {

            doc.Close();

        }

Regard
Mukesh Singh
mukesha.com

I have added iText bouncy-castle adapter module and it all worked as expected.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.