Example usage for com.itextpdf.text Document addKeywords

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

Introduction

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

Prototype


public boolean addKeywords(String keywords) 

Source Link

Document

Adds the keywords to a Document.

Usage

From source file:Report.RelatorioProfessor.java

/**
 * Funo para gerar o stream do relatorio de orientaes por professor
 *
 * @param lOrientacao//from   w w w . j  a v a  2s .  c  o  m
 * @param dtinicial
 * @param dtfinal
 * @param coordenador
 * @param campus
 * @return ByteArrayOutputStream
 */
public ByteArrayOutputStream relatorioProfessorOrientacao(List<Professororientacao> lOrientacao, Date dtinicial,
        Date dtfinal, Professor coordenador, Campus campus) {

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    FacesContext faces = FacesContext.getCurrentInstance();
    //pega o contexto da aplicacao
    String realPath = faces.getExternalContext().getRealPath("/");

    try {
        BaseFont fHelvetica = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false);
        //----------------------------------------------------------------------
        //creation of the document with a certain size and certain margins
        //may want to use PageSize.LETTER instead
        Document document = new Document(PageSize.A4, 40, 40, 20, 50);
        document.addAuthor("SisGES"); // optional
        document.addSubject("Relatrio"); // opcional
        document.addKeywords("SisGES");
        document.addCreator("iText");
        //----------------------------------------------------------------------
        // creation of the different writers
        //PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("web/resources/report/alunosMatriculados.pdf"));
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        writer.setBoxSize("header", new Rectangle(36, 54, 559, 788));
        //----------------------------------------------------------------------
        // ADICIONA HEADER E FOOTER
        //----------------------------------------------------------------------
        HeaderFooter headerFooter = new HeaderFooter();
        headerFooter.setY(760f);
        writer.setPageEvent(headerFooter);
        //----------------------------------------------------------------------
        //ABRE DOCUMENTO PARA ESCRITA
        //----------------------------------------------------------------------
        document.open();
        //----------------------------------------------------------------------
        //ADICIONAR LOGO NO DOCUMENTO
        //----------------------------------------------------------------------
        Image logoUfu = Image.getInstance(realPath + "/resources/images/logoUFUAta.png");
        logoUfu.scaleAbsolute(155, 39);//(largura,altura)
        logoUfu.isImgTemplate(); //add no template
        document.add(logoUfu);

        //----------------------------------------------------------------------
        //ADICIONAR CABEALHO
        //----------------------------------------------------------------------
        PdfContentByte univ = writer.getDirectContentUnder();
        univ.beginText();
        univ.setFontAndSize(fHelvetica, 10);
        univ.setTextMatrix(349, 816); // x e y
        univ.showText("UNIVERSIDADE FEDERAL DE UBERLNDIA");
        univ.setTextMatrix(405, 802); // x e y
        univ.showText("FACULDADE DE COMPUTAO");
        univ.setTextMatrix(403, 788); // x e y
        univ.showText("COORDENADORIA DE ESTGIO ");
        univ.endText();

        String info = "Campus Universitrio - " + campus.getNomecampus() + " - CEP " + campus.getCep() + " - "
                + campus.getCidade() + " - " + campus.getEstadosigla().toUpperCase();

        Chunk txtCampus = new Chunk(info);
        Paragraph paragraph0 = new Paragraph();
        paragraph0.setSpacingBefore(-10);
        paragraph0.setFont(new Font(fHelvetica, 7));
        paragraph0.add(txtCampus);
        paragraph0.setAlignment(Element.ALIGN_RIGHT);
        document.add(paragraph0);

        info = "Telefone: " + coordenador.getTelefone() + "   Email: " + coordenador.getEmail();
        Chunk txtCoordenador = new Chunk(info);
        Paragraph paragraph1 = new Paragraph();
        paragraph1.setSpacingBefore(-5);
        paragraph1.setSpacingAfter(10);
        paragraph1.setFont(new Font(fHelvetica, 7));
        paragraph1.add(txtCoordenador);
        paragraph1.setAlignment(Element.ALIGN_RIGHT);
        document.add(paragraph1);

        //            PdfContentByte univ = writer.getDirectContentUnder();
        //            univ.beginText();
        //            univ.setFontAndSize(fHelvetica, 12);
        //            univ.setTextMatrix(200, 815); // x e y
        //            univ.showText("UNIVERSIDADE FEDERAL DE UBERLNDIA");
        //            univ.setTextMatrix(235, 800); // x e y
        //            univ.showText("FACULDADE DE COMPUTAO");
        //            univ.endText();
        //
        //            PdfContentByte univEnd = writer.getDirectContentUnder();
        //            univEnd.beginText();
        //            univEnd.setFontAndSize(fHelvetica, 7);
        //            univEnd.setTextMatrix(210, 785); // x e y
        //            univEnd.showText("Campus Universitrio - Santa Mnica - CEP 38408-100 - Uberlndia - MG");
        //            univEnd.setTextMatrix(260, 775); // x e y
        //            univEnd.showText("Telefone: (34)3239-4144 ou 3239-4393");
        //            univEnd.endText();
        //----------------------------------------------------------------------
        //ADICIONAR TITULO
        //----------------------------------------------------------------------
        PdfContentByte t1 = writer.getDirectContentUnder();
        t1.beginText();
        t1.setFontAndSize(fHelvetica, 14);
        t1.setTextMatrix(180, 730); // x e y
        t1.showText("Participao dos professores FACOM");
        t1.endText();

        PdfContentByte t2 = writer.getDirectContentUnder();
        t2.beginText();
        t2.setFontAndSize(fHelvetica, 12);
        t2.setTextMatrix(195, 705); // x e y
        String periodo = CalendarFormat.getDataBRtoDate(dtinicial) + " at "
                + CalendarFormat.getDataBRtoDate(dtfinal);
        t2.showText("Perodo: " + periodo);
        t2.endText();

        //----------------------------------------------------------------------
        //TABELA
        PdfPTable table = new PdfPTable(4);
        //espao do inicio da pagina
        table.setSpacingBefore(100f);
        table.setTotalWidth(100f);
        table.setWidthPercentage(100);
        float[] widths = { 20, 30, 35, 15 };//largura das colunas
        table.setWidths(widths);
        table.setHeaderRows(1);

        //CABEALHO DA TABELA
        Paragraph cabecalho = new Paragraph("Siape");
        PdfPCell cell1 = new PdfPCell(cabecalho); // celula
        cabecalho.getFont().setStyle(Font.BOLD);
        cabecalho.getFont().setSize(8);
        cell1.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell1.setBorderColor(BaseColor.LIGHT_GRAY);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell1);

        cabecalho = new Paragraph("Professor");
        cabecalho.getFont().setStyle(Font.BOLD);
        cabecalho.getFont().setSize(8);
        PdfPCell cell2 = new PdfPCell(cabecalho); // celula
        cell2.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell2.setBorderColor(BaseColor.LIGHT_GRAY);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell2);

        cabecalho = new Paragraph("Email do Professor");
        cabecalho.getFont().setStyle(Font.BOLD);
        cabecalho.getFont().setSize(8);
        PdfPCell cell4 = new PdfPCell(cabecalho); // celula
        cell4.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell4.setBorderColor(BaseColor.LIGHT_GRAY);
        cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell4);

        cabecalho = new Paragraph("Orientaes");
        cabecalho.getFont().setStyle(Font.BOLD);
        cabecalho.getFont().setSize(8);
        PdfPCell cell3 = new PdfPCell(cabecalho); // celula
        cell3.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell3.setBorderColor(BaseColor.LIGHT_GRAY);
        cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell3);

        for (int i = 0; i < lOrientacao.size(); i++) {
            Professororientacao po = lOrientacao.get(i);

            Paragraph texto = new Paragraph(String.valueOf(po.getSiape()));
            texto.getFont().setSize(8);
            cell1 = new PdfPCell(texto); // celula
            cell1.setBorderColor(BaseColor.LIGHT_GRAY);
            cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell1);

            texto = new Paragraph(po.getNome());
            texto.getFont().setSize(8);
            cell2 = new PdfPCell(texto); // celula
            cell2.setBorderColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell2);

            texto = new Paragraph(po.getEmail());
            texto.getFont().setSize(8);
            cell4 = new PdfPCell(texto); // celula
            cell4.setBorderColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell4);

            texto = new Paragraph(String.valueOf(po.getOrientacoes()));
            texto.getFont().setSize(8);
            cell3 = new PdfPCell(texto); // celula
            cell3.setBorderColor(BaseColor.LIGHT_GRAY);
            cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell3);

            switch (i % 2) {
            case 0:
                cell1.setBorderColor(BaseColor.LIGHT_GRAY);
                cell1.setBackgroundColor(BaseColor.LIGHT_GRAY);
                break;
            case 1:

                break;
            }
        }

        //add a tabela
        document.add(table);
        //-----------------------------------------------------
        // distancia do fim da pagina
        float y = 70f;
        float x = 160f;
        //-----------------------------------------------------
        //linha
        PdfContentByte linha = writer.getDirectContentUnder();
        linha.setLineWidth(1f); // mostrar linha
        linha.setGrayStroke(0.5f); // 0 = preto, 1 = branco
        linha.moveTo(x, y);
        linha.lineTo(450f, y); // ate onde a linha vai
        linha.stroke();
        //------------------------------------------------------
        //assinatura
        PdfContentByte a1 = writer.getDirectContentUnder();
        a1.beginText();
        a1.setFontAndSize(fHelvetica, 10);
        a1.setTextMatrix(x + 50, y - 15); // x e y
        a1.showText("Coordenao de Estgio Supervisionado");
        a1.endText();
        //------------------------------------------------------
        //assinatura
        PdfContentByte a2 = writer.getDirectContentUnder();
        a2.beginText();
        a2.setFontAndSize(fHelvetica, 10);
        a2.setTextMatrix(x + 50, y - 27); // x e y
        a2.showText("FACOM/UFU");
        a2.endText();
        //------------------------------------------------------

        //add nova pagina
        document.newPage();
        //close document
        document.close();
    } catch (DocumentException | IOException ex) {
        Logger.getLogger(RelatorioProfessor.class.getName()).log(Level.SEVERE, null, ex);
    }
    //return stream com dados
    return baos;
}

From source file:sipl.recursos.GenerarPDFGrafica.java

private void addMetaData(Document document) {
    document.addTitle(Titulo);/*from  w w  w .  j  a v a 2 s  . c o  m*/
    document.addSubject("Grfica");
    document.addKeywords("Java, Grfica, PDF, iText");
    document.addAuthor("Wilmar Gonzlez - Sandra Vera");
    document.addCreator("SIPL");
}

From source file:sipl.recursos.GenerarPDFListar.java

private void addMetaData(Document document) {
    document.addTitle(Titulo);//  www.jav a  2  s . c om
    document.addSubject("Lista especfica");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("Wilmar Gonzlez - Sandra Vera");
    document.addCreator("SIPL");
}

From source file:sipl.recursos.GenerarPDFtipomaterial.java

private static void addMetaData(Document document) {
    document.addTitle(Titulo);//from   ww  w .  j  a va  2  s .  c om
    document.addSubject("Grfica");
    document.addKeywords("Java, Grfica, PDF, iText");
    document.addAuthor("Wilmar Gonzlez - Sandra Vera");
    document.addCreator("SIPL");
}

From source file:sistemafacturacionlibros.PDFCreator.java

public void addMetaData(Document document) {
    document.addTitle("PDF Report");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor(System.getProperty("user.name"));
    document.addCreator(System.getProperty("user.name"));
}

From source file:sqlsentinel.report.PDFGenerator.java

License:Open Source License

private static void addMetaData(Document document) {
    document.addTitle("SQLSentinel Report");
    document.addSubject("site: " + url);
    document.addKeywords("");
    document.addAuthor("SQLSentinel");
    document.addCreator("SQLSentinel");
}

From source file:tn.com.hitechart.eds.Util.pdfRpport.FirstPdf.java

private void addMetaData(Document document) {

    document.addTitle("My first PDF");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("AHMED BEJ");
    document.addCreator("AHMED BEJ");
}

From source file:tn.esprit.twin1.brogrammers.eventify.Eventify.util.TicketGenerator.java

public static void GenerateTicket(Ticket ticket) {
    Document document = new Document();
    try {//  w  ww .  ja v a 2 s. c om
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(FILE));
        Rectangle pagesize = new Rectangle(700, 300);
        document.open();
        Paragraph emptyline = new Paragraph();
        emptyline.add(new Paragraph(" "));
        document.setPageSize(pagesize);
        document.newPage();
        //PIC
        PdfContentByte canvas = writer.getDirectContentUnder();
        Image image = Image.getInstance(IMAGE);
        //image.scaleAbsolute(pagesize.rotate());
        image.setAbsolutePosition(0, 0);
        canvas.addImage(image);
        //PIC
        document.addTitle("Your Access To" + ticket.getEvent().getTitle());
        document.addSubject(ticket.getEvent().getTheme());
        document.addKeywords(ticket.getEvent().getTitle() + "Ticket");
        document.addAuthor("Mohamed Firas Ouertani");
        document.addCreator("Mohamed Firas Ouertani");
        Paragraph prefacetitle = new Paragraph();
        prefacetitle.add(new Paragraph("Your Ticket For " + ticket.getEvent().getTitle(), bigFont));
        document.add(prefacetitle);
        document.add(emptyline);

        Paragraph prefacetime = new Paragraph();
        prefacetime.add(new Paragraph(ticket.getEvent().getStartTime().toString(), greyFont));
        document.add(prefacetime);
        document.add(emptyline);
        document.add(emptyline);
        Paragraph prefacetype = new Paragraph();
        prefacetype.add(new Paragraph("You Reserved For: " + ticket.getTypeTicket(), catFont));
        document.add(prefacetype);
        //QR
        BarcodeQRCode qrcode = new BarcodeQRCode(
                "REF:#" + ticket.getEvent().getId() + "" + ticket.getEvent().getTitle().trim(), 1, 1, null);
        Image qrcodeImage = qrcode.getImage();
        qrcodeImage.setAbsolutePosition(520, 70);
        qrcodeImage.scalePercent(400);
        document.add(qrcodeImage);
        //QR

        //Bar
        PdfContentByte cb = writer.getDirectContent();
        Barcode128 code128 = new Barcode128();

        BarcodeEAN codeEAN = new BarcodeEAN();
        codeEAN.setCode("REF:#" + ticket.getEvent().getId() + "" + ticket.getEvent().getTitle().trim());
        codeEAN.setCodeType(BarcodeEAN.EAN13);
        Image codeEANImage = code128.createImageWithBarcode(cb, null, null);
        codeEANImage.setAbsolutePosition(10, 10);
        codeEANImage.scalePercent(125);
        document.add(codeEANImage);
        //Bar

        document.close();

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:vemo.controller.ReportController.java

@RequestMapping(value = "report/RentalsPDF", produces = "application/pdf")
@ResponseBody//www . ja  va 2s  .  co m
public String RentalsPDF(ModelMap model, HttpServletResponse response, HttpServletRequest request,
        Integer maxResults, @RequestParam(value = "first", required = false) String first,
        @RequestParam(value = "last", required = false) String last) throws DocumentException, IOException {
    Document document = new Document();
    PdfWriter.getInstance(document, response.getOutputStream());
    document.open();

    document.addTitle("Report Of Rentals");
    document.addSubject("Report");
    document.addKeywords("Report Of Rentals");
    document.addAuthor("Sandy Andryanto");
    document.addCreator("Sandy Andryanto");

    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" REPORT OF RENTALS "));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));

    PdfPTable table = new PdfPTable(6);
    table.addCell("No");
    table.addCell("Date");
    table.addCell("Account Count");
    table.addCell("Movie Count");
    table.addCell("Total Loan");
    table.addCell("Total Returned");

    List<CustomersRentals> list = ReportDao.list(0, maxResults, first, last);
    for (int i = 0; i < list.size(); i++) {
        table.addCell("" + (i + 1));
        table.addCell("" + list.get(i).getDate());
        table.addCell("" + ReportDao.GetReportRentals("" + list.get(i).getDate(), "account_id"));
        table.addCell("" + ReportDao.GetReportRentals("" + list.get(i).getDate(), "movie_id"));
        table.addCell("" + ReportDao.GetReportRentals2("" + list.get(i).getDate(), "loan"));
        table.addCell("" + ReportDao.GetReportRentals2("" + list.get(i).getDate(), "return"));
    }

    document.add(table);
    document.close();

    return "RentalsPDF";
}

From source file:vemo.controller.ReportController.java

@RequestMapping(value = "report/FinancialsPDF", produces = "application/pdf")
@ResponseBody/*from   ww w . ja  v a 2  s . c o m*/
public String FinancialsPDF(ModelMap model, HttpServletResponse response, HttpServletRequest request,
        Integer maxResults, @RequestParam(value = "first", required = false) String first,
        @RequestParam(value = "last", required = false) String last) throws DocumentException, IOException {
    Document document = new Document();
    PdfWriter.getInstance(document, response.getOutputStream());
    document.open();

    document.addTitle("Report Of Financials");
    document.addSubject("Report");
    document.addKeywords("Report Of Financials");
    document.addAuthor("Sandy Andryanto");
    document.addCreator("Sandy Andryanto");

    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" REPORT OF FINANCIALS "));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));

    PdfPTable table = new PdfPTable(5);
    table.addCell("No");
    table.addCell("Date");
    table.addCell("Customer Name");
    table.addCell("Movie Title");
    table.addCell("Amount");

    int SUM = 0;
    List<CustomersRentals> list = ReportDao.list(0, maxResults, first, last);
    for (int i = 0; i < list.size(); i++) {
        table.addCell("" + (i + 1));
        table.addCell("" + list.get(i).getDate());
        table.addCell("" + list.get(i).getRentals().getCustomers().getFullName());
        table.addCell("" + list.get(i).getRentals().getMovies().getTitle());
        table.addCell("" + list.get(i).getAmount());
        SUM += list.get(i).getAmount();
    }

    table.addCell("");
    table.addCell("");
    table.addCell("TOTAL");
    table.addCell("");
    table.addCell("$ " + SUM);

    document.add(table);
    document.close();

    return "RentalsPDF";
}