Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package documento; /** * * @author ernesto11 */ import com.itextpdf.text.Document; import com.itextpdf.text.Paragraph; import com.itextpdf.text.pdf.PdfWriter; import java.io.*; import com.itextpdf.text.DocumentException; public class Documento { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException, DocumentException, FileNotFoundException { // TODO code application logic here Document documento = new Document(); FileOutputStream ficheroPdf = new FileOutputStream("fichero.pdf"); // Se asocia el documento al OutputStream y se indica que el espaciado entre lineas (20) PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); documento.open(); Paragraph title = new Paragraph("KE ONDA KE PEX!"); title.setAlignment(1); documento.add(title); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Texto del PDF")); //cerramos el documento documento.close(); } }