List of usage examples for com.itextpdf.text Document addTitle
public boolean addTitle(String title)
From source file:com.mycompany.mavenproject1.Createpdf.java
public void createPDF(String pdfFilename) { Document doc = new Document(); PdfWriter docWriter = null;// ww w. ja v a 2s .co m initializeFonts(); try { String path = "C:\\Users\\Thaskioglu\\Downloads\\" + pdfFilename; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path)); doc.addAuthor("FabulousCar"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("FabulousCar"); doc.addTitle("Invoice"); doc.setPageSize(PageSize.LETTER); doc.open(); PdfContentByte cb = docWriter.getDirectContent(); boolean beginPage = true; int y = 0; for (int i = 0; i < 100; 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); } catch (DocumentException dex) { dex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } finally { if (doc != null) { doc.close(); } if (docWriter != null) { docWriter.close(); } } }
From source file:com.mycompany.mavenproject2.VirtualkeyController.java
private static void addMetaData(Document document) { document.addTitle("Item"); document.addSubject("Item History "); document.addKeywords("Item, History, POS"); document.addAuthor("Store Name"); document.addCreator("Germanium Inc."); }
From source file:com.photoshop.misc.Factuurgenerator.java
private void addMetaData(Document document) { document.addTitle("Factuur: " + order.getId()); //Moet order nummer uit database worden document.addAuthor("Photowinkel"); document.addCreator("Photowinkel"); }
From source file:com.photoshop.misc.Indexkaartgenerator.java
private void addMetaData(Document document) { document.addTitle("Indexkaart: " + order.getId()); //Moet order nummer uit database worden document.addAuthor("Fotowinkel"); // naam fotograaf document.addCreator("Fotowinkel"); }
From source file:com.planfeed.services.MeetingServiceImpl.java
License:Apache License
public ByteArrayOutputStream getActa(String meetingId) throws Exception { Meeting meeting;//from w w w . j a v a 2 s.c om try { meeting = this.getMeeting(meetingId); } catch (Exception e) { throw new MeetingNotFound(); } Document document = new Document(); ByteArrayOutputStream baosPDF = new ByteArrayOutputStream(); PdfWriter docWriter = null; HeaderFooter event = new HeaderFooter(meeting.getDate()); docWriter = PdfWriter.getInstance(document, baosPDF); docWriter.setBoxSize("art", new Rectangle(36, 54, 559, 788)); docWriter.setPageEvent(event); document.open(); //metadata document.addTitle(meeting.getTitle() + " Acta"); document.add(new Paragraph(" ")); //Title Paragraph title = new Paragraph("Acta of " + meeting.getTitle(), titleFont); title.setAlignment(Element.ALIGN_CENTER); addEmptyLine(title, 1); document.add(title); //Description Paragraph descriptionPar = new Paragraph(); descriptionPar.add(new Paragraph("Description", titlePointFont)); descriptionPar.add(new Paragraph(meeting.getDescription(), textFont)); addEmptyLine(descriptionPar, 1); document.add(descriptionPar); //Points int index = 1; for (PointOfAgenda point : meeting.getAgenda()) { Paragraph pointPar = new Paragraph(); pointPar.add(new Paragraph(index + ". " + point.getName(), titlePointFont)); pointPar.add(new Paragraph(point.getComment(), textFont)); addEmptyLine(pointPar, 2); document.add(pointPar); index += 1; } document.close(); return baosPDF; }
From source file:com.planning.project.controller.CreatePDF.java
private static void addMetaData(Document document) { document.addTitle("Generate PDF report"); document.addSubject("Generate PDF report"); document.addAuthor("Java Honk"); document.addCreator("Java Honk"); }
From source file:com.preselect.pdfservice.tasks.PdfConversionTask.java
License:Open Source License
private static void copyDocument(PdfReader reader, int start, int end, String path, OutlineItems outline) throws IOException, DocumentException { Document document = new Document(); PdfSmartCopy copy = new PdfSmartCopy(document, new FileOutputStream(path)); document.open();/* www . ja va 2 s . c o m*/ for (int i = (start - 1); i <= (end - 1);) { copy.addPage(copy.getImportedPage(reader, ++i)); } List<OutlineItem> outlineForChapter = getOutlineBetweenPages(outline, start, end); Iterator<OutlineItem> iterator = outlineForChapter.iterator(); if (iterator.hasNext()) { List<HashMap<String, Object>> bookmarksForChapter = getBookmarks(iterator.next(), iterator, 1); SimpleBookmark.shiftPageNumbers(bookmarksForChapter, (-start + 1), null); copy.setOutlines(bookmarksForChapter); } if (outlineForChapter.size() > 0) { OutlineItem firstOutline = outlineForChapter.get(0); document.addTitle(firstOutline.getTitle()); } document.addCreator("Content Select"); document.close(); copy.close(); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorActivosFijos.java
public void crearPDFInversion(HttpServletResponse hsr1, ArrayList<HashMap> resultados, double granTotalDepActual, double granTotalValorActual, double granTotalValorOr) throws Exception { Document dcmntaf = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(dcmntaf, baos); System.out.println(resultados.get(0).size()); dcmntaf.open();/*from www . j a v a 2 s.c o m*/ dcmntaf.open(); dcmntaf.addTitle("Sapito PDFs"); dcmntaf.addSubject("Pdf de sapito"); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); dcmntaf.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); dcmntaf.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); dcmntaf.add(footer); //---------------------- TITLE --------------------------- String titulo = "Reporte de Inversin"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); String titulo2 = "Reporte de Activos Fijos por Tipo"; //Cambiar el titulo del PDF aqui Font f2 = new Font(FontFamily.HELVETICA, 12.0f, Font.NORMAL, BaseColor.BLACK); Chunk c2 = new Chunk(titulo2 + " \n ", f2); c2.setBackground(BaseColor.WHITE); Paragraph title2 = new Paragraph(c2); title2.setAlignment(Element.ALIGN_LEFT); title2.setIndentationLeft(50); //------------------------- CONTENIDO ------------------------------------------------------- dcmntaf.add(title); //Titulo del PDF dcmntaf.add(title2); PdfPTable table = new PdfPTable(4); // PdfPCell cell; // cell = new PdfPCell(new Phrase("Tipo de A", FontFactory.getFont("TIMES_ROMAN", 12, Font.BOLD, BaseColor.BLACK))); // table.addCell(cell); table.addCell("Tipo de Activo fijo"); table.addCell("Valor Original"); table.addCell("Depreciacin Actual "); table.addCell("Valor Actual"); // Iterator it = resultados.get(0).entrySet().iterator(); for (int i = 0; i < resultados.size(); i++) { table.addCell(resultados.get(i).get("tipo").toString()); table.addCell(resultados.get(i).get("valorOriginal").toString()); table.addCell(resultados.get(i).get("depreciacionActual").toString()); table.addCell(resultados.get(i).get("valoreActual").toString()); } // while (it.hasNext()) { // Map.Entry e = (Map.Entry) it.next(); // System.out.println(e.getKey() + " " + e.getValue()); // // table.addCell(e.getValue().toString()); // } dcmntaf.add(table); String titulo3 = "Reporte Total de Activos Fijos"; //Cambiar el titulo del PDF aqui Font f3 = new Font(FontFamily.HELVETICA, 12.0f, Font.NORMAL, BaseColor.BLACK); Chunk c3 = new Chunk(titulo3 + " \n ", f3); c3.setBackground(BaseColor.WHITE); Paragraph title3 = new Paragraph(c3); title3.setAlignment(Element.ALIGN_LEFT); title3.setIndentationLeft(50); dcmntaf.add(title3); PdfPTable table2 = new PdfPTable(3); // PdfPCell cell; // cell = new PdfPCell(new Phrase("Tipo de A", FontFactory.getFont("TIMES_ROMAN", 12, Font.BOLD, BaseColor.BLACK))); // table.addCell(cell); table2.addCell("Valor Original Total"); table2.addCell("Depreciacin Anual Total"); table2.addCell("Valor Total"); table2.addCell(granTotalValorOr + ""); table2.addCell(granTotalDepActual + ""); table2.addCell(granTotalValorActual + ""); dcmntaf.add(table2); PdfPTable table3 = new PdfPTable(1); table3.setWidthPercentage(100.0f); table3.setWidths(new float[] { 2.0f }); table3.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.COURIER_BOLD); font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(BaseColor.BLUE); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Resultado", font)); table3.addCell(cell); Depreciacion dep = new Depreciacion(); String bla = a + " "; table3.addCell(bla); //-------------------------- FIN CONTENIDO ----------------- dcmntaf.close(); dcmntaf.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorContabilidad.java
public void crearEstadoResultados(HttpServletResponse hsr1, String ingresos, String cVenta, String cGeneral, String cImpu, String cImpTot) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();//from w w w . ja va2s. com document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Estado de Resultados"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF PdfPTable table = new PdfPTable(2); table.addCell("Ingresos"); table.addCell(ingresos);//valor table.addCell("Costo de Venta"); table.addCell(cVenta);//valor table.addCell("Costos Generales"); table.addCell(cGeneral);//valor table.addCell("Impuestos de Ingresos"); table.addCell(cImpu);//valor table.addCell("Impuesto de Costos Totales"); table.addCell(cImpTot);//valor document.add(table); document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorContabilidad.java
public void crearVariacionContable(HttpServletResponse hsr1, String sInicial, String aumento, String utilidad, String disminucion, String perdidas, String sFinal) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();//from ww w .j a v a 2 s . c om document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Variaciones de Capital Contable"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF PdfPTable table = new PdfPTable(2); table.addCell("Saldo al inicio del ejercicio"); table.addCell(sInicial);//valor table.addCell("Aumentos"); table.addCell(aumento);//valor table.addCell("Utilidades"); table.addCell(utilidad);//valor table.addCell("Disminuciones"); table.addCell(disminucion);//valor table.addCell("Perdidas"); table.addCell(perdidas);//valor table.addCell("Saldo al final del ejercicio"); table.addCell(sFinal);//valor document.add(table); document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }