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:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java

private String createDocument(Document doc, PdfWriter docWriter, LicensePFEntity license)
        throws FileNotFoundException, DocumentException {

    String fileName = "Comunicado de alterao cadastral - Cnpj: " + license.getCompany().getCnpj() + ".pdf";

    docWriter = PdfWriter.getInstance(doc, new FileOutputStream(filePath + fileName));

    // document header attributes
    doc.addAuthor("EnforceMaps");
    doc.addCreationDate();//from   ww  w. ja  va 2 s .co  m
    doc.addProducer();
    doc.addCreator("EnforceMaps");
    doc.addTitle("Comunicado de alterao cadastral: ");
    doc.setPageSize(PageSize.A4);

    // open document
    doc.open();

    return fileName;
}

From source file:com.swayam.bhasha.engine.io.writers.impl.PDFGenerator.java

License:Apache License

private void makePDFPage(HTMLDocModel htmlDoc, String fileName) throws DocGenerationException {

    Rectangle pageSize = PageSize.A4;

    if (pageDim.height > pageSize.getHeight()) {
        pageSize = new Rectangle(pageDim.width, pageDim.height);
    }/*from w w  w.j a va2  s  .  co m*/

    Document pdfDoc = new Document(pageSize, MARGINS, MARGINS, MARGINS, MARGINS);

    FileOutputStream pdfStream = null;

    try {
        pdfStream = new FileOutputStream(fileName);

        PdfWriter.getInstance(pdfDoc, pdfStream);

        pdfDoc.addAuthor("Bhasha PDF Generator (Powered by IText)");

        pdfDoc.open();

        List<Para> paraList = htmlDoc.getParaList();

        for (Para para : paraList) {
            pdfDoc.add(getParagraph(para));
        }

        pdfDoc.close();

    } catch (Exception e) {
        throw new DocGenerationException(e);
    } finally {

        if (pdfStream != null) {
            try {
                pdfStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

}

From source file:com.swayam.bhasha.engine.io.writers.impl.PDFImageGenerator.java

License:Apache License

private void makePDFPage(HTMLDocModel htmlDoc, String fileName) throws DocGenerationException, IOException {

    BufferedImage image = getImage(pageDim, htmlDoc);

    /*/*from w w  w.  j  av a  2s.c o m*/
     * ByteArrayOutputStream bos = new ByteArrayOutputStream();
     * 
     * ImageIO.write(image, "JPG", bos);
     * 
     * byte[] imageData = bos.toByteArray();
     * 
     * System.out.println("PDFImageGenerator.makePDFPage() " +
     * imageData.length);
     */

    Rectangle pageSize = PageSize.A4;

    if (image.getHeight() > pageSize.getHeight()) {
        pageSize = new Rectangle(image.getWidth(), image.getHeight());
    }

    Document pdfDoc = new Document(pageSize, MARGINS, MARGINS, MARGINS, MARGINS);

    FileOutputStream pdfStream = null;

    try {
        pdfStream = new FileOutputStream(fileName);

        PdfWriter pdfWriter = PdfWriter.getInstance(pdfDoc, pdfStream);

        pdfDoc.addAuthor("Bhasha PDF Generator (Powered by IText)");

        pdfDoc.open();

        PdfContentByte contentByte = pdfWriter.getDirectContent();

        Image pdfImage = Image.getInstance(image, null);

        pdfImage.setAbsolutePosition(0, 0);
        contentByte.addImage(pdfImage);

    } catch (Exception e) {
        throw new DocGenerationException(e);
    } finally {

        pdfDoc.close();

        if (pdfStream != null) {
            try {
                pdfStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}

From source file:com.systemevent.jsfclass.util.PdfEvento.java

public void imprimirPdf(Evento events) {
    Evento event = events;/* w w w . ja v a 2 s.  c o m*/

    //buscarPDF(n);
    try {
        //Generamos el archivo PDF
        String directorioArchivos;
        ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance().getExternalContext()
                .getContext();
        directorioArchivos = ctx.getRealPath("\'") + "reports";
        String name = directorioArchivos + "\'document-report.pdf";
        //String name="C:\\Users\\Jose_Gascon\\Documents\\NetBeansProjects\\SystemEvent\\target\\SystemEvent-1.0-SNAPSHOT\\reports\\document-report.pdf";
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(name));
        FormatoPDF encabezado = new FormatoPDF("");
        Paragraph parrafo, datos, datos1;
        int i;

        // indicamos que objecto manejara los eventos al escribir el Pdf
        writer.setPageEvent(encabezado);

        document.open();
        document.addAuthor("Erick Ramirez");
        document.addTitle("Reporte");

        //Creamos una cantidad significativa de paginas para probar el encabezado

        //for (i = 0; i < 4; i++) {
        parrafo = new Paragraph("Presupuesto de Evento");
        parrafo.setAlignment(Element.ALIGN_CENTER);

        document.add(parrafo);
        //  document.newPage();
        //}

        datos = new Paragraph("Ubicacion: " + event.getUbicacion());
        datos1 = new Paragraph("Pais: " + event.getCodigoPais().getNombre());
        datos.setAlignment(Element.ALIGN_RIGHT);
        datos1.setAlignment(Element.ALIGN_RIGHT);
        document.add(datos1);
        document.add(datos);
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        //              PdfPTable table = new PdfPTable(2);
        //              
        //              table.addCell("Cliente: ");
        //              table.addCell(event.getIdCliente().getNombre());
        //              
        //              table.addCell("Descripcion del Evento: ");
        //              table.addCell(event.getDescripcion());
        //              
        //              document.add(table);

        document.add(Tabla_compleja());

        document.close();
        //----------------------------
        //Abrimos el archivo PDF
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
        response.setContentType("application/pdf");
        response.setHeader("Content-disposition", "inline=filename=" + name);
        try {
            response.getOutputStream().write(Util.getBytesFromFile(new File(name)));
            response.getOutputStream().flush();
            response.getOutputStream().close();
            context.responseComplete();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.thomasmore.service.PdfCreateServiceImpl.java

public void readPdf() {
    try {/*from   w  w w.ja  v a  2 s  .  c om*/
        OutputStream file = new FileOutputStream(new File("D:\\SamplePDFje.pdf"));

        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        document.add(new Paragraph("First iText PDF"));
        document.add(new Paragraph(new Date().toString()));

        document.addAuthor("Krishna Sfsfsfsn");
        document.addCreationDate();
        document.addCreator("JavaBeat");
        document.addTitle("Sample PDF");

        //Create Paragraph
        Paragraph paragraph = new Paragraph("Title 1", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD));

        //New line
        paragraph.add(new Paragraph(" "));
        paragraph.add("Test Paragraph");
        paragraph.add(new Paragraph(" "));
        document.add(paragraph);

        //Create a table in PDF
        PdfPTable pdfTable = new PdfPTable(3);
        PdfPCell cell1 = new PdfPCell(new Phrase("Table Header 1"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Table Header 2"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Table Header 3"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);
        pdfTable.setHeaderRows(1);

        pdfTable.addCell("Row 1 Col 1");
        pdfTable.addCell("Row 1 Col 2");
        pdfTable.addCell("Row 1 Col 3");

        pdfTable.addCell("Row 2 Col 1");
        pdfTable.addCell("Row 2 Col 2");
        pdfTable.addCell("Row 2 Col 3");

        document.add(pdfTable);

        document.close();
        file.close();

    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:com.unicauca.coordinacionpis.managedbean.RegistroFormatoAController.java

public void agregarMetadatos() {
    // create document and writer
    Document document = new Document(PageSize.A4);
    PdfWriter writer;//from w  ww.j  a  v a2s  .  c o m
    try {
        writer = PdfWriter.getInstance(document, new FileOutputStream("D:\\aguaabril2016.pdf"));
        // add meta-data to pdf
        document.addAuthor("Memorynotfound");
        document.addCreationDate();
        document.addCreator("Memorynotfound.com");
        document.addTitle("Add meta data to PDF");
        document.addSubject("how to add meta data to pdf using itext");
        document.addKeywords(metadatosAnteproyectos.getTitulo() + "," + metadatosAnteproyectos.getProfesor());
        document.addLanguage(Locale.ENGLISH.getLanguage());
        document.addHeader("type", "tutorial, example");

        // add xmp meta data
        writer.createXmpMetadata();

        document.open();
        document.add(new Paragraph("Add meta-data to PDF using iText"));
        document.close();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(RegistroOfertaAcademicaController.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.util.Imprimir.java

private static void addMetaData(Document document) {
    document.addTitle("Meu primeiro arquivo PDF");
    document.addSubject("Utilizando iText");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("Victor Carlo");
    document.addCreator("X4VC");
}

From source file:com.VanLesh.macsv10.macs.Models.Pdf.java

License:GNU General Public License

private static void addMetaData(Document doc, Calculation calc) {
    doc.addTitle(calc.getTitle());// w  ww  . ja v  a2 s  . c  o  m
    doc.addAuthor(calc.getEngineerName());
    doc.addSubject(calc.getJobSite() + " This PDF was created using itext, and MACS is subject to"
            + "the AGPL license");
    doc.addCreator("MACS v1.0 using itext");
    doc.addKeywords("MACS, itext, PDF");

}

From source file:com.wipro.srs.service.PrintTicket.java

private static void addMetaData(Document document) {
    document.addTitle("Maverick Ship services ");
    document.addSubject("Ticket");
    document.addAuthor("Maverick Ship services");
    document.addCreator("Maverick Ship services");
    document.addCreationDate();//from  w w  w  . java2s .c o m
}

From source file:com.zaptech.pdfdemo.MainActivity.java

private void addMetaData(Document document) {
    document.addTitle("My First PDF");
    document.addSubject("Sample PDF");
    document.addKeywords("Java,Android");
    document.addAuthor("Bandish Mehta");
    document.addCreator("Bandish Mehta");
}