Created
January 3, 2013 19:42
-
-
Save HiroNakamura/4446414 to your computer and use it in GitHub Desktop.
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
| /** | |
| * @file UsoGrapes.groovy | |
| * @version 0.0.1 | |
| * @author Fer Carraro | |
| * @date 03-enero-2013 | |
| * @url http://codemonkeyjunior.blogspot.mx/ | |
| * @description Crear un documento PDF con la librería itext (itextpdf) usando @Grapes y @Grab de Groovy | |
| */ | |
| import groovy.grape.Grape | |
| import java.io.FileOutputStream | |
| import java.io.IOException | |
| import com.itextpdf.text.Document | |
| import com.itextpdf.text.DocumentException | |
| import com.itextpdf.text.Paragraph | |
| import com.itextpdf.text.pdf.PdfWriter | |
| principal() | |
| @Grapes(@Grab(group='com.itextpdf', module='itextpdf', version='5.1.2')) | |
| def principal()throws DocumentException, IOException{ | |
| println "Inicio..." | |
| def documento="micodigo.pdf" | |
| Document document = new Document(); | |
| PdfWriter.getInstance(document, new FileOutputStream(documento)); | |
| document.open(); | |
| document.add(new Paragraph("Usando Grapes en Groovy")); | |
| document.add(new Paragraph("http://codemonkeyjunior.blogspot.mx/")); | |
| document.close(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment