-
Notifications
You must be signed in to change notification settings - Fork 0
04. HelloPrint
Antonio Diaz Arroyo edited this page Oct 16, 2015
·
13 revisions
Example of use iText to generate a PDF and print it from browse in Chrome in Spring MVC 3.2.
Important points
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>${itext.version}</version>
</dependency>
standalone iText java application:
package com;
import java.io.FileOutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfWriter;
public class SavePdfLocal {
public static void main(String[] args) throws Exception {
System.out.println("working with documents...");
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("c:/Users/toni/Desktop/salida.pdf"));
Rectangle one = new Rectangle(226.72f, 340.08f);
document.setPageSize(one);
document.setMargins(2, 2, 2, 2);
document.open();
Paragraph p = new Paragraph("Hi");
document.add(p);
document.close();
}
}
Spring mvc examples for my own use and for everyone.