List of usage examples for com.itextpdf.text Document addTitle
public boolean addTitle(String title)
From source file:printInv.GenerateInvoice.java
private void createPDF(String pdfFilename) { Document doc = new Document(); PdfWriter docWriter = null;//from ww w .jav a 2s. c om 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 {// w ww . ja 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 w w w. j a v a2 s . c o m*/ 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")); }
From source file:report.pdfs.Labour_PDF_Report.java
private void addMetaData(Document document) { document.addTitle("Labour Overview Report"); document.addSubject("Labour"); document.addKeywords("Basics, Labour, Report"); document.addAuthor("admin"); document.addCreator(System.getProperty("user.name")); }
From source file:report.pdfs.Lighting_PDF_Report.java
private void addMetaData(Document document) { document.addTitle("Lighting Overview Report"); document.addSubject("Lighting"); document.addKeywords("Basics, Lighting, Report"); document.addAuthor("admin"); document.addCreator(System.getProperty("user.name")); }