rurtubia
4/28/2015 - 12:01 AM

Create a PDF with an image

Create a PDF with an image

//Crear el documento
Document document = new Document();

//Definición de la ruta
PdfWriter.GetInstance(document,
new FileStream("D:/users/Documentos/HolaMundo.pdf",
FileMode.Create));
//Abrir el documeto
document.Open();
//Agregar paragraph con el texto Hola Mundo
document.Add(new Paragraph("Hola Mundo!"));
document.Add(new Paragraph("Hola Mundo!"));

/7Agregando una imagen
iTextSharp.text.Image imagen = iTextSharp.text.Image.GrtInstance
("D:/Users/Documentos/imagen.png");
image.BorderWidth = 0;
imagen.Alignment = Element.ALIGN_LEFT
float percentage = 0,0f;
percentage = 150 / imagen.Width;
imagen.ScalePercent(percentage * 100);

//Insertar la imagen al documento
doc.A