using iTextSharp.text; using iTextSharp.text.pdf; // ... PdfContentByte cb = writer.DirectContent; Image img = Image.GetInstance("path/to/image.png"); img.ScaleAbsolute(100f, 100f); img.SetAbsolutePosition(50f, 500f); cb.AddImage(img);
using iTextSharp.text; using iTextSharp.text.pdf; // ... PdfContentByte cb = writer.DirectContent; Image img = Image.GetInstance("path/to/image.png"); img.ScaleToFit(200f, 200f); img.Alignment = Image.ALIGN_CENTER; cb.AddImage(img);This example demonstrates another way to add an image to a PDF document using the PdfContentByte class. The `ScaleToFit` method is called to scale the image to a maximum size of 200x200 units. The `Alignment` property is set to center the image in the document. The image is then added to the content byte. The package library for iTextSharp is iTextSharp.dll.