Search in sources :

Example 36 with Document

use of com.lowagie.text.Document in project dhis2-core by dhis2.

the class PDFUtils method openDocument.

/**
 * Creates a document.
 *
 * @param outputStream The output stream to write the document content.
 * @param pageSize the page size.
 * @return A Document.
 */
public static Document openDocument(OutputStream outputStream, Rectangle pageSize) {
    try {
        Document document = new Document(pageSize);
        PdfWriter.getInstance(document, outputStream);
        document.open();
        return document;
    } catch (DocumentException ex) {
        throw new RuntimeException("Failed to open PDF document", ex);
    }
}
Also used : DocumentException(com.lowagie.text.DocumentException) Document(com.lowagie.text.Document)

Aggregations

Document (com.lowagie.text.Document)36 DocumentException (com.lowagie.text.DocumentException)20 ByteArrayOutputStream (java.io.ByteArrayOutputStream)15 PdfWriter (com.lowagie.text.pdf.PdfWriter)13 Paragraph (com.lowagie.text.Paragraph)12 IOException (java.io.IOException)12 Rectangle (com.lowagie.text.Rectangle)10 PdfContentByte (com.lowagie.text.pdf.PdfContentByte)9 FileOutputStream (java.io.FileOutputStream)9 Color (java.awt.Color)8 DefaultFontMapper (com.lowagie.text.pdf.DefaultFontMapper)6 PdfImportedPage (com.lowagie.text.pdf.PdfImportedPage)5 File (java.io.File)5 DocWriter (com.lowagie.text.DocWriter)4 Phrase (com.lowagie.text.Phrase)4 PdfPCell (com.lowagie.text.pdf.PdfPCell)4 PdfPTable (com.lowagie.text.pdf.PdfPTable)4 PdfReader (com.lowagie.text.pdf.PdfReader)4 Graphics2D (java.awt.Graphics2D)4 OutputStream (java.io.OutputStream)4