Skip to content

Instantly share code, notes, and snippets.

@rurtubia
Created April 28, 2015 00:01
Show Gist options
  • Select an option

  • Save rurtubia/42a86e3a880b7b893409 to your computer and use it in GitHub Desktop.

Select an option

Save rurtubia/42a86e3a880b7b893409 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment