List of usage examples for com.lowagie.text.pdf PdfPTable PdfPTable
public PdfPTable(PdfPTable table)
PdfPTable
. From source file:ambit2.data.qmrf.Qmrf_Xml_Pdf.java
License:Open Source License
public void headerTable(Document pdfdoc, org.w3c.dom.Document xmldoc) { try {/* w ww. j a v a2 s . co m*/ int header_font_size = 10; Image png_left = Image .getInstance(Qmrf_Xml_Pdf.class.getClassLoader().getResource("ambit/data/qmrf/logo.png")); Image png_right = Image .getInstance(Qmrf_Xml_Pdf.class.getClassLoader().getResource("ambit/data/qmrf/logo.png")); png_left.setAlignment(Image.LEFT); png_right.setAlignment(Image.RIGHT); png_left.scalePercent(60); png_right.scalePercent(60); //png.scaleAbsolute(76, 67); //png.setAlignment(Image.MIDDLE); PdfPCell cell; float[] widths = { 1f, 5f, 1f }; float[] widths1 = { 1f }; PdfPTable table = new PdfPTable(widths); PdfPTable table1 = new PdfPTable(widths1); table.setWidthPercentage(100); cell = new PdfPCell(); cell.setMinimumHeight(70); cell.addElement(new Chunk(png_left, +14, -40)); table.addCell(cell); String Text = ""; try { Text = findNodeValue(xml_QMRF_number, xmldoc); Chunk ident_title = new Chunk("QMRF identifier (ECB Inventory):"); Chunk ident_text = new Chunk(Text); Font bi_font = new Font(baseFont, header_font_size, Font.BOLDITALIC); Font i_font = new Font(baseFont, header_font_size, Font.ITALIC); ident_title.setFont(bi_font); ident_text.setFont(i_font); Paragraph p = new Paragraph(); p.add(ident_title); p.add(ident_text); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table1.addCell(cell); ident_title = new Chunk("QMRF Title:"); Phrase textPhrase = new Phrase(); createNodePhrase("QSAR_title", xmldoc, textPhrase, i_font); ident_title.setFont(bi_font); p = new Paragraph(); p.add(ident_title); p.add(textPhrase); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table1.addCell(cell); java.util.Date now = new java.util.Date(); java.text.DateFormat df = java.text.DateFormat.getDateInstance(); String date = df.format(now); ident_title = new Chunk("Printing Date:"); ident_text = new Chunk(date); ident_title.setFont(bi_font); ident_text.setFont(i_font); p = new Paragraph(); p.add(ident_title); p.add(ident_text); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table1.addCell(cell); p = new Paragraph(""); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table1.addCell(cell); cell = new PdfPCell(table1); cell.setPadding(0f); table.addCell(cell); } catch (Throwable x) { x.printStackTrace(); } //table.addCell(new PdfPCell(png, true)); cell.addElement(new Chunk(png_right, +14, -40)); table.addCell(cell); pdfdoc.add(table); pdfdoc.add(new Paragraph(16)); } catch (Exception x) { x.printStackTrace(); } }
From source file:ambit2.db.reporters.PDFReporter.java
public void header(Document output, Q query) { output.addCreationDate();// ww w . j a v a 2 s. c o m output.addCreator(getClass().getName()); output.addSubject(""); output.addAuthor("http://ambit.sourceforge.net"); output.addHeader("License", getLicenseURI()); output.addTitle(query.toString()); output.addKeywords(query.toString()); if (getLicenseURI() != null) { HeaderFooter footer = new HeaderFooter(new Phrase(String.format("License %s", getLicenseURI())), false); footer.setAlignment(Element.ALIGN_CENTER); output.setFooter(footer); } output.open(); font = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL); table = new PdfPTable(new float[] { 3f, 5f }); table.setWidthPercentage(100); try { writeHeader(output); } catch (Exception x) { } }
From source file:at.htlpinkafeld.beans.JahresuebersichtBean.java
/** * pre processes the PDF for creating/* w ww .java2 s. com*/ * * @param document pdf-doc * @throws DocumentException may be thrown */ public void preProcessPDF(Object document) throws DocumentException { Document pdf = (Document) document; pdf.open(); pdf.setPageSize(PageSize.A4); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); table.addCell(getCell("Jahresbersicht - " + selectedYear.getYear(), PdfPCell.ALIGN_LEFT)); table.addCell(getCell("", PdfPCell.ALIGN_CENTER)); table.addCell(getCell("von " + selectedUser.getPersName(), PdfPCell.ALIGN_RIGHT)); pdf.add(table); pdf.add(new Paragraph("\n")); }
From source file:at.htlpinkafeld.beans.UserDetailsBean.java
public void preProcessPDF(Object document) throws DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.A4.rotate()); pdf.open();/*from w w w . ja v a 2s .c om*/ PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); table.addCell(getCell("Monatsbersicht - " + selectedDate.format(DateTimeFormatter.ofPattern("MM.yyyy")), PdfPCell.ALIGN_LEFT)); table.addCell(getCell("", PdfPCell.ALIGN_CENTER)); table.addCell(getCell("von " + selectedUser, PdfPCell.ALIGN_RIGHT)); pdf.add(table); pdf.add(new Paragraph("\n")); }
From source file:be.fedict.eid.applet.service.impl.PdfGenerator.java
License:Open Source License
public byte[] generatePdf(EIdData eIdData) throws DocumentException { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); document.open();/*from w ww .j ava 2 s. c o m*/ Paragraph titleParagraph = new Paragraph("eID Identity Data"); titleParagraph.setAlignment(Paragraph.ALIGN_CENTER); Font titleFont = titleParagraph.getFont(); titleFont.setSize((float) 20.0); titleFont.setStyle(Font.BOLD); titleParagraph.setSpacingAfter(20); document.add(titleParagraph); if (null != eIdData && null != eIdData.getIdentity()) { if (null != eIdData.getPhoto()) { try { Image image = createImageFromPhoto(eIdData.getPhoto()); document.add(image); } catch (Exception e) { LOG.error("Error getting photo: " + e.getMessage()); } Identity identity = eIdData.getIdentity(); // metadata setDocumentMetadata(document, identity.firstName, identity.name); writer.createXmpMetadata(); // create a table with the data of the eID card PdfPTable table = new PdfPTable(2); table.getDefaultCell().setBorder(0); table.addCell("Name"); table.addCell(identity.name); table.addCell("First name"); String firstName = identity.firstName; if (null != identity.middleName) { firstName += " " + identity.middleName; } table.addCell(firstName); table.addCell("Nationality"); table.addCell(identity.nationality); table.addCell("National Registration Number"); table.addCell(identity.nationalNumber); table.addCell("Gender"); table.addCell(identity.gender.toString()); table.addCell("Date of birth"); SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); table.addCell(formatter.format(identity.dateOfBirth.getTime())); table.addCell("Place of birth"); table.addCell(identity.placeOfBirth); if (null != eIdData.getAddress()) { Address address = eIdData.getAddress(); table.addCell("Address"); PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.addElement(new Paragraph(address.streetAndNumber)); cell.addElement(new Paragraph(address.zip + " " + address.municipality)); table.addCell(cell); } document.add(table); // TODO: to be tested /* try { Image barcodeImage = createBarcodeImage(identity.nationalNumber, identity.cardNumber); barcodeImage.setAlignment(Element.ALIGN_CENTER); Paragraph barcodePara = new Paragraph(); barcodePara.add(barcodeImage); document.add(barcodeImage); } catch (Exception e) { LOG.error("Error adding barcode: " + e.getMessage()); } */ } else { document.add(new Paragraph("No eID identity data available.")); } } document.close(); return baos.toByteArray(); }
From source file:be.fedict.eid.tsl.Tsl2PdfExporter.java
License:Open Source License
protected PdfPTable createInfoTable() { final float alpha = 0.22f; final PdfPTable t = new PdfPTable(new float[] { alpha, 1.0f - alpha }); t.getDefaultCell().setBorder(BORDER); t.setWidthPercentage(101f);//from www.j a v a 2 s . co m return t; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRResultsController.java
/** * Create PdfTable with info on each condition of the analysis group; * * @return//from w w w .j a v a2 s . c o m */ //possibly reuse dRInputController's createTableModel(List<PlateCondition> processedConditions) @Override protected PdfPTable createAnalysisGroupInfoTable() { //maps log transformed conc (double) to list of velocities (double) List<DoseResponsePair> fittedData = doseResponseController.getDataToFit(false); //CONTROL HAS BEEN GIVEN A CONCENTRATION FOR FITTING PURPOSES: find control concentration (lowest) List<Double> allConcentrations = new ArrayList<>(); for (DoseResponsePair row : fittedData) { allConcentrations.add(row.getDose()); } Double controlConcentration = Collections.min(allConcentrations); // new table with 6 columns PdfPTable dataTable = new PdfPTable(6); PdfUtils.setUpPdfPTable(dataTable); // add 1st row: column names PdfUtils.addCustomizedCell(dataTable, "DRUG CONCENTRATION", boldFont); PdfUtils.addCustomizedCell(dataTable, "# TECHNICAL REPLICATES", boldFont); PdfUtils.addCustomizedCell(dataTable, "TECHNICAL REPLICATES EXCLUDED?", boldFont); PdfUtils.addCustomizedCell(dataTable, "LOWEST VELOCITY", boldFont); PdfUtils.addCustomizedCell(dataTable, "HIGHEST VELOCITY", boldFont); PdfUtils.addCustomizedCell(dataTable, "MEDIAN VELOCITY", boldFont); // for each condition get results and add a cell for (DoseResponsePair condition : fittedData) { Integer replicates = condition.getResponses().size(); String excluded; int excludedCount = 0; List<Double> velocities = condition.getResponses(); //count how many replicates were excluded for (int i = 0; i < velocities.size(); i++) { Double replicate = velocities.get(i); if (replicate == null) { excludedCount++; } } if (excludedCount == 0) { excluded = "NO"; } else { excluded = "YES, " + excludedCount; } //put log-value of the concentration back to an understandable format String concentration; Double logConc = condition.getDose(); Double transformed = Math.pow(10, logConc); //check which concentration unit is to be used //if lower than 0.1 M: use nM unit if (transformed < Math.pow(10, -7)) { concentration = AnalysisUtils.roundTwoDecimals(transformed * Math.pow(10, 9)) + " nM"; } //if lower than 0.1 mM: use M unit else if (transformed < Math.pow(10, -3)) { concentration = AnalysisUtils.roundTwoDecimals(transformed * Math.pow(10, 6)) + " M"; } //else for everything >= 1 mM use mM unit else { concentration = AnalysisUtils.roundTwoDecimals(transformed * Math.pow(10, 3)) + " mM"; } //if this is the control, replace concentration string if (logConc.equals(controlConcentration)) { concentration = "Control"; } //remove null's (excluded replicates) from velocities collection velocities.removeAll(Collections.singleton(null)); PdfUtils.addCustomizedCell(dataTable, concentration, bodyFont); PdfUtils.addCustomizedCell(dataTable, replicates.toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, excluded, bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(Collections.min(velocities)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(Collections.max(velocities)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(AnalysisUtils.computeMedian(velocities)).toString(), bodyFont); } return dataTable; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRResultsController.java
/** * Create info table for the corresponding fitting mode (initial/normalized) * * @param normalized/*from ww w. j ava 2 s.co m*/ * @return */ @Override protected PdfPTable createFittingInfoTable(boolean normalized) { // 4 columns PdfPTable dataTable = new PdfPTable(4); PdfUtils.setUpPdfPTable(dataTable); DecimalFormat df = new DecimalFormat("0.00E00"); DoseResponseStatisticsHolder statistics = doseResponseController.getdRAnalysisGroup() .getDoseResponseAnalysisResults().getStatistics(normalized); // add 1st row: column names PdfUtils.addCustomizedCell(dataTable, "Parameter", boldFont); PdfUtils.addCustomizedCell(dataTable, "Best-fit value", boldFont); PdfUtils.addCustomizedCell(dataTable, "Standard Error", boldFont); PdfUtils.addCustomizedCell(dataTable, "95% Confidende Interval", boldFont); //parameter names List<String> parameters = new ArrayList<>(); parameters.add("Bottom"); parameters.add("Top"); parameters.add("LogEC50"); parameters.add("Hillslope"); //best-fit values List<Double> bestFitValues = new ArrayList<>(); bestFitValues.add(doseResponseController.getdRAnalysisGroup().getDoseResponseAnalysisResults() .getFittingResults(normalized).getBottom()); bestFitValues.add(doseResponseController.getdRAnalysisGroup().getDoseResponseAnalysisResults() .getFittingResults(normalized).getTop()); bestFitValues.add(doseResponseController.getdRAnalysisGroup().getDoseResponseAnalysisResults() .getFittingResults(normalized).getLogEC50()); bestFitValues.add(doseResponseController.getdRAnalysisGroup().getDoseResponseAnalysisResults() .getFittingResults(normalized).getHillslope()); //standard errors List<Double> standardErrors = new ArrayList<>(); standardErrors.add(statistics.getStdErrBottom()); standardErrors.add(statistics.getStdErrTop()); standardErrors.add(statistics.getStdErrLogEC50()); standardErrors.add(statistics.getStdErrHillslope()); //ec50 does not have a SE, will need to be displayed differently standardErrors.add(Double.NaN); //confidence interval boundaries List<Double> cIBoundaries = new ArrayList<>(); cIBoundaries = AnalysisUtils.addArrayToList(cIBoundaries, statistics.getcIBottom()); cIBoundaries = AnalysisUtils.addArrayToList(cIBoundaries, statistics.getcITop()); cIBoundaries = AnalysisUtils.addArrayToList(cIBoundaries, statistics.getcILogEC50()); cIBoundaries = AnalysisUtils.addArrayToList(cIBoundaries, statistics.getcIHillslope()); //for all parameters except EC50 (is handled separately for scientific notation purposes) for (int row = 0; row < parameters.size(); row++) { //parameter name in 1st column PdfUtils.addCustomizedCell(dataTable, parameters.get(row), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(bestFitValues.get(row)).toString(), bodyFont); if (standardErrors.get(row) == 0.0) { PdfUtils.addCustomizedCell(dataTable, "--", bodyFont); PdfUtils.addCustomizedCell(dataTable, "--", bodyFont); } else { PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(standardErrors.get(row)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(cIBoundaries.get(row * 2)) + " to " + AnalysisUtils.roundThreeDecimals(cIBoundaries.get((row * 2) + 1)), bodyFont); } } //add EC50 information PdfUtils.addCustomizedCell(dataTable, "EC50", bodyFont); PdfUtils.addCustomizedCell(dataTable, df.format(statistics.getEc50()), bodyFont); PdfUtils.addCustomizedCell(dataTable, "--", bodyFont); PdfUtils.addCustomizedCell(dataTable, df.format(statistics.getcIEC50()[0]) + " to " + df.format(statistics.getcIEC50()[1]), bodyFont); return dataTable; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDRResultsController.java
@Override protected PdfPTable createAnalysisGroupInfoTable() { //maps log transformed conc (double) to list of velocities (double) List<DoseResponsePair> data = doseResponseController.getImportedDRDataHolder().getDoseResponseData(); // new table with 5 columns PdfPTable dataTable = new PdfPTable(5); PdfUtils.setUpPdfPTable(dataTable);//from w ww .j a v a 2 s. c o m // add 1st row: column names PdfUtils.addCustomizedCell(dataTable, "DOSE", boldFont); PdfUtils.addCustomizedCell(dataTable, "# TECHNICAL REPLICATES", boldFont); PdfUtils.addCustomizedCell(dataTable, "LOWEST RESPONSE", boldFont); PdfUtils.addCustomizedCell(dataTable, "HIGHEST RESPONSE", boldFont); PdfUtils.addCustomizedCell(dataTable, "MEDIAN RESPONSE", boldFont); // for each condition get results and add a cell for (DoseResponsePair condition : data) { Integer replicates = condition.getResponses().size(); List<Double> velocities = condition.getResponses(); PdfUtils.addCustomizedCell(dataTable, condition.getDose().toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, replicates.toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(Collections.min(velocities)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(Collections.max(velocities)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(AnalysisUtils.computeMedian(velocities)).toString(), bodyFont); } return dataTable; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDRResultsController.java
@Override protected PdfPTable createFittingInfoTable(boolean normalized) { // 4 columns//from ww w . j a v a2s . c o m PdfPTable dataTable = new PdfPTable(4); PdfUtils.setUpPdfPTable(dataTable); DecimalFormat df = new DecimalFormat("0.00E00"); DoseResponseStatisticsHolder statistics = doseResponseController.getdRAnalysisGroup() .getDoseResponseAnalysisResults().getStatistics(normalized); // add 1st row: column names PdfUtils.addCustomizedCell(dataTable, "Parameter", boldFont); PdfUtils.addCustomizedCell(dataTable, "Best-fit value", boldFont); PdfUtils.addCustomizedCell(dataTable, "Standard Error", boldFont); PdfUtils.addCustomizedCell(dataTable, "95% Confidende Interval", boldFont); //parameter names List<String> parameters = new ArrayList<>(); parameters.add("Bottom"); parameters.add("Top"); if (doseResponseController.getLogTransform()) { parameters.add("LogEC50"); } else { parameters.add("EC50"); } parameters.add("Hillslope"); //best-fit values List<Double> bestFitValues = new ArrayList<>(); bestFitValues.add(doseResponseController.getdRAnalysisGroup().getDoseResponseAnalysisResults() .getFittingResults(normalized).getBottom()); bestFitValues.add(doseResponseController.getdRAnalysisGroup().getDoseResponseAnalysisResults() .getFittingResults(normalized).getTop()); bestFitValues.add(doseResponseController.getdRAnalysisGroup().getDoseResponseAnalysisResults() .getFittingResults(normalized).getLogEC50()); bestFitValues.add(doseResponseController.getdRAnalysisGroup().getDoseResponseAnalysisResults() .getFittingResults(normalized).getHillslope()); //standard errors List<Double> standardErrors = new ArrayList<>(); standardErrors.add(statistics.getStdErrBottom()); standardErrors.add(statistics.getStdErrTop()); standardErrors.add(statistics.getStdErrLogEC50()); standardErrors.add(statistics.getStdErrHillslope()); //ec50 does not have a SE, will need to be displayed differently standardErrors.add(Double.NaN); //confidence interval boundaries List<Double> cIBoundaries = new ArrayList<>(); cIBoundaries = AnalysisUtils.addArrayToList(cIBoundaries, statistics.getcIBottom()); cIBoundaries = AnalysisUtils.addArrayToList(cIBoundaries, statistics.getcITop()); cIBoundaries = AnalysisUtils.addArrayToList(cIBoundaries, statistics.getcILogEC50()); cIBoundaries = AnalysisUtils.addArrayToList(cIBoundaries, statistics.getcIHillslope()); //for all parameters except EC50 (is handled separately for scientific notation purposes) for (int row = 0; row < parameters.size(); row++) { //parameter name in 1st column PdfUtils.addCustomizedCell(dataTable, parameters.get(row), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(bestFitValues.get(row)).toString(), bodyFont); if (standardErrors.get(row) == 0.0 || Double.isNaN(standardErrors.get(row))) { PdfUtils.addCustomizedCell(dataTable, "--", bodyFont); PdfUtils.addCustomizedCell(dataTable, "--", bodyFont); } else { PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(standardErrors.get(row)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(cIBoundaries.get(row * 2)) + " to " + AnalysisUtils.roundThreeDecimals(cIBoundaries.get((row * 2) + 1)), bodyFont); } } //add EC50 information if (doseResponseController.getLogTransform()) { PdfUtils.addCustomizedCell(dataTable, "EC50", bodyFont); PdfUtils.addCustomizedCell(dataTable, df.format(statistics.getEc50()), bodyFont); PdfUtils.addCustomizedCell(dataTable, "--", bodyFont); PdfUtils.addCustomizedCell(dataTable, df.format(statistics.getcIEC50()[0]) + " to " + df.format(statistics.getcIEC50()[1]), bodyFont); } return dataTable; }