Example usage for com.lowagie.text FontFactory COURIER

List of usage examples for com.lowagie.text FontFactory COURIER

Introduction

In this page you can find the example usage for com.lowagie.text FontFactory COURIER.

Prototype

String COURIER

To view the source code for com.lowagie.text FontFactory COURIER.

Click Source Link

Document

This is a possible value of a base 14 type 1 font

Usage

From source file:Agenda.java

public void preparaPDF(Object document) throws IOException, BadElementException, DocumentException {
    //criando novo pdf
    Document pdf = (Document) document;

    //abrindo documento
    pdf.open();//from w w w.jav  a 2  s .c om

    //modificando caracteristicas do documento
    pdf.setPageSize(PageSize.A4);

    //        //VERSAO FUNCIONAL    
    //        //criando paragrafo no texto
    //            Paragraph p = new Paragraph("Relatrio Contatos",            
    //            //editando configuracoes de fontes do texto
    //            FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new Color(255,150,255)));
    //            
    //        //definindo alinhamento
    //            p.setAlignment(Element.ALIGN_CENTER);
    //        
    //        //adiciona as modificaes ao documento
    //            pdf.add(p);

    //VERSAO CORRETA
    Paragraph p = new Paragraph();
    p.setFont(FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new Color(255, 255, 0)));
    p.add(new Phrase("Relatrio Contatos"));
    p.setAlignment(Element.ALIGN_CENTER);
    pdf.add(p);
}

From source file:com.aurel.track.util.PdfUtils.java

License:Open Source License

public static void createPdfFromText(StringBuilder text, File pdfFile) {
    Document output = null;/*from   w w  w.  j a va2  s  . c o m*/
    try {
        BufferedReader input = new BufferedReader(new StringReader(text.toString()));
        // Size DIN A4
        //    see com.lowagie.text.PageSize for a complete list of page-size constants.
        output = new Document(PageSize.A4, 40, 40, 40, 40);
        float fntSize, lineSpacing;
        fntSize = 9f;
        lineSpacing = 11f;
        Font font1 = FontFactory.getFont(FontFactory.COURIER, fntSize);
        Font font2 = FontFactory.getFont(FontFactory.COURIER, fntSize);
        font2.setColor(Color.BLUE);
        Font font3 = FontFactory.getFont(FontFactory.COURIER, fntSize);
        font3.setColor(Color.RED);

        PdfWriter.getInstance(output, new FileOutputStream(pdfFile));

        output.open();
        output.addAuthor("Steinbeis");
        output.addSubject("Debug Info");
        output.addTitle(pdfFile.getName());

        String line = "";
        while (null != (line = input.readLine())) {
            Font ft = font1;
            if (line.startsWith("%")) {
                ft = font2;
            }
            if (line.startsWith("% ^^^") || line.startsWith("% vvv")) {
                ft = font3;
            }
            Paragraph p = new Paragraph(lineSpacing, line, ft);
            p.setAlignment(Element.ALIGN_JUSTIFIED);
            output.add(p);
        }
        output.close();
        input.close();
    } catch (Exception e) {
        LOGGER.debug("Problem creating debug info pdf file", e);
    }
}

From source file:com.centurylink.mdw.designer.pages.ExportHelper.java

License:Apache License

private void initialize(boolean isUseCase) {
    chapterFont = FontFactory.getFont(FontFactory.TIMES, isUseCase ? 16 : 20, Font.BOLD, new Color(0, 0, 0));
    sectionFont = FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLD, new Color(0, 0, 0));
    subSectionFont = FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0));
    normalFont = FontFactory.getFont(FontFactory.TIMES, 12, Font.NORMAL, new Color(0, 0, 0));
    boldFont = FontFactory.getFont(FontFactory.TIMES, 12, Font.BOLD, new Color(0, 0, 0));
    fixedWidthFont = FontFactory.getFont(FontFactory.COURIER, 11, Font.NORMAL, new Color(0, 0, 0));
    excludedAttributes = new HashSet<String>();
    excludedAttributes.add(WorkAttributeConstant.LOGICAL_ID);
    excludedAttributes.add(WorkAttributeConstant.REFERENCE_ID);
    excludedAttributes.add(WorkAttributeConstant.WORK_DISPLAY_INFO);
    excludedAttributes.add(WorkAttributeConstant.REFERENCES);
    excludedAttributes.add(WorkAttributeConstant.DOCUMENTATION);
    excludedAttributes.add(WorkAttributeConstant.SIMULATION_STUB_MODE);
    excludedAttributes.add(WorkAttributeConstant.SIMULATION_RESPONSE);
    excludedAttributes.add(WorkAttributeConstant.DESCRIPTION);
    excludedAttributes.add(WorkAttributeConstant.BAM_START_MSGDEF);
    excludedAttributes.add(WorkAttributeConstant.BAM_FINISH_MSGDEF);
    excludedAttributesForSpecificValues = new HashMap<String, String>();
    excludedAttributesForSpecificValues.put("DoNotNotifyCaller", "false");
    excludedAttributesForSpecificValues.put("DO_LOGGING", "True");
    tabularAttributes = new HashMap<String, List<String>>();
    tabularAttributes.put("Notices",
            Arrays.asList(new String[] { "Outcome", "Template", "Notifier Class(es)" }));
    tabularAttributes.put("Variables",
            Arrays.asList(new String[] { "Variable", "ReferredAs", "Display", "Seq.", "Index" }));
    tabularAttributes.put("WAIT_EVENT_NAMES",
            Arrays.asList(new String[] { "Event Name", "Completion Code", "Recurring" }));
    tabularAttributes.put("variables",
            Arrays.asList(new String[] { "=", "SubProcess Variable", "Binding Expression" }));
    tabularAttributes.put("processmap",
            Arrays.asList(new String[] { "=", "Logical Name", "Process Name", "Process Version" }));
    tabularAttributes.put("Bindings", Arrays.asList(new String[] { "=", "Variable", "LDAP Attribute" }));
    tabularAttributes.put("Parameters",
            Arrays.asList(new String[] { "=", "Input Variable", "Binding Expression" }));
    textboxAttributes = new HashMap<String, String>();
    textboxAttributes.put("Rule", "Code");
    textboxAttributes.put("Java", "Java");
    textboxAttributes.put("PreScript", "Pre-Script");
    textboxAttributes.put("PostScript", "Post-Script");
}

From source file:Controleur.CtrlImprimerOrdonnance.java

public void RemplirOrdonnance() {
    ResultSet res;//from w  w w.  jav a2s  .c om
    String nomEtablissement = "";
    String adresseEtablissement = "";
    int telEtablissement = 0;
    String nomPatient = "";
    String prenomPatient = "";
    String dateNaissPatient = null;
    String traitement = "";
    Etablissement etab = new Etablissement();
    try {
        res = etab.getEtablissement();
        nomEtablissement = res.getString("nomEtab");
        adresseEtablissement = res.getString("adresseEtab");
        telEtablissement = res.getInt("telEtab");
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, "erreur \n" + e.getMessage());
    }
    Medecin med1 = new Medecin();
    Medecin med2 = med1.getMedecinById(Fen.getIdm());
    String nomMedecin = med2.getNomMedecin();
    String prenomMedecin = med2.getPrenomMedecin();
    String specialiteMedecin = med2.getSpecialite();
    Patient patient = new Patient();
    res = patient.getPatient(Fen.getIdp());
    try {
        res.next();
        nomPatient = res.getString("nomPatient");
        prenomPatient = res.getString("prenomPatient");
        dateNaissPatient = res.getString("dateNaissance");
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, "erreur \n" + e.getMessage());
    }

    traitement = Fen.getTxtTraitement().getText();

    Document document = new Document(PageSize.A4);
    try {
        PdfWriter.getInstance(document, new FileOutputStream("./ordonnance.pdf"));
        document.open();
        Date d = new Date();
        Paragraph paragraph = new Paragraph(d.toLocaleString(),
                FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD));
        paragraph.setAlignment(Element.ALIGN_RIGHT);
        paragraph.setIndentationRight(50f);
        document.add(paragraph);
        paragraph = new Paragraph("Dr " + nomMedecin + " " + prenomMedecin,
                FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD));
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("SPECIALISTE EN " + specialiteMedecin);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph(nomEtablissement);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph(adresseEtablissement);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("Tl : " + telEtablissement);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("                      ");
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("nom & prenom :" + nomPatient + " " + prenomPatient,
                FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD));
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("Ne(e) le :" + dateNaissPatient);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("                       ");
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);

        Chunk chunk = new Chunk("Ordonnance", FontFactory.getFont(FontFactory.COURIER, 30, Font.BOLD));
        chunk.setUnderline(Color.BLACK, 3.0f, 0.0f, 0.0f, -0.2f, PdfContentByte.LINE_CAP_BUTT);
        paragraph = new Paragraph();
        paragraph.setAlignment(Element.ALIGN_CENTER);
        paragraph.add(chunk);
        document.add(paragraph);

        paragraph = new Paragraph("                       ");
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph(traitement);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);

        Runtime r = Runtime.getRuntime();
        r.exec("cmd /C ./ordonnance.pdf");
    } catch (DocumentException de) {
        de.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    document.close();
}

From source file:etc.Exporter.java

License:Open Source License

public static void saveAsPDF(File file, Task task) {
    try {/*from  ww w.j a va 2 s .c  o  m*/
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(file));

        document.open();
        Paragraph taskid = new Paragraph("ID e Detyres: " + task.getIdentifier(),
                FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC));
        document.add(taskid);

        Paragraph creator = new Paragraph("Krijuar nga " + task.getCreator().toString() + "["
                + task.getCreationTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy - HH.mm")) + "]",
                FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC));
        document.add(creator);

        Paragraph executor = new Paragraph("Per zbatim prej: " + task.getExecutor().toString(),
                FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC));
        document.add(executor);

        Paragraph title = new Paragraph(task.getTitle().toUpperCase(),
                FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD));
        document.add(title);

        Paragraph description = new Paragraph(task.getDescription(),
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL));
        document.add(description);

        PdfPCell cell = new PdfPCell();
        cell.setBorder(Rectangle.BOTTOM);

        PdfPTable table = new PdfPTable(1);
        table.addCell(cell);
        table.setWidthPercentage(100f);
        document.add(table);

        if (task instanceof dc.CompletedTask) {
            document.add(new Paragraph(
                    "Gjendja: Perfunduar [" + ((dc.CompletedTask) task).getCompletitionTime()
                            .format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH.mm")) + "]",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)));
            document.add(new Paragraph("Shenimet e Zbatuesit".toUpperCase(),
                    FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD)));
            document.add(new Paragraph(((dc.CompletedTask) task).getAnnotations(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL)));
        } else if (task instanceof dc.RejectedTask) {
            document.add(new Paragraph(
                    "Gjendja: Refuzuar [" + ((dc.RejectedTask) task).getRejectionTime()
                            .format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH.mm")) + "]",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)));
            document.add(new Paragraph("Shenimet e Zbatuesit".toUpperCase(),
                    FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD)));
            document.add(new Paragraph(((dc.RejectedTask) task).getAnnotations(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL)));
        } else {
            document.add(new Paragraph("Gjendja: Ne Pritje",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)));
        }

        document.close();

        Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file.getAbsolutePath());
        p.waitFor();
    } catch (DocumentException | InterruptedException | IOException ex) {
        Logger.getLogger(Exporter.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.areasy.common.doclet.document.Fonts.java

License:Open Source License

public static Font getFont(int faceType, int style, int size) {
    Font font = null;//www  .  jav a2 s  . c om
    String lookup = String.valueOf(faceType);
    String fontFile = fontTable.getProperty(lookup);

    int fontStyle = Font.NORMAL;
    Color color = COLOR_BLACK;

    if ((style & LINK) != 0) {
        fontStyle += Font.UNDERLINE;
        color = COLOR_LINK;
    } else if ((style & UNDERLINE) != 0)
        fontStyle += Font.UNDERLINE;

    if ((style & STRIKETHROUGH) != 0)
        fontStyle += Font.STRIKETHRU;

    if (fontFile != null) {

        File file = new File(DefaultConfiguration.getWorkDir(), fontFile);
        if (file.exists() && file.isFile()) {

            try {
                String encoding = encTable.getProperty(lookup, BaseFont.CP1252);
                BaseFont bfComic = BaseFont.createFont(file.getAbsolutePath(), encoding, BaseFont.EMBEDDED);

                if ((style & AbstractConfiguration.ITALIC) > 0) {
                    if ((style & AbstractConfiguration.BOLD) > 0)
                        fontStyle += Font.BOLDITALIC;
                    else
                        fontStyle += Font.ITALIC;
                } else if ((style & AbstractConfiguration.BOLD) > 0)
                    fontStyle += Font.BOLD;

                if (fontStyle != Font.NORMAL)
                    font = new Font(bfComic, size, fontStyle, color);
                else
                    font = new Font(bfComic, size);

                if (font == null)
                    throw new IllegalArgumentException("Font null: " + fontFile);
            } catch (Exception e) {
                e.printStackTrace();
                throw new IllegalArgumentException("Font unusable");
            }
        } else
            DocletUtility.error("Font file not found: " + fontFile);
    } else {
        // Use predefined font
        String face = "";

        if (faceType == TEXT_FONT) {
            face = FontFactory.HELVETICA;

            if ((style & AbstractConfiguration.ITALIC) > 0) {
                if ((style & AbstractConfiguration.BOLD) > 0)
                    face = FontFactory.HELVETICA_BOLDOBLIQUE;
                else
                    face = FontFactory.HELVETICA_OBLIQUE;
            } else if ((style & AbstractConfiguration.BOLD) > 0)
                face = FontFactory.HELVETICA_BOLD;
        } else {
            face = FontFactory.COURIER;
            if ((style & ITALIC) > 0) {
                if ((style & BOLD) > 0)
                    face = FontFactory.COURIER_BOLDOBLIQUE;
                else
                    face = FontFactory.COURIER_OBLIQUE;
            } else if ((style & BOLD) > 0)
                face = FontFactory.COURIER_BOLD;
        }

        if (fontStyle != Font.NORMAL)
            font = FontFactory.getFont(face, size, fontStyle, color);
        else
            font = FontFactory.getFont(face, size);
    }

    return font;
}

From source file:org.egomez.irpgeditor.swing.PanelSpoolFiles.java

License:Open Source License

@Override
public void run() {
    synchronized (this) {
        try {//from  w w  w  .j av a2  s .c o  m
            localPrintStream = new PrintStream(target);

            switch (exportType) {
            case SPOOL_EXPORT_TEXT:
                break;
            case SPOOL_EXPORT_PDF:
                document = new Document(PageSize.A4);
                PdfWriter.getInstance(document, localPrintStream);
                document.open();
                break;
            }

            PrintParameterList localPrintParameterList = new PrintParameterList();
            localPrintParameterList.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT,
                    "/QSYS.LIB/QWPDEFAULT.WSCST");
            localPrintParameterList.setParameter(PrintObject.ATTR_MFGTYPE, "*WSCST");
            localPrintParameterList.setParameter(PrintObject.ATTR_CODEPAGE, 284);
            PrintObjectTransformedInputStream localPrintObjectTransformedInputStream = file
                    .getTransformedInputStream(localPrintParameterList);
            byte[] buf = new byte[32767];
            StringBuffer buffer = new StringBuffer();
            int bytesRead = 0;
            do {
                bytesRead = localPrintObjectTransformedInputStream.read(buf);
                // System.out.println(bytesRead);
                if (bytesRead > 0) {
                    buffer.append(new String(buf, 0, bytesRead, "cp437"));
                }
            } while (bytesRead != -1);

            String cadena = buffer.toString();
            cadena = cadena.replace('\r', ' ');
            switch (exportType) {
            case SPOOL_EXPORT_TEXT:
                if (buffer.length() > 0)
                    localPrintStream.println(cadena.toCharArray());
                localPrintStream.flush();
                localPrintStream.close();
                break;
            case SPOOL_EXPORT_PDF:
                Paragraph p = new Paragraph(cadena,
                        FontFactory.getFont(FontFactory.COURIER, 6, com.lowagie.text.Font.NORMAL));
                // p.setFont(courierFont);
                if (buffer.length() > 0) {
                    document.add(p);
                }

                document.close();
                document = null;
                break;
            }

            JOptionPane.showMessageDialog(null, "File " + target.getAbsolutePath() + " was saved.");

        } catch (FileNotFoundException e) {
            // e.printStackTrace();
            logger.error(e.getMessage());
        } catch (IOException e) {
            logger.error(e.getMessage());
        } catch (AS400Exception e) {
            logger.error(e.getMessage());
        } catch (AS400SecurityException e) {
            logger.error(e.getMessage());
        } catch (ErrorCompletingRequestException e) {
            // e.printStackTrace();
            logger.error(e.getMessage());
        } catch (InterruptedException e) {
            // e.printStackTrace();
            logger.error(e.getMessage());
        } catch (RequestNotSupportedException e) {
            // e.printStackTrace();
            logger.error(e.getMessage());
        } catch (DocumentException e) {
            // e.printStackTrace();
            logger.error(e.getMessage());
        }
    }
}

From source file:org.kuali.kfs.gl.report.TransactionReport.java

License:Open Source License

/**
 * Generates transaction report/*from   w  ww .ja  v a  2 s . c om*/
 * 
 * @param errorSortedList list of error'd transactions
 * @param reportErrors map containing transactions and the errors associated with each transaction
 * @param reportSummary list of summary objects
 * @param runDate date report is run
 * @param title title of report
 * @param fileprefix file prefix of report file
 * @param destinationDirectory destination of where report file will reside
 */
public void generateReport(List<Transaction> errorSortedList, Map<Transaction, List<Message>> reportErrors,
        List<Summary> reportSummary, Date runDate, String title, String fileprefix,
        String destinationDirectory) {
    LOG.debug("generateReport() started");

    Font headerFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD);
    Font textFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL);

    Document document = new Document(PageSize.A4.rotate());

    PageHelper helper = new PageHelper();
    helper.runDate = runDate;
    helper.headerFont = headerFont;
    helper.title = title;

    try {
        DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);

        String filename = destinationDirectory + "/" + fileprefix + "_";
        filename = filename + dateTimeService.toDateTimeStringForFilename(runDate);
        filename = filename + ".pdf";
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
        writer.setPageEvent(helper);

        document.open();
        appendReport(document, headerFont, textFont, errorSortedList, reportErrors, reportSummary, runDate);
    } catch (DocumentException de) {
        LOG.error("generateReport() Error creating PDF report", de);
        throw new RuntimeException("Report Generation Failed: " + de.getMessage());
    } catch (FileNotFoundException fnfe) {
        LOG.error("generateReport() Error writing PDF report", fnfe);
        throw new RuntimeException("Report Generation Failed: Error writing to file " + fnfe.getMessage());
    } finally {
        if ((document != null) && document.isOpen()) {
            document.close();
        }
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java

License:Open Source License

protected void writeFileNameSectionTitle(com.lowagie.text.Document pdfDoc, String filenameLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD);

    //  file name title, get title only, on windows & unix platforms
    String fileNameOnly = filenameLine.toUpperCase();
    int indexOfSlashes = fileNameOnly.lastIndexOf("\\");
    if (indexOfSlashes < fileNameOnly.length()) {
        fileNameOnly = fileNameOnly.substring(indexOfSlashes + 1);
    }/*from   w  w w  .ja v  a 2 s .c o  m*/
    indexOfSlashes = fileNameOnly.lastIndexOf("/");
    if (indexOfSlashes < fileNameOnly.length()) {
        fileNameOnly = fileNameOnly.substring(indexOfSlashes + 1);
    }

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
    Chunk chunk = new Chunk(fileNameOnly, font);
    chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5);
    paragraph.add(chunk);

    //  blank line
    paragraph.add(new Chunk("", font));

    try {
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java

License:Open Source License

protected void writeInvoiceSectionTitle(com.lowagie.text.Document pdfDoc, String customerNameLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
    paragraph.add(new Chunk(customerNameLine, font));

    //  blank line
    paragraph.add(new Chunk("", font));

    try {//from  ww w.j  a  v  a 2 s  . c o m
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}