List of usage examples for com.itextpdf.text.pdf PdfPTable setSpacingBefore
public void setSpacingBefore(final float spacing)
From source file:main.java.ru.tsystems.restserviceclient.ServiceBean.java
public void downloadFile() throws IOException, org.json.simple.parser.ParseException { HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext() .getResponse();/*w w w . j a v a 2 s . c om*/ try { // Get the text that will be added to the PDF String text = request; if (text == null || text.trim().length() == 0) { text = "No data."; } // step 1 Document document = new Document(); // step 2 ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); // step 3 document.open(); // step 4 document.add(new Paragraph("Tickets from " + dateToString(dateFrom) + " to " + dateToString(dateTo))); PdfPTable table = new PdfPTable(7); // 3 columns. table.setWidthPercentage(100); //Width 100% table.setSpacingBefore(10f); //Space before table table.setSpacingAfter(10f); //Space after table //Set Column widths float[] columnWidths = { 1f, 1f, 1f, 1f, 1f, 1f, 1f }; table.setWidths(columnWidths); PdfPCell cell1 = new PdfPCell(new Paragraph("Id")); ; PdfPCell cell2 = new PdfPCell(new Paragraph("Departure")); ; PdfPCell cell3 = new PdfPCell(new Paragraph("Passenger")); PdfPCell cell4 = new PdfPCell(new Paragraph("Route")); PdfPCell cell5 = new PdfPCell(new Paragraph("From")); PdfPCell cell6 = new PdfPCell(new Paragraph("To")); PdfPCell cell7 = new PdfPCell(new Paragraph("Train")); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); table.addCell(cell5); table.addCell(cell6); table.addCell(cell7); //parse data JSONParser parser = new JSONParser(); JSONArray array = (JSONArray) parser.parse(text); for (Object obj : array) { JSONObject objTemp = (JSONObject) obj; long ticketId = (long) objTemp.get("ticketId"); String t = Long.toString(ticketId); table.addCell(t); table.addCell((String) objTemp.get("depatureTime")); table.addCell((String) objTemp.get("passenger")); table.addCell((String) objTemp.get("route")); table.addCell((String) objTemp.get("stationFrom")); table.addCell((String) objTemp.get("stationTo")); table.addCell((String) objTemp.get("train")); } document.add(table); // step 5 document.close(); // setting some response headers response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); // setting the content type response.setContentType("application/pdf"); // the contentlength response.setContentLength(baos.size()); // write ByteArrayOutputStream to the ServletOutputStream OutputStream os = response.getOutputStream(); baos.writeTo(os); os.flush(); os.close(); FacesContext.getCurrentInstance().getResponseComplete(); } catch (DocumentException e) { logger.error("Error!", e); } }
From source file:model.PDFModel.java
License:Open Source License
public PdfPTable createDailyTable(String date) throws DocumentException { PdfPTable dailyTable = new PdfPTable(3); PdfPCell cell;/*from w w w . jav a 2s .c o m*/ dailyTable.setSpacingBefore(5f); cell = new PdfPCell(new Phrase("Stolik dnia")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); dailyTable.addCell(cell); cell = new PdfPCell(new Phrase("Potrawa dnia")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); dailyTable.addCell(cell); cell = new PdfPCell(new Phrase("Suma rachunkw")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); dailyTable.addCell(cell); double theBestTableEarnings = 0.00; int theBestTableNumber = 0; for (int i = 1; i < totalTablePayment.length; i++) { if (theBestTableEarnings < totalTablePayment[i]) { theBestTableEarnings = totalTablePayment[i]; theBestTableNumber = i; } } cell = new PdfPCell(new Phrase("Stolik " + String.valueOf(theBestTableNumber))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); dailyTable.addCell(cell); cell = new PdfPCell(new Phrase(query.getDailyBestSellingProduct(date))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); dailyTable.addCell(cell); cell = new PdfPCell(new Phrase(query.getDailyTakings(date))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); dailyTable.addCell(cell); return dailyTable; }
From source file:naprawa.praca.PracaController.java
public void akcjaDrukuj() { mapaUslug = getDaoFactory().getDaoDefect().pobierzUslugi(getConnection(), wybranyDefect); FileOutputStream file = null; File druk = null;/*w w w . ja va 2 s . co m*/ try { Document document = new Document(PageSize.A5, 0, 0, 0, 0); String userPath = System.getProperty("user.home"); druk = new File(userPath + "/Baks wydruki"); if (!druk.exists()) { druk.mkdirs(); } File wydruk = new File(druk + "/" + wybranyDefect.getInfoNaprawa() + ".pdf"); if (!wydruk.exists()) { try { wydruk.createNewFile(); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } } file = new FileOutputStream(wydruk); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(wydruk)); document.open(); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.setSpacingBefore(0f); table.setSpacingAfter(0f); PdfPTable tableO = new PdfPTable(2); tableO.setWidthPercentage(100); tableO.setSpacingBefore(0f); table.setSpacingAfter(0f); tableO.addCell(getNewCell( "BAK's Machine\nin. Baej Krzciuk\n26-800 Biaobrzegi\nul. Brzechwy 31\ntel. 509-281-487")); Image image = Image.getInstance(getClass().getClassLoader().getResource("baksZ.jpg")); tableO.addCell(image); table.addCell(tableO); PdfPCell cell1 = getNewCell( "Biaobrzegi, dn. " + new SimpleDateFormat("yyyy-MM-dd").format(new Date())); cell1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell1); table.addCell(addTableCzesc()); table.addCell(addTableCzescService("Materiay", RodzajUslugi.MATERIAL)); table.addCell(addTableCzescService("Naprawa", RodzajUslugi.NAPRAWA)); PdfPTable tablePodsumowanie = new PdfPTable(3); tablePodsumowanie.setWidthPercentage(100); int[] width = { 8, 77, 15 }; tablePodsumowanie.setWidths(width); PdfPCell cell = getNewCell("Podsumowanie"); cell.setColspan(10); cell.setBorder(PdfPCell.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tablePodsumowanie.addCell(cell); tablePodsumowanie.addCell(getNewCell("1.")); tablePodsumowanie.addCell(getNewCell("Czci")); tablePodsumowanie.addCell(getNewCell(wybranyDefect.getKosztCzesciS() + " z")); tablePodsumowanie.addCell(getNewCell("2.")); tablePodsumowanie.addCell(getNewCell("Materiay")); tablePodsumowanie.addCell(getNewCell(wybranyDefect.getKosztMaterialyS() + " z")); tablePodsumowanie.addCell(getNewCell("3.")); tablePodsumowanie.addCell(getNewCell("Naprawa")); tablePodsumowanie.addCell(getNewCell(wybranyDefect.getKosztNaprawyS() + " z")); tablePodsumowanie.addCell(getNewCell("")); tablePodsumowanie.addCell(getNewCell("RAZEM")); tablePodsumowanie.addCell(getNewCell(wybranyDefect.getKosztSumaS() + " z")); table.addCell(tablePodsumowanie); document.add(table); document.close(); writer.close(); } catch (Exception e) { e.printStackTrace(); } } catch (FileNotFoundException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); BaksSessionBean.getInstance().fireMessage(widok, "Wydruk", "Pdf do ktrego chcesz zapisa wynik jest otwarty!\n Zamknij i sprbuj jeszcze raz."); } finally { try { file.close(); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } } Desktop desktop = null; if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); try { desktop.open(druk); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } } BaksSessionBean.getInstance().fireMessage(widok, "Zapis", "Wydruk zapisany w folderze: " + System.getProperty("user.home") + "/Baks wydruki"); }
From source file:net.digitstar.vanadio.helpers.PdfHelper.java
License:Apache License
public static PdfPTable newTable(TableStyle style) { PdfPTable t; if (style.getColumnWidths() == null) { t = new PdfPTable(style.getColumnNumber()); } else {/*from ww w .ja va 2s . c o m*/ float[] w = style.getColumnWidths(); if (style.getColumnWidths().length < style.getColumnNumber()) { w = new float[style.getColumnNumber()]; System.arraycopy(style.getColumnWidths(), 0, w, 0, style.getColumnWidths().length); Arrays.fill(w, style.getColumnWidths().length, w.length, style.getColumnWidths()[style.getColumnWidths().length - 1]); } t = new PdfPTable(w); } t.setWidthPercentage(style.getWidthPct()); t.setSpacingBefore(style.getSpacingBefore()); t.setSpacingAfter(style.getSpacingAfter()); return t; }
From source file:nl.ctmm.trait.proteomics.qcviewer.utils.ReportPDFExporter.java
License:Apache License
/** * Create the metrics values table for given report unit. This table will be added to the PDF document. * * @param allMetricsMap map of all QC metrics - keys and description. * @param reportUnit Report unit for which to create the metrics values table. * @return PDF table containing metrics values of the report unit. *///from w ww. j av a 2 s. c o m private static PdfPTable createMetricsValuesTable(final Map<String, String> allMetricsMap, final ReportUnit reportUnit) { /* * TODO: Column size, font size and spacing of the metrics value table. */ // Create columns names. final String columnNames[] = { Constants.METRICS_ID_COLUMN_NAME, Constants.DESCRIPTION_COLUMN_NAME, Constants.VALUE_COLUMN_NAME, Constants.METRICS_ID_COLUMN_NAME, Constants.DESCRIPTION_COLUMN_NAME, Constants.VALUE_COLUMN_NAME, }; //Creation of table object. final PdfPTable table = new PdfPTable(columnNames.length); try { table.setSpacingBefore(TABLE_SPACING); //Set the table width. table.setTotalWidth(COLUMN_WIDTHS); table.setLockedWidth(true); //Add table header. for (int i = 0; i < TOTAL_COLUMNS; ++i) { final PdfPCell headerCell = new PdfPCell(new Phrase(columnNames[i], Constants.TABLE_HEADER_FONT)); headerCell.setBackgroundColor(BaseColor.RED); headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(headerCell); } //Read metricsValues corresponding to reportUnit. final Map<String, String> metricsValues = reportUnit.getMetricsValues(); //TODO: Split allMetricsMap in two parts such that sorted rows are properly added in the table. //Get all keys final Object[] keyArray = allMetricsMap.keySet().toArray(); //get all values final Object[] valueArray = allMetricsMap.values().toArray(); //Calculate halfSize final int halfSize = keyArray.length / 2; for (int i = 0; i < halfSize; ++i) { addMetric(keyArray[i].toString(), valueArray[i].toString(), metricsValues, table); addMetric(keyArray[i + halfSize].toString(), valueArray[i + halfSize].toString(), metricsValues, table); } } catch (final DocumentException e) { //DocumentException signals that an error has occurred in a Document. logger.log(Level.SEVERE, String.format(PDF_TABLE_EXCEPTION_MESSAGE, reportUnit.getMsrunName()), e); } return table; }
From source file:org.apache.jmeter.visualizers.CreateReport.java
License:Apache License
public void createPdf(String filename, Document document2) throws IOException, DocumentException { // step 1//from w w w . jav a 2s. co m Document document = new Document(); // step 2 // OutputStream outputStream = new OutputStream(new FileOutputStream(filename)); PdfWriter.getInstance(document, new FileOutputStream(filename)); // step 3 document.open(); // step 4 Font titleFont = new Font(Font.FontFamily.HELVETICA, 30, Font.BOLD, clr);//BaseColor.Color.getHSBColor(258, 100, 13)); Paragraph emptyLine = new Paragraph(); addEmptyLine(emptyLine, 2); Paragraph title = new Paragraph("Test Report", titleFont); title.setAlignment(Element.ALIGN_CENTER); BaseColor BC = new BaseColor(164, 188, 196); document.add(title); document.add(emptyLine); emptyLine = new Paragraph(" "); Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("E yyyy.MM.dd 'at' hh:mm:ss a zzz"); // addEmptyLine(emptyLine, 0); document.add(new Paragraph("Report created on : " + ft.format(dNow), small)); document.add(emptyLine); document.add(emptyLine); document.add(emptyLine); document.add(new Paragraph("Test Summary Report", subFont)); // document.add(emptyLine); PdfPTable table = createTable1(); PdfPTable table2 = createTable2(); document.add(new Paragraph(" ")); document.add(emptyLine); document.add(table); document.add(emptyLine); document.add(emptyLine); document.add(emptyLine); document.add(new Paragraph("Test Error Report", subFont)); document.add(emptyLine); document.add(emptyLine); document.add(table2); table.setSpacingBefore(5); table.setSpacingAfter(5); table2.setSpacingBefore(5); table2.setSpacingAfter(5); // step 5 //adding graphs //PdfWriter writer ; // writer = PdfWriter.getInstance(document, outputStream); Image[] img = new Image[5]; img[0] = createGraphs("Average Response Time of samples for each Request", "Average(ms)", 2); // df *add 90%line and no of samples to csv summary model table img[1] = createGraphs("Number of samples processed for each Request", "Number of Samples", 2); img[2] = createGraphs("Error % of samples for each Request", "Error %", 6); img[3] = createGraphs("Throughput of samples for each Request", "Throughput(ms)", 7); img[4] = createGraphs("90 % Line of samples for each Request", "90% line(ms)", 2); // document.add(image1); document.add(img[0]); // document. //release resources document.close(); document = null; }
From source file:org.cherchgk.actions.tournament.result.show.GetPDFTournamentResultAction.java
License:Apache License
public InputStream getDocument() throws DocumentException, IOException { Font normalFont = getNormalFont(); Font boldFont = getBoldFont(); ByteArrayOutputStream out = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document, out); document.open();/*w w w. ja va2 s. c o m*/ Paragraph tournamentNameParagraph = new Paragraph(tournament.getTitle(), boldFont); tournamentNameParagraph.setAlignment(Element.ALIGN_CENTER); document.add(tournamentNameParagraph); Paragraph tournamentDateParagraph = new Paragraph(tournament.getDateAsString(), boldFont); tournamentDateParagraph.setAlignment(Element.ALIGN_CENTER); document.add(tournamentDateParagraph); if (teamCategory != null) { Paragraph teamCategoryParagraph = new Paragraph(teamCategory.getTitle(), boldFont); teamCategoryParagraph.setAlignment(Element.ALIGN_CENTER); document.add(teamCategoryParagraph); } int numColumns = 3 + tournamentResult.getRankingAlgorithms().size(); PdfPTable resultTable = new PdfPTable(numColumns); int[] widths = new int[numColumns]; widths[0] = 1; widths[1] = 3; for (int i = 2; i < numColumns; i++) { widths[i] = 1; } resultTable.setWidths(widths); resultTable.setSpacingBefore(10f); PdfPCell cell = new PdfPCell(new Phrase("", boldFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setColspan(2); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); resultTable.addCell(cell); for (RankingAlgorithm rankingAlgorithm : tournamentResult.getRankingAlgorithms()) { cell = new PdfPCell(new Phrase(rankingAlgorithm.getPointName(), boldFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); resultTable.addCell(cell); } cell = new PdfPCell(new Phrase("?", boldFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); resultTable.addCell(cell); boolean showTeamCategoryInTable = (teamCategory == null) && !tournament.getTeamCategories().isEmpty(); for (TournamentResult.TeamResult teamResult : tournamentResult.getTeamResultList()) { if (showTeamCategoryInTable) { if (teamResult.getTeam().getTeamCategory() != null) { cell = new PdfPCell(new Phrase(teamResult.getTeam().getTeamCategory().getTitle(), normalFont)); } else { cell = new PdfPCell(new Phrase("", normalFont)); } resultTable.addCell(cell); } cell = new PdfPCell(new Phrase(teamResult.getTeam().getName(), normalFont)); if (!showTeamCategoryInTable) { cell.setColspan(2); } resultTable.addCell(cell); for (Map<Team, RankingPoint> m : tournamentResult.getRankingPointsList()) { cell = new PdfPCell(new Phrase(m.get(teamResult.getTeam()).toString(), normalFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); resultTable.addCell(cell); } cell = new PdfPCell(new Phrase(teamResult.getPlace(), normalFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); resultTable.addCell(cell); } document.add(resultTable); document.close(); return new ByteArrayInputStream(out.toByteArray()); }
From source file:org.cidte.sii.negocio.PDFWriter.java
public void writePDF(ArrayList<Writable> list, String directorio, String nombre, java.awt.Image image) throws DocumentException, FileNotFoundException, BadElementException, IOException { Document doc = new Document(); PdfWriter docWriter;//from w ww . j a va2 s.co m // special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 12); // file path String path = directorio + nombre + ".pdf"; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(new File(path))); // document header attributes doc.addAuthor("sii"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("sii"); doc.addTitle(nombre); doc.setPageSize(PageSize.LETTER); // open document doc.open(); Image img = Image.getInstance(image, null); img.setAlignment(Element.ALIGN_LEFT); doc.add(img); // create a paragraph Paragraph paragraph = new Paragraph("iText is a library that allows you to create and " + "manipulate PDF documents. It enables developers looking to enhance web and other " + "applications with dynamic PDF document generation and/or manipulation."); // create PDF table with the given widths PdfPTable table = new PdfPTable(list.get(0).getNames().length); // set table width a percentage of the page width table.setWidthPercentage(100); table.setSpacingBefore(10f); // Space before table table.setSpacingAfter(10f); // Space after table // insert column headings String[] headings = list.get(0).getNames(); for (String heading : headings) { insertCell(table, heading, Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); // insert the data for (int i = 0; i < list.size(); i++) { Writable w = list.get(i); Object[] arr = w.getAsArray(); for (int j = 0; j < arr.length; j++) { // arr[j] insertCell(table, arr[j].toString(), Element.ALIGN_LEFT, 1, bf12); } } // insert an empty row // insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12); // add the PDF table to the paragraph paragraph.add(table); // add the paragraph to the document doc.add(paragraph); // close the document doc.close(); // close the writer docWriter.close(); }
From source file:org.dspace.disseminate.CitationDocument.java
/** * Takes a DSpace {@link Bitstream} and uses its associated METADATA to * create a cover page./* www .j a v a 2 s .c o m*/ * * @param cDoc The cover page document to add cited information to. * @param writer * @param cMeta * METADATA retrieved from the parent collection. * @throws IOException * @throws DocumentException */ private void generateCoverPage(Document cDoc, PdfWriter writer, CitationMeta cMeta) throws DocumentException { cDoc.open(); writer.setCompressionLevel(0); Item item = cMeta.getItem(); //Set up some fonts Font helv26 = FontFactory.getFont(FontFactory.HELVETICA, 26f, BaseColor.BLACK); Font helv16 = FontFactory.getFont(FontFactory.HELVETICA, 16f, BaseColor.BLACK); Font helv12 = FontFactory.getFont(FontFactory.HELVETICA, 12f, BaseColor.BLACK); Font helv12_italic = FontFactory.getFont(FontFactory.HELVETICA_OBLIQUE, 12f, BaseColor.BLACK); Font helv11_bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11f, BaseColor.BLACK); Font helv9 = FontFactory.getFont(FontFactory.HELVETICA, 9f, BaseColor.BLACK); // 1 - Header: // University Name // Repository Name repository.url Paragraph university = new Paragraph("The Ohio State University", helv11_bold); cDoc.add(university); PdfPTable repositoryTable = new PdfPTable(2); repositoryTable.setWidthPercentage(100); Chunk repositoryName = new Chunk("Knowledge Bank", helv11_bold); PdfPCell nameCell = new PdfPCell(); nameCell.setBorderWidth(0); nameCell.addElement(repositoryName); Chunk repositoryURL = new Chunk("kb.osu.edu", helv11_bold); repositoryURL.setAnchor("http://kb.osu.edu"); PdfPCell urlCell = new PdfPCell(); urlCell.setHorizontalAlignment(Element.ALIGN_RIGHT); urlCell.setBorderWidth(0); urlCell.addElement(repositoryURL); repositoryTable.addCell(nameCell); repositoryTable.addCell(urlCell); repositoryTable.setSpacingAfter(5); cDoc.add(repositoryTable); // Line Separator LineSeparator lineSeparator = new LineSeparator(); cDoc.add(lineSeparator); // 2 - Bread Crumbs // Community Name Collection Name PdfPTable breadcrumbTable = new PdfPTable(2); breadcrumbTable.setWidthPercentage(100); Chunk communityName = new Chunk(getOwningCommunity(item), helv9); PdfPCell commCell = new PdfPCell(); commCell.setBorderWidth(0); commCell.addElement(communityName); Chunk collectionName = new Chunk(getOwningCollection(item), helv9); PdfPCell collCell = new PdfPCell(); collCell.setHorizontalAlignment(Element.ALIGN_RIGHT); collCell.setBorderWidth(0); collCell.addElement(collectionName); breadcrumbTable.addCell(commCell); breadcrumbTable.addCell(collCell); breadcrumbTable.setSpacingBefore(5); breadcrumbTable.setSpacingAfter(5); cDoc.add(breadcrumbTable); // Line Separator cDoc.add(lineSeparator); // 3 - Metadata // date.issued // dc.title // dc.creator; dc.creator Paragraph dateIssued = new Paragraph(getFirstMetadata(item, "dc.date.issued"), helv12); dateIssued.setSpacingBefore(20); cDoc.add(dateIssued); Paragraph title = new Paragraph(item.getName(), helv26); title.setSpacingBefore(15); cDoc.add(title); Paragraph creators = new Paragraph(getAllMetadataSeperated(item, "dc.creator"), helv16); creators.setSpacingBefore(30); creators.setSpacingAfter(20); cDoc.add(creators); // Line Separator cDoc.add(lineSeparator); // 4 - Citation // dc.identifier.citation // dc.identifier.uri Paragraph citation = new Paragraph(getFirstMetadata(item, "dc.identifier.citation"), helv12); Chunk identifierChunk = new Chunk(getFirstMetadata(item, "dc.identifier.uri"), helv12); identifierChunk.setAnchor(getFirstMetadata(item, "dc.identifier.uri")); Paragraph identifier = new Paragraph(); identifier.add(identifierChunk); cDoc.add(citation); cDoc.add(identifier); // 5 - License // Downloaded from the Knowledge Bank, The Ohio State University's institutional repository Paragraph license = new Paragraph( "Downloaded from the Knowledge Bank, The Ohio State University's institutional repository", helv12_italic); license.setSpacingBefore(10); cDoc.add(license); cDoc.close(); }
From source file:org.inspira.condominio.pdf.DocumentoEgresos.java
public void exportarPdf(String destino) throws IOException, DocumentException { File file = new File(destino); file.getParentFile().mkdirs();//from w ww . ja v a 2 s . c o m PdfWriter.getInstance(documento, new FileOutputStream(file)); documento.open(); documento.add(new Paragraph( "Periodo: ".concat( DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()).format(new Date())), F_NORMAL)); documento.add(new Paragraph(admin, F_NORMAL)); Paragraph heading = new Paragraph("Gastos ".concat(tipoDeGasto), new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD, new BaseColor(0x000000))); heading.setSpacingBefore(16f); heading.setSpacingAfter(16f); Paragraph heading2 = new Paragraph("Autoriz", new Font(Font.FontFamily.HELVETICA, 12, Font.NORMAL, new BaseColor(0x000000))); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); Paragraph heading3 = new Paragraph("Vo. Bo.", new Font(Font.FontFamily.HELVETICA, 12, Font.NORMAL, new BaseColor(0x000000))); PdfPCell cell1 = new PdfPCell(heading2); cell1.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell1.setColspan(1); cell1.setFixedHeight(20f); cell1.setBorder(Rectangle.NO_BORDER); PdfPCell cell2 = new PdfPCell(heading3); cell2.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell2.setColspan(1); cell2.setFixedHeight(20f); cell2.setBorder(Rectangle.NO_BORDER); table.addCell(cell1); table.addCell(cell2); table.setSpacingBefore(16f); table.setSpacingAfter(32f); documento.add(heading); agregarTablaEgresos(egresos); documento.add(table); agregarZonaVistoBueno(); documento.close(); }