List of usage examples for com.itextpdf.text Document addTitle
public boolean addTitle(String title)
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 w ww . j a v a 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.systemevent.jsfclass.util.PdfEvento.java
public void imprimirPdf(Evento events) { Evento event = events;//from w w w . j ava2s. c om //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 www . jav a2s . c o m*/ 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;/* w w w . ja v a2 s . 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()); 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 ww w.j a v a 2s. c o m }
From source file:com.workhub.utils.PDFUtils.java
private static void addMetaData(Document document, String title, String creator) { document.addTitle(title); // document.addSubject("Using iText"); // document.addKeywords("Java, PDF, iText"); // document.addAuthor("Lars Vogel"); document.addCreator(creator);//from www . ja v a2 s . co 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"); }
From source file:com.zentrix.minutas.SMinuta.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request//from www .ja v a2s . c o m * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //obtenemos los datos de la forma String titulo = request.getParameter("titulo"); String cuerpo = request.getParameter("cuerpominuta"); ServletOutputStream sos = response.getOutputStream(); response.setContentType("application/pdf"); //creamos un nuevo documento Document doc = new Document(); //creamos los estilos y las fuentes Font bfBold20 = new Font(FontFamily.TIMES_ROMAN, 20, Font.BOLD, new BaseColor(0, 0, 0)); Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLDITALIC, new BaseColor(0, 0, 0)); Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12); try { //creamos un instancio de PdfWriter usando el OutputStream PdfWriter.getInstance(doc, sos); doc.addAuthor("Sistema Gestor de Academias"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Sistema de Academias"); doc.addTitle(titulo); doc.setPageSize(PageSize.LETTER); doc.open(); doc.add(new Paragraph(titulo, bfBold20)); doc.add(new Paragraph(cuerpo, bf12)); doc.close(); // PrintWriter out = response.getWriter(); // out.println("titulo "+ titulo); // out.println("cuerpo "+ cuerpo); } catch (DocumentException ex) { ex.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }