Example usage for com.itextpdf.text Document addAuthor

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

Introduction

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

Prototype


public boolean addAuthor(String author) 

Source Link

Document

Adds the author to a Document.

Usage

From source file:pdfgen.pdf_generation_try5.java

private void addMetaData(Document document) {
    document.addTitle("YourLawyer");
    document.addSubject("NAME CHANGE AFFIDAVIT");
    document.addKeywords("Affidavit, Name ,User-type");
    document.addAuthor("Extract name from the user");
    document.addCreator("YourLawyer");
}

From source file:principal.Informes.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//  w w w.  j a  v a 2 s .  c om
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, DocumentException, InterruptedException {
    // SERVLET PARA LA IMPRESIN DE LOS REGISTROS DE SISTEMA
    try {
        // Ejecucion de comando que sera introducido en el pdf
        Runtime runtime = Runtime.getRuntime();
        Process process = runtime.exec("/opt/script/owncloud/logOwncloud");
        process.waitFor();
        BufferedReader buffer = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String linea;

        //Imagen para documento PDF
        Image imagen = Image.getInstance("images/owncloud.png");
        imagen.setAlignment(Element.ALIGN_CENTER); //donde estara la imagen localizada           
        imagen.setAlt("50");

        // Creo objeto document de la clase Document     
        Document document = new Document();

        // paso 2
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter.getInstance(document, baos);

        // Abro nuevo documento PDF
        document.open();
        document.addAuthor("Administrator");

        //Nuevo parrafo con texto centrado
        Paragraph parrafo1 = new Paragraph("Informe de servidor Owncloud");
        parrafo1.setAlignment(1); //Centrar el texto
        document.add(imagen); //introduccion de la imagen en el documento pdf
        document.add(parrafo1);

        // bucle ejecutando el comando e introduciendolo en un nuevo parrafo del PDF
        while ((linea = buffer.readLine()) != null) {
            document.add(new Paragraph(linea));
        }

        // Cierre del documento PDF
        document.close();

        // Response headers
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        // Tipo de contenido que ser
        response.setContentType("application/pdf");
        // the contentlength
        response.setContentLength(baos.size());
        // Extrae todo el PDF para introducirlo en el servlet
        OutputStream os = response.getOutputStream();
        baos.writeTo(os);
        os.flush();
        os.close();
    } catch (DocumentException e) {
        throw new IOException(e.getMessage());
    }

}

From source file:printInv.GenerateInvoice.java

private void createPDF(String pdfFilename) {

    Document doc = new Document();
    PdfWriter docWriter = null;/* ww w.jav  a 2  s. c o m*/
    initializeFonts();

    try {
        //   String path = "docs/" + pdfFilename;
        String path = pdfFilename;
        docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path));
        doc.addAuthor("SmartWMS");
        doc.addCreationDate();
        doc.addProducer();
        doc.addCreator("SmartWMS");
        doc.addTitle("Invoice");
        doc.setPageSize(PageSize.LETTER);

        doc.open();
        PdfContentByte cb = docWriter.getDirectContent();

        boolean beginPage = true;
        int y = 0;
        System.out.println("n ===========" + n);
        for (int i = 0; i < n; i++) {
            if (beginPage) {
                beginPage = false;
                generateLayout(doc, cb);
                generateHeader(doc, cb);
                y = 615;
            }
            generateDetail(doc, cb, i, y);
            y = y - 15;
            if (y < 50) {
                printPageNumber(cb);
                doc.newPage();
                beginPage = true;
            }
        }
        printPageNumber(cb);
        cb.beginText();
        cb.setFontAndSize(bfBold, 10);
        cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Grand Total : " + total, 570, 35, 0);
        cb.endText();

    } catch (DocumentException dex) {
        dex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (doc != null) {
            doc.close();
        }
        if (docWriter != null) {
            docWriter.close();
        }
    }
}

From source file:PROCESOS.ImprimirPDF.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/pdf");
    String precio_unitario = request.getParameter("precio");

    String id_vale = request.getParameter("codigo");

    //  if(request.getParameter("codigo")!=null){
    OutputStream salida = response.getOutputStream();
    try {//from  w  w  w . j  a  v a2 s.co  m

        try {

            DTO.ClaseTransaccion clase = new ClaseTransaccion();
            clase = consulta.Transaccion();
            Document documento = new Document(PageSize.A4, 36, 36, 45, 20);
            PdfWriter pw = PdfWriter.getInstance(documento, salida);
            documento.open();
            Paragraph parrafo1 = new Paragraph();
            Font font_titulo = new Font(Font.FontFamily.HELVETICA, 16, Font.UNDERLINE, BaseColor.BLACK);
            parrafo1.add(new Phrase("TecnoBencina, COMPROBANTE", font_titulo));
            parrafo1.setAlignment(Element.ALIGN_CENTER);
            parrafo1.add(new Phrase(Chunk.NEWLINE));
            parrafo1.add(new Phrase(Chunk.NEWLINE));
            documento.add(parrafo1);

            Paragraph parrafo2 = new Paragraph();
            Font font_titulo_p2 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK);

            if (id_vale.length() > 0) {
                parrafo2.add(new Phrase("Comprobante de transaccion : codigo del vale : " + id_vale,
                        font_titulo_p2));
            } else {
                parrafo2.add(new Phrase("Comprobante de transaccion ", font_titulo_p2));
            }

            parrafo2.setAlignment(Element.ALIGN_JUSTIFIED);
            parrafo2.add(new Phrase(Chunk.NEWLINE));
            parrafo2.add(new Phrase(Chunk.NEWLINE));
            parrafo2.add(new Phrase(Chunk.NEWLINE));
            documento.add(parrafo2);

            PdfPTable tabla = new PdfPTable(9);
            PdfPCell celda1 = new PdfPCell(new Paragraph("ID transaccion ",
                    FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda2 = new PdfPCell(
                    new Paragraph("Estado ", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda3 = new PdfPCell(new Paragraph("ID de surtidor",
                    FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda4 = new PdfPCell(
                    new Paragraph("Litros", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda5 = new PdfPCell(
                    new Paragraph("Monto", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda6 = new PdfPCell(
                    new Paragraph("Fecha", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda7 = new PdfPCell(
                    new Paragraph("ID pago", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda8 = new PdfPCell(new Paragraph("Precio unitario",
                    FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));

            tabla.addCell(celda1);
            tabla.addCell(celda2);
            tabla.addCell(celda3);
            tabla.addCell(celda4);
            tabla.addCell(celda5);
            tabla.addCell(celda6);
            tabla.addCell(celda7);
            tabla.addCell(celda8);

            tabla.addCell(String.valueOf(clase.getId_transaccion()));
            tabla.addCell(clase.getEstado());
            tabla.addCell(String.valueOf(clase.getId_transaccion()));
            tabla.addCell(String.valueOf(clase.getLitros()));
            tabla.addCell(String.valueOf(clase.getMonto()));
            tabla.addCell(String.valueOf(clase.getFecha()));
            tabla.addCell(String.valueOf(clase.getId_pago()));
            tabla.addCell(precio_unitario);

            documento.add(tabla);
            documento.addAuthor("TecnoBencina");
            documento.addTitle("Comprobante");
            documento.addLanguage("Espaol");
            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));
            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));

            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));
            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));
            documento.add(new Paragraph("texto....", font_titulo_p2));
            documento.close();
        } catch (Exception s) {
            s.getMessage();
        }

    } catch (Exception s) {
        System.out.println("" + s.getMessage());
    } finally {
        salida.close();
    }
    // }
}

From source file:qedit.export.PDFObject.java

License:GNU General Public License

public void publish(OutputStream stream) throws Exception {
    if (stream == null) {
        throw new NullPointerException("Cannot public pdf to a null output stream");
    }//from www  .j  a  va  2 s  .c om
    try {
        /*
         * Initialize the document...
         */
        Document doc = new Document();
        try {
            PdfWriter.getInstance(doc, stream);
        } catch (ClassCastException ex) {
            throw new ClassCastException("The stream you provided is not a valid output stream");
        }
        doc.open();
        /*
         * Meta-information about the document...
         */
        doc.addAuthor(pdfAuthor);
        doc.addCreationDate();
        doc.addProducer();
        doc.addSubject(subject);
        doc.addCreator(pdfCreator);
        doc.addTitle(pdfTitle);
        doc.addKeywords(pdfKeywords);
        doc.addHeader("License", "GNU GPL v3");
        doc.add(new Paragraph("\n\n\n"));
        for (Element e : elements) {
            doc.add(e);
        }
        doc.close();
    } catch (DocumentException ex) {
        throw new DocumentException("Error while generating PDF representation.");
    }

}

From source file:report.pdfs.Basics_PDF_Report.java

private void addMetaData(Document document) {
    document.addTitle("Basics Overview Report");
    document.addSubject("Bascis");
    document.addKeywords("Basics, Report");
    document.addAuthor("admin");
    document.addCreator(System.getProperty("user.name"));
}

From source file:report.pdfs.Feed_PDF_Report.java

private void addMetaData(Document document) {
    document.addTitle("Feed Overview Report");
    document.addSubject("Feed");
    document.addKeywords("Beef, Feed, Report");
    document.addAuthor("admin");
    document.addCreator(System.getProperty("user.name"));
}

From source file:report.pdfs.Fertilizer_PDF_Report.java

private void addMetaData(Document document) {
    document.addTitle("Fertilizer Overview Report");
    document.addSubject("Fertilizer");
    document.addKeywords("Basics, Fertilizer, Report");
    document.addAuthor("admin");
    document.addCreator(System.getProperty("user.name"));
}

From source file:report.pdfs.Gas_PDF_Report.java

private void addMetaData(Document document) {
    document.addTitle("Gas Overview Report");
    document.addSubject("Gas");
    document.addKeywords("Basics, Gas, Report");
    document.addAuthor("admin");
    document.addCreator(System.getProperty("user.name"));
}

From source file:report.pdfs.Herd_PDF_Report.java

private void addMetaData(Document document) {
    document.addTitle("Herd Overview Report");
    document.addSubject("Herd");
    document.addKeywords("Beef, Herd, Report");
    document.addAuthor("admin");
    document.addCreator(System.getProperty("user.name"));
}