Search in sources :

Example 16 with Phrase

use of com.lowagie.text.Phrase in project drools by kiegroup.

the class DroolsDocsBuilder method writePDF.

public void writePDF(OutputStream out) {
    // TODO: Use i18n!
    Document document = new Document();
    try {
        PdfWriter.getInstance(document, out);
        HeaderFooter footer = DroolsDocsComponentFactory.createFooter(packageData.getName());
        document.setFooter(footer);
        document.addTitle(packageData.getName().toUpperCase());
        document.open();
        // First page, documentation info.
        DroolsDocsComponentFactory.createFirstPage(document, currentDate, packageData);
        document.newPage();
        // List index of the rules
        document.add(new Phrase("Table of Contents"));
        document.add(DroolsDocsComponentFactory.createContents(packageData.getRules()));
        document.newPage();
        for (DrlRuleParser ruleData : packageData.getRules()) {
            DroolsDocsComponentFactory.newRulePage(document, packageData.getName(), ruleData);
        }
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    }
    document.close();
}
Also used : DocumentException(com.lowagie.text.DocumentException) HeaderFooter(com.lowagie.text.HeaderFooter) Phrase(com.lowagie.text.Phrase) Document(com.lowagie.text.Document) DrlRuleParser(org.drools.verifier.misc.DrlRuleParser)

Example 17 with Phrase

use of com.lowagie.text.Phrase in project drools by kiegroup.

the class EndPage method newCell.

private static Cell newCell(String text) throws BadElementException {
    Cell c = new Cell(new Phrase(text, BODY_TEXT));
    c.setLeading(10);
    c.setBorder(0);
    c.setBorderWidthBottom(1);
    return c;
}
Also used : Phrase(com.lowagie.text.Phrase) Cell(com.lowagie.text.Cell) PdfPCell(com.lowagie.text.pdf.PdfPCell)

Example 18 with Phrase

use of com.lowagie.text.Phrase in project OpenClinica by OpenClinica.

the class DownloadDiscrepancyNote method serializeThreadsToPDF.

public void serializeThreadsToPDF(List<DiscrepancyNoteThread> listOfThreads, OutputStream stream, String studyIdentifier) {
    ServletOutputStream servletStream = (ServletOutputStream) stream;
    Document pdfDoc = new Document();
    try {
        PdfWriter.getInstance(pdfDoc, servletStream);
        pdfDoc.open();
        // Create header for the study identifier or name
        if (studyIdentifier != null) {
            HeaderFooter header = new HeaderFooter(new Phrase("Study Identifier: " + studyIdentifier + " pg."), true);
            header.setAlignment(Element.ALIGN_CENTER);
            Paragraph para = new Paragraph("Study Identifier: " + studyIdentifier, new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 0, 0)));
            para.setAlignment(Element.ALIGN_CENTER);
            pdfDoc.setHeader(header);
            pdfDoc.add(para);
        }
        for (DiscrepancyNoteThread discNoteThread : listOfThreads) {
            pdfDoc.add(this.createTableThreadHeader(discNoteThread));
            // Just the parent of the thread?  discNoteThread.getLinkedNoteList()
            for (DiscrepancyNoteBean discNoteBean : discNoteThread.getLinkedNoteList()) {
                // DiscrepancyNoteBean discNoteBean = discNoteThread.getLinkedNoteList().getFirst();
                if (discNoteBean.getParentDnId() > 0) {
                    pdfDoc.add(this.createTableFromBean(discNoteBean));
                    pdfDoc.add(new Paragraph("\n"));
                }
            }
        }
    // pdfDoc.add(new Paragraph(content));
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    pdfDoc.close();
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) Color(java.awt.Color) DocumentException(com.lowagie.text.DocumentException) HeaderFooter(com.lowagie.text.HeaderFooter) Phrase(com.lowagie.text.Phrase) Document(com.lowagie.text.Document) Font(com.lowagie.text.Font) Paragraph(com.lowagie.text.Paragraph) DiscrepancyNoteThread(org.akaza.openclinica.service.DiscrepancyNoteThread)

Example 19 with Phrase

use of com.lowagie.text.Phrase in project OpenClinica by OpenClinica.

the class DownloadDiscrepancyNote method serializeListToPDF.

public void serializeListToPDF(List<DiscrepancyNoteBean> listOfBeans, OutputStream stream, String studyIdentifier) {
    ServletOutputStream servletStream = (ServletOutputStream) stream;
    Document pdfDoc = new Document();
    try {
        PdfWriter.getInstance(pdfDoc, servletStream);
        pdfDoc.open();
        // Create header for the study identifier or name
        if (studyIdentifier != null) {
            HeaderFooter header = new HeaderFooter(new Phrase("Study Identifier: " + studyIdentifier + " pg."), true);
            header.setAlignment(Element.ALIGN_CENTER);
            Paragraph para = new Paragraph("Study Identifier: " + studyIdentifier, new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 0, 0)));
            para.setAlignment(Element.ALIGN_CENTER);
            pdfDoc.setHeader(header);
            pdfDoc.add(para);
        }
        for (DiscrepancyNoteBean discNoteBean : listOfBeans) {
            pdfDoc.add(this.createTableFromBean(discNoteBean));
            pdfDoc.add(new Paragraph("\n"));
        }
    // pdfDoc.add(new Paragraph(content));
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    pdfDoc.close();
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) Color(java.awt.Color) DocumentException(com.lowagie.text.DocumentException) HeaderFooter(com.lowagie.text.HeaderFooter) Phrase(com.lowagie.text.Phrase) Document(com.lowagie.text.Document) Font(com.lowagie.text.Font) Paragraph(com.lowagie.text.Paragraph)

Example 20 with Phrase

use of com.lowagie.text.Phrase in project charts by vaadin.

the class PdfExportDemo method createCell.

private PdfPCell createCell(String value) throws BadElementException {
    PdfPCell cell = new PdfPCell(new Phrase(new Chunk(value, normalFont)));
    cell.setBorder(0);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    return cell;
}
Also used : PdfPCell(com.lowagie.text.pdf.PdfPCell) Phrase(com.lowagie.text.Phrase) Chunk(com.lowagie.text.Chunk)

Aggregations

Phrase (com.lowagie.text.Phrase)23 HeaderFooter (com.lowagie.text.HeaderFooter)9 DocumentException (com.lowagie.text.DocumentException)8 Paragraph (com.lowagie.text.Paragraph)8 PdfPCell (com.lowagie.text.pdf.PdfPCell)7 Chunk (com.lowagie.text.Chunk)4 Document (com.lowagie.text.Document)4 Color (java.awt.Color)4 Image (com.lowagie.text.Image)3 Section (com.lowagie.text.Section)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 BadElementException (com.lowagie.text.BadElementException)2 Cell (com.lowagie.text.Cell)2 Font (com.lowagie.text.Font)2 ListItem (com.lowagie.text.ListItem)2 Rectangle (com.lowagie.text.Rectangle)2 PdfContentByte (com.lowagie.text.pdf.PdfContentByte)2 PdfPTable (com.lowagie.text.pdf.PdfPTable)2