Created
April 28, 2015 00:01
-
-
Save rurtubia/42a86e3a880b7b893409 to your computer and use it in GitHub Desktop.
Create a PDF with an image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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