Example usage for com.itextpdf.text Document addTitle

List of usage examples for com.itextpdf.text Document addTitle

Introduction

In this page you can find the example usage for com.itextpdf.text Document addTitle.

Prototype


public boolean addTitle(String title) 

Source Link

Document

Adds the title to a Document.

Usage

From source file:Modelo.RelatoriosBEAN.java

public static void relatorioMontanteCliente() throws FileNotFoundException, DocumentException {
    String path = System.getProperty("user.home") + FRMEmitirRelatorios.local + ".pdf";
    Document document = new Document(PageSize.A4.rotate());
    PdfWriter.getInstance(document, new FileOutputStream(path));
    document.open();//from  ww  w  . java2 s.com
    document.addAuthor("TechSales");
    document.addCreator("TechSales");
    document.addSubject("TechSales - Sistema de gerenciamento de locadoras");
    document.addCreationDate();
    document.addTitle("TechSales");

    HTMLWorker htmlWorker = new HTMLWorker(document);

    String frase;
    try {
        frase = "<html>" + "<head> <meta charset=\"utf-8\"> </head>" + "<body>" + "<br/>"
                + "<h1 align=center>Relatrio de montante por cliente </h1>" + "<br/><br/>"
                + "<table BORDER RULES=rows border=0 style=\"  width:100%; \">\n" + "<tr> "
                + "<th align=center><strong>Cdigo do cliente</strong></th> "
                + "<th align=center><strong>Nome do cliente</strong></th> "
                + "<th align=center><strong>Nmero de compras</strong></th> "
                + "<th align=center><strong>Valor total das compras</strong></th> "
                + "<th align=center><strong>Quantidade de alugueis</strong></th> "
                + "<th align=center><strong>Valor total de alugueis</strong></th> "
                + "<th align=center><strong>Montante Total</strong></th> " + "</tr> ";
        for (MontanteBEAN j : jDAO.montanteCliente()) {
            frase += "<tr align=center><td>" + j.getFunCodigo() + "</td><td>" + j.getFunNome() + "</td><td>"
                    + j.getnVendas() + "</td><td>" + j.getValorVendas() + "</td><td>" + j.getnAluguel()
                    + "</td><td>" + j.getValorAluguel() + "</td><td>" + j.getValorTotal() + "</td></tr>";
        }
        frase += "</table>";
        frase += "</body></html>";
        htmlWorker.parse(new StringReader(frase));
        document.close();
        if (Desktop.isDesktopSupported()) {
            try {
                Desktop.getDesktop().open(new File(path));
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Modelo.RelatoriosBEAN.java

public static void notaDaVenda(VendaBEAN v) throws FileNotFoundException, DocumentException {
    String path = System.getProperty("user.home") + FRMEmitirRelatorios.local + ".pdf";
    Document document = new Document(PageSize.LETTER);
    PdfWriter.getInstance(document, new FileOutputStream(path));
    document.open();//from  w w w  . j  ava  2s.c om
    document.addAuthor("TechSales");
    document.addCreator("TechSales");
    document.addSubject("TechSales - Sistema de gerenciamento de locadoras");
    document.addCreationDate();
    document.addTitle("TechSales");

    HTMLWorker htmlWorker = new HTMLWorker(document);

    String frase;
    try {
        frase = "<html>" + "<head> <meta charset=\"utf-8\"> </head>" + "<body>"
                + "<h1 align=center>Nota de Compra</h1>" + "<br/><br/>"
                + "<table BORDER RULES=rows border=0 style=\"  width:100%; \">\n" + "<tr> "
                + "<th align=center><strong>Cdigo</strong></th> "
                + "<th align=center><strong>Cliente</strong></th> "
                + "<th align=center><strong>Data</strong></th> "
                + "<th align=center><strong>Total</strong></th> "
                + "<th align=center><strong>Entrada</strong></th> "
                + "<th align=center><strong>Parcelas</strong></th> "
                + "<th align=center><strong>Vendedor</strong></th> " + "</tr> ";

        frase += "<tr align=center><td>" + v.getVendaCodigo() + "</td><td>" + v.getCliente().getCliCodigo()
                + "</td><td>" + v.getVendaData() + "</td><td>" + "</td><td>" + v.getVendaValorTotal()
                + "</td><td>" + "</td><td>" + v.getVendaEntrada() + "</td><td>" + "</td><td>"
                + v.getVendaNparcelas() + "</td><td>" + "</td><td>" + v.getVendedor().getVendedorCodigo()
                + "</td></tr>" + "</table>";

        frase += "<table BORDER RULES=rows border=0 style=\"  width:100%; \">\n" + "<br/><br/>" + "<tr> "
                + "<th align=center><strong>Parcela</strong></th> "
                + "<th align=center><strong>Data</strong></th> "
                + "<th align=center><strong>Valor</strong></th> "
                + "<th align=center><strong>Situao</strong></th> " + "</tr> ";

        for (VendaAPrazoBEAN vap : cVap.listarALL()) {
            if (vap.getVenda().getVendaCodigo() == v.getVendaCodigo()) {
                frase += "<tr align=center><td>" + vap.getVapNumParcela() + "</td><td>" + vap.getVapData()
                        + "</td><td>" + vap.getVapValorParcela() + "</td><td>" + vap.getVapSituacao()
                        + "</td></tr>";
            }
        }
        frase += "</table>";
        frase += "</body></html>";
        htmlWorker.parse(new StringReader(frase));
        document.close();
        if (Desktop.isDesktopSupported()) {
            try {
                Desktop.getDesktop().open(new File(path));
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Modelo.RelatoriosBEAN.java

public static void notaDaDev(DevolucaoBEAN l) throws FileNotFoundException, DocumentException {
    String path = System.getProperty("user.home") + FRMEmitirRelatorios.local + ".pdf";
    Document document = new Document(PageSize.A4.rotate());
    PdfWriter.getInstance(document, new FileOutputStream(path));
    document.open();/*  w  w w .j  a v a 2s .c  o m*/
    document.addAuthor("TechSales");
    document.addCreator("TechSales");
    document.addSubject("TechSales - Sistema de gerenciamento de locadoras");
    document.addCreationDate();
    document.addTitle("TechSales");

    HTMLWorker htmlWorker = new HTMLWorker(document);

    String frase;
    try {
        frase = "<html>" + "<head> <meta charset=\"utf-8\"> </head>" + "<body>"
                + "<h1 align=center>Nota de devoluo</h1>" + "<br/><br/>"
                + "<table BORDER RULES=rows border=0 style=\"  width:100%; \">\n" + "<tr> "
                + "<th align=center><strong>Cdigo</strong></th> "
                + "<th align=center><strong>Cliente</strong></th> "
                + "<th align=center><strong>Data Devoluo</strong></th> "
                + "<th align=center><strong>Multa</strong></th> "
                + "<th align=center><strong>Valor Total</strong></th> "
                + "<th align=center><strong>Vendedor</strong></th> " + "</tr> ";

        frase += "<tr align=center><td>" + l.getDevCodigo() + "</td><td>"
                + l.getLocacao().getCliente().getCliNome() + "</td><td>" + l.getDevData() + "</td><td>"
                + l.getDevMulta() + "</td><td>" + l.getDevValor() + "</td><td>"
                + l.getLocacao().getVendedor().getFuncionario().getFunNome() + "</td></tr>" + "</table>";

        frase += "<table BORDER RULES=rows border=0 style=\"  width:100%; \">\n" + "<br/><br/>" + "<tr> "
                + "<th align=center><strong>Cdigo do Jogo</strong></th> "
                + "<th align=center><strong>Nome</strong></th> "
                + "<th align=center><strong>Quantidade Locao</strong></th> " + "</tr> ";
        for (JogoLocacaoBEAN jl : cJl.listarALL()) {
            if (jl.getChaveComposta().getLocacao().getLocCodigo() == l.getLocacao().getLocCodigo()) {
                frase += "<tr align=center><td>" + jl.getChaveComposta().getJogo().getJoCodigo() + "</td><td>"
                        + jl.getChaveComposta().getJogo().getJoNome() + "</td><td>" + jl.getJlQtd()
                        + "</td></tr>";
            }
        }
        frase += "</table>";
        frase += "</body></html>";
        htmlWorker.parse(new StringReader(frase));
        document.close();
        if (Desktop.isDesktopSupported()) {
            try {
                Desktop.getDesktop().open(new File(path));
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Modelo.RelatoriosBEAN.java

public static void notaDeConta(ContaBEAN v) throws FileNotFoundException, DocumentException {
    String path = System.getProperty("user.home") + FRMEmitirRelatorios.local + ".pdf";
    Document document = new Document(PageSize.LETTER);
    PdfWriter.getInstance(document, new FileOutputStream(path));
    document.open();//from   www  .  j  a  va 2 s .  co m
    document.addAuthor("TechSales");
    document.addCreator("TechSales");
    document.addSubject("TechSales - Sistema de gerenciamento de locadoras");
    document.addCreationDate();
    document.addTitle("TechSales");

    HTMLWorker htmlWorker = new HTMLWorker(document);

    String frase;
    try {
        frase = "<html>" + "<head> <meta charset=\"utf-8\"> </head>" + "<body>"
                + "<h1 align=center>Nota de Conta</h1>" + "<br/><br/>"
                + "<table BORDER RULES=rows border=0 style=\"  width:100%; \">\n" + "<tr> "
                + "<th align=center><strong>Cdigo</strong></th> "
                + "<th align=center><strong>Fornecedor</strong></th> "
                + "<th align=center><strong>Data</strong></th> "
                + "<th align=center><strong>Total</strong></th> "
                + "<th align=center><strong>Entrada</strong></th> "
                + "<th align=center><strong>Parcelas</strong></th> " + "</tr> ";

        frase += "<tr align=center><td>" + v.getConCodigo() + "</td><td>"
                + v.getFornecedor().getForNomeEmpresa() + "</td><td>" + v.getConData() + "</td><td>"
                + v.getConValorTotal() + "</td><td>" + v.getConEntrada() + "</td><td>" + v.getConNparcelas()
                + "</td></tr>" + "</table>";

        frase += "<table BORDER RULES=rows border=0 style=\"  width:100%; \">\n" + "<br/><br/>" + "<tr> "
                + "<th align=center><strong>Parcela</strong></th> "
                + "<th align=center><strong>Data</strong></th> "
                + "<th align=center><strong>Valor</strong></th> "
                + "<th align=center><strong>Situao</strong></th> " + "</tr> ";

        for (ContaAPrazoBEAN vap : cCap.listarALL()) {
            if (vap.getConta().getConCodigo() == v.getConCodigo()) {
                frase += "<tr align=center><td>" + vap.getCapNumParcela() + "</td><td>" + vap.getCapData()
                        + "</td><td>" + vap.getCapValorParcela() + "</td><td>" + vap.getCapSituacao()
                        + "</td></tr>";
            }
        }
        frase += "</table>";
        frase += "</body></html>";
        htmlWorker.parse(new StringReader(frase));
        document.close();
        if (Desktop.isDesktopSupported()) {
            try {
                Desktop.getDesktop().open(new File(path));
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Modelo.RelatoriosBEAN.java

public static void notaDeCompra(NotaDecompraBEAN n) throws FileNotFoundException, DocumentException {
    String path = System.getProperty("user.home") + FRMEmitirRelatorios.local + ".pdf";
    Document document = new Document(PageSize.A4.rotate());
    PdfWriter.getInstance(document, new FileOutputStream(path));
    document.open();//from w  w w.ja  va 2  s. c  o  m
    document.addAuthor("TechSales");
    document.addCreator("TechSales");
    document.addSubject("TechSales - Sistema de gerenciamento de locadoras");
    document.addCreationDate();
    document.addTitle("TechSales");

    HTMLWorker htmlWorker = new HTMLWorker(document);

    String frase;
    try {
        frase = "<html>" + "<head> <meta charset=\"utf-8\"> </head>" + "<body>" + "<br/>"
                + "<h1 align=center>Relatrio de Jogos Comprados </h1>" + "<br/><br/>"
                + "<table BORDER RULES=rows border=0 style=\"  width:100%; \">\n" + "<tr> "
                + "<th align=center><strong>Cdigo</strong></th> "
                + "<th align=center><strong>Custo Unitrio</strong></th> "
                + "<th align=center><strong>Data</strong></th> "
                + "<th align=center><strong>Valor da Entrada</strong></th> "
                + "<th align=center><strong>Nmero de parcelas</strong></th> "
                + "<th align=center><strong>Preo Total</strong></th> "
                + "<th align=center><strong>Quantidade Compradra</strong></th> "
                + "<th align=center><strong>Caixa</strong></th> "
                + "<th align=center><strong>Jogo</strong></th> " + "</tr> ";

        frase += "<tr align=center><td>" + n.getNdcCodigo() + "</td><td>" + n.getNdcCustoUnitario()
                + "</td><td>" + n.getNdcData() + "</td><td>" + n.getNdcEntrada() + "</td><td>"
                + n.getNdcParcelas() + "</td><td>" + n.getNdcPrecoTotal() + "</td><td>" + n.getNdcQtdComprada()
                + "</td><td>" + n.getCaixa().getCaixaCodigo() + "</td><td>" + n.getJogo().getJoNome()
                + "</td></tr>" + "</table>";
        ;

        frase += "<table BORDER RULES=rows border=0 style=\"  width:100%; \">\n" + "<br/><br/>" + "<tr> "
                + "<th align=center><strong>Parcela</strong></th> "
                + "<th align=center><strong>Data</strong></th> "
                + "<th align=center><strong>Valor</strong></th> "
                + "<th align=center><strong>Situao</strong></th> " + "</tr> ";

        for (NotaDeCompraPrazoBEAN nap : cNdcap.listarALL()) {
            if (nap.getNota().getNdcCodigo() == n.getNdcCodigo()) {
                frase += "<tr align=center><td>" + nap.getNapNumParcela() + "</td><td>" + nap.getNapData()
                        + "</td><td>" + nap.getNapValor() + "</td><td>" + nap.getNapSituacao() + "</td></tr>";
            }
        }

        frase += "</table>";
        frase += "</body></html>";
        htmlWorker.parse(new StringReader(frase));
        document.close();
        if (Desktop.isDesktopSupported()) {
            try {
                Desktop.getDesktop().open(new File(path));
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:mom.trd.opentheso.SelectedBeans.BaseDeDonnesBean.java

/**
* permet de generer une document pour pouvoir le telecharger
* le format c'est pdf/*from w w w . j  av a2s . com*/
* @return
* @throws SQLException
* @throws Exception 
*/
public StreamedContent pdf() throws SQLException, Exception {
    Thesaurus thesaurus = new Thesaurus();
    ExportStatistiques expo = new ExportStatistiques();
    expo.recuperatefils(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(),
            theso.getThesaurus().getLanguage(), 2);
    Document pdf = new Document(PageSize.LETTER);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter writer;
    Paragraph para = new Paragraph(expo.getDocument());
    writer = PdfWriter.getInstance(pdf, baos);
    if (!pdf.isOpen()) {
        pdf.open();
    }
    pdf.addTitle("theso");
    pdf.add(para);
    //Adding content to pdf
    pdf.close();
    InputStream stream = new ByteArrayInputStream(baos.toByteArray());
    fileDownload = new DefaultStreamedContent(stream, "application/pdf",
            "Thsaurus" + thesaurus.getId_thesaurus() + ".pdf");

    return fileDownload;
}

From source file:negotiation.Contract.FormContractPdf.java

public static void addMetaData(Document document) {
    document.addTitle("FitSM Module");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText, FitSM");
    document.addAuthor("Zeqian Meng");
    document.addCreator("Zeqian Meng");
}

From source file:net.FilterLogic.imaging.ToPDF.java

License:Apache License

/**
 * Iterate through properties and set each value for PDF document.
 *///from www .  j  a v  a  2s.  co  m
private void setDocumentProperties(Document pdf) {

    for (Enumeration e = this.documentProperties.keys(); e.hasMoreElements();) {
        String name = e.nextElement().toString().toUpperCase();
        String value = this.documentProperties.getProperty(name);

        if (name.equals("TITLE"))
            pdf.addTitle(value);

        if (name.equals("AUTHOR"))
            pdf.addAuthor(value);

        //            if(name.equals("CREATOR"))
        //                pdf.addCreator(value);

        if (name.equals("CREATIONDATE"))
            pdf.addCreationDate();

        if (name.equals("SUBJECT"))
            pdf.addSubject(value);

        if (name.equals("KEYWORDS"))
            pdf.addKeywords(value);
    }

}

From source file:net.vzurczak.timesheetgenerator.PdfGenerator.java

License:Apache License

/**
 * Creates a PDF document.//from  ww w . ja v a 2 s  .com
 * @param bean a generation bean (not null)
 * @throws DocumentException
 * @throws FileNotFoundException
 */
public void createDocument(GenerationDataBean bean) throws FileNotFoundException, DocumentException {

    // Create the document
    File outputFile = new File("./Feuille-De-Temps.pdf");
    final Document doc = new Document(PageSize.A4.rotate());
    PdfWriter.getInstance(doc, new FileOutputStream(outputFile));

    doc.open();
    doc.addAuthor(bean.getName());
    doc.addCreator(bean.getName());

    String s;
    if (bean.getEndWeek() - bean.getStartWeek() > 1)
        s = "Feuilles de Temps - Semaines " + bean.getStartWeek() + "  " + bean.getEndWeek();
    else
        s = "Feuille de Temps - Semaine " + bean.getStartWeek();

    doc.addTitle(s);
    doc.addSubject(s);

    // Add pages
    for (int i = bean.getStartWeek(); i <= bean.getEndWeek(); i++)
        addPageForWeek(i, doc, bean);

    // That's it!
    doc.close();
}

From source file:org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter.java

License:Open Source License

private void addMetaData(Document document) {
    document.addTitle(report.getName());
    document.addSubject("Migration status report");
    document.addKeywords("BPMN, Migration, BonitaSoft, Process");
    document.addAuthor("Bonita Studio");
    document.addCreator("Bonita Studio");
}