List of usage examples for com.lowagie.text Element ALIGN_LEFT
int ALIGN_LEFT
To view the source code for com.lowagie.text Element ALIGN_LEFT.
Click Source Link
From source file:ispyb.client.mx.collection.PdfRtfExporter.java
License:Open Source License
/** * returns a simple cell witha given value inside * /*from www . ja v a 2s . c om*/ * @param value * @return */ private Cell getCellValue(String value) { Cell cell = new Cell(); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.add(new Paragraph(value, FONT_DOC_BOLD)); cell.setColspan(1); return cell; }
From source file:ispyb.client.mx.collection.PdfRtfExporter.java
License:Open Source License
/** * set a line for a specified dataCollection in the dataCollection table * // w ww .j a va 2s .c om * @param document * @param table * @param col * @param session * @param df2 * @param df3 * @throws Exception */ private void setDataCollectionData2(Document document, Table table, DataCollection3VO col, Session3Service sessionService, AutoProc3VO autoProcValue, AutoProcScalingStatistics3VO autoProcOverall, AutoProcScalingStatistics3VO autoProcInner, AutoProcScalingStatistics3VO autoProcOuter, boolean withAutoProcessing, boolean setEDNAInfo, ScreeningOutput3VO screeningOutput, ScreeningOutputLattice3VO screeningOutputLattice, String nbImage) throws Exception { // Session3VO slv = sessionService.findByPk(col.getSessionId(), false, // false, false); DataCollectionGroup3VO dcGroup = col.getDataCollectionGroupVO(); Session3VO slv = dcGroup.getSessionVO(); // here slv is not null if (col.getNumberOfImages() != null) { if (!DataCollectionExporter.isDataCollectionScreening(col)) { table.getDefaultCell().setGrayFill(GREY_FILL_DATA_COLLECT); } else table.getDefaultCell().setGrayFill(GREY_FILL_DATA); } if (col.getImagePrefix() != null) table.addCell(new Paragraph(col.getImagePrefix(), FONT_DOC)); else table.addCell(""); // The beamline name is only displayed for select by protein or by // sample name if (name != null) { if (slv.getBeamlineName() != null) table.addCell(new Paragraph(slv.getBeamlineName(), FONT_DOC)); else table.addCell(""); } if (col.getDataCollectionNumber() != null) table.addCell(new Paragraph(col.getDataCollectionNumber().toString(), FONT_DOC)); else table.addCell(""); if (nbImage != null) table.addCell(new Paragraph(nbImage, FONT_DOC)); else table.addCell(""); if (withAutoProcessing) { // space group if (autoProcValue != null && autoProcValue.getSpaceGroup() != null) { Paragraph p = new Paragraph(autoProcValue.getSpaceGroup(), FONT_DOC); table.addCell(p); } else if (setEDNAInfo && screeningOutputLattice != null && screeningOutputLattice.getSpaceGroup() != null) { Paragraph p = new Paragraph(screeningOutputLattice.getSpaceGroup(), FONT_DOC); table.addCell(p); } else table.addCell(""); // unit cell if (autoProcValue != null && autoProcValue.getSpaceGroup() != null) table.addCell(new Paragraph(autoProcValue.getRefinedCellA() + " (" + autoProcValue.getRefinedCellAlpha() + ")\n" + autoProcValue.getRefinedCellB() + " (" + autoProcValue.getRefinedCellBeta() + ")\n" + autoProcValue.getRefinedCellC() + " (" + autoProcValue.getRefinedCellGamma() + ")", FONT_DOC)); else if (setEDNAInfo && screeningOutputLattice != null && screeningOutputLattice.getUnitCell_a() != null && screeningOutputLattice.getUnitCell_b() != null && screeningOutputLattice.getUnitCell_c() != null && screeningOutputLattice.getUnitCell_alpha() != null && screeningOutputLattice.getUnitCell_beta() != null && screeningOutputLattice.getUnitCell_gamma() != null) { Paragraph p = new Paragraph(df3.format(screeningOutputLattice.getUnitCell_a()) + " (" + df3.format(screeningOutputLattice.getUnitCell_alpha()) + ")\n" + df3.format(screeningOutputLattice.getUnitCell_b()) + " (" + df3.format(screeningOutputLattice.getUnitCell_beta()) + ")\n" + df3.format(screeningOutputLattice.getUnitCell_c()) + " (" + df3.format(screeningOutputLattice.getUnitCell_gamma()) + ")", FONT_DOC); table.addCell(p); } else table.addCell(""); // completeness, rsymm, processed resolution String completenessString = new String(); String rSymmString = new String(); String resolutionString = new String(); if (autoProcOverall != null && autoProcInner != null && autoProcOuter != null) { completenessString += df2.format(autoProcInner.getCompleteness()) + "\n" + df2.format(autoProcOuter.getCompleteness()) + "\n" + df2.format(autoProcOverall.getCompleteness()); rSymmString += (autoProcInner.getRmerge() == null ? "" : df2.format(autoProcInner.getRmerge())) + "\n" + (autoProcOuter.getRmerge() == null ? "" : df2.format(autoProcOuter.getRmerge())) + "\n" + (autoProcOverall.getRmerge() == null ? "" : df2.format(autoProcOverall.getRmerge())); resolutionString += autoProcInner.getResolutionLimitLow() + " - " + autoProcInner.getResolutionLimitHigh() + "\n" + autoProcOuter.getResolutionLimitLow() + " - " + autoProcOuter.getResolutionLimitHigh() + "\n" + autoProcOverall.getResolutionLimitLow() + " - " + autoProcOverall.getResolutionLimitHigh(); } else if (setEDNAInfo && screeningOutput != null && screeningOutput.getRankingResolution() != null) { resolutionString = df2.format(screeningOutput.getRankingResolution()); } table.addCell(new Paragraph(completenessString, FONT_DOC)); table.addCell(new Paragraph(rSymmString, FONT_DOC)); table.addCell(new Paragraph(resolutionString, FONT_DOC)); } // detector resolution if (col.getResolution() != null) table.addCell(new Paragraph(df2.format(col.getResolution()), FONT_DOC)); else table.addCell(""); // wavelength if (col.getWavelength() != null) table.addCell(new Paragraph(df3.format(col.getWavelength()), FONT_DOC)); else table.addCell(""); // phi range if (col.getAxisRange() != null) table.addCell(new Paragraph(df2.format(col.getAxisRange()), FONT_DOC)); else table.addCell(""); // Column crystalClass only for IFX proposal in case of MXPress // experiment if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) { // if (col.getCrystalClass() != null && col.getCrystalClass() != "") // table.addCell(new // Paragraph(col.getCrystalClass(), new Font(Font.HELVETICA, 8))); // else table.addCell(""); DataCollectionGroup3Service dataCollectionGroupService = (DataCollectionGroup3Service) ejb3ServiceLocator .getLocalService(DataCollectionGroup3Service.class); DataCollectionGroup3VO group = dataCollectionGroupService.findByPk(col.getDataCollectionGroupVOId(), true, true); boolean firstCollect = group.isFirstCollect(col); if (dcGroup.getCrystalClass() != null) { int idCC = getCrystalClassIndex(listOfCrystalClass, dcGroup.getCrystalClass().trim().toUpperCase()); String crystalS = ""; if (idCC == -1) { crystalS = dcGroup.getCrystalClass().toString(); } else { crystalS = listOfCrystalClass.get(idCC).getCrystalClassName(); } String crystalCell = crystalS; if (!firstCollect && crystalS != null && !crystalS.equals("")) { crystalCell = "(" + crystalS + ")"; } table.addCell(new Paragraph(crystalCell, FONT_DOC)); } else table.addCell(""); } table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); if (col.getComments() != null && col.getComments() != "") table.addCell(new Paragraph(col.getComments(), FONT_DOC)); else table.addCell(""); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); }
From source file:ispyb.client.mx.results.ExportAutoProcAction.java
License:Open Source License
private void setAutoProcInfo(Document document) throws Exception { // header//from w w w .j a va2 s .c o m Table headerTable = new Table(1); headerTable.getDefaultCell().setBorderWidth(0); headerTable.setBorderWidth(0); headerTable.setCellsFitPage(true); headerTable.setAlignment(Element.ALIGN_LEFT); headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); headerTable.getDefaultCell().setBackgroundColor(PdfRtfExporter.LIGHT_YELLOW_COLOR); headerTable.getDefaultCell().setLeading(3); headerTable.setWidth(100); // percentage headerTable .addCell(new Paragraph("Crystal data and data-collection statistics", PdfRtfExporter.FONT_DOC_11)); headerTable.addCell(new Paragraph("Values in parentheses are for the highest resolution shell.", PdfRtfExporter.FONT_DOC_11)); document.add(headerTable); document.add(new Paragraph(" ", PdfRtfExporter.VERY_SMALL_FONT)); // auto proc table Table autoProcTable = new Table(2); autoProcTable.getDefaultCell().setBorderWidth(0); autoProcTable.setBorderWidth(0); autoProcTable.setCellsFitPage(true); autoProcTable.setAlignment(Element.ALIGN_LEFT); autoProcTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // autoProcTable.getDefaultCell().setLeading(3); autoProcTable.setPadding(2); autoProcTable.setWidth(100); // percentage // data String spaceGroup = autoProc == null ? "" : autoProc.getSpaceGroup(); String unitCell_a = autoProc == null ? "" : autoProc.getRefinedCellA().toString(); String unitCell_b = autoProc == null ? "" : autoProc.getRefinedCellB().toString(); String unitCell_c = autoProc == null ? "" : autoProc.getRefinedCellC().toString(); String unitCell_alpha = autoProc == null ? "" : autoProc.getRefinedCellAlpha().toString(); String unitCell_beta = autoProc == null ? "" : autoProc.getRefinedCellBeta().toString(); String unitCell_gamma = autoProc == null ? "" : autoProc.getRefinedCellGamma().toString(); String resolutionRange = ""; String nTotalObservations = ""; String nTotalUniqueReflections = ""; String completeness = ""; String multiplicity = ""; String isigma = ""; String rmerge = ""; if (autoProcStatisticsOverall != null) { resolutionRange = autoProcStatisticsOverall.getResolutionLimitLow() + " - " + autoProcStatisticsOverall.getResolutionLimitHigh(); nTotalObservations = "" + autoProcStatisticsOverall.getnTotalObservations(); nTotalUniqueReflections = "" + (autoProcStatisticsOverall.getnTotalUniqueObservations() == null ? "" : autoProcStatisticsOverall.getnTotalUniqueObservations()); completeness = "" + autoProcStatisticsOverall.getCompleteness(); multiplicity = "" + autoProcStatisticsOverall.getMultiplicity(); isigma = "" + autoProcStatisticsOverall.getMeanIoverSigI(); rmerge = "" + (autoProcStatisticsOverall.getRmerge() == null ? "" : autoProcStatisticsOverall.getRmerge()); } if (autoProcStatisticsOuter != null) { resolutionRange += " (" + autoProcStatisticsOuter.getResolutionLimitLow() + " - " + autoProcStatisticsOuter.getResolutionLimitHigh() + ")"; nTotalObservations += " (" + autoProcStatisticsOuter.getnTotalObservations() + ")"; nTotalUniqueReflections += autoProcStatisticsOuter.getnTotalUniqueObservations() == null ? "" : (" (" + autoProcStatisticsOuter.getnTotalUniqueObservations() + ")"); completeness += " (" + autoProcStatisticsOuter.getCompleteness() + ")"; multiplicity += " (" + autoProcStatisticsOuter.getMultiplicity() + ")"; isigma += " (" + autoProcStatisticsOuter.getMeanIoverSigI() + ")"; rmerge += " (" + (autoProcStatisticsOuter.getRmerge() == null ? "" : autoProcStatisticsOuter.getRmerge()) + ")"; } // space group autoProcTable.addCell(new Paragraph("Space Group", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(spaceGroup, PdfRtfExporter.FONT_DOC_11)); // unit cell parameters autoProcTable.addCell( new Paragraph("Unit-cell parameters (" + Constants.ANGSTROM + ")", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph("", PdfRtfExporter.FONT_DOC_11)); Paragraph pa = new Paragraph("\t a", PdfRtfExporter.FONT_DOC_11); pa.setAlignment(Element.ALIGN_JUSTIFIED); pa.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pa); autoProcTable.addCell(new Paragraph(unitCell_a, PdfRtfExporter.FONT_DOC_11)); Paragraph pb = new Paragraph("\t b", PdfRtfExporter.FONT_DOC_11); pb.setAlignment(Element.ALIGN_JUSTIFIED); pb.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pb); autoProcTable.addCell(new Paragraph(unitCell_b, PdfRtfExporter.FONT_DOC_11)); Paragraph pc = new Paragraph("\t c", PdfRtfExporter.FONT_DOC_11); pc.setAlignment(Element.ALIGN_JUSTIFIED); pc.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pc); autoProcTable.addCell(new Paragraph(unitCell_c, PdfRtfExporter.FONT_DOC_11)); // Issue 1733: cell angles info added Paragraph palpha = new Paragraph("\t alpha", PdfRtfExporter.FONT_DOC_11); palpha.setAlignment(Element.ALIGN_JUSTIFIED); palpha.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(palpha); autoProcTable.addCell(new Paragraph(unitCell_alpha, PdfRtfExporter.FONT_DOC_11)); Paragraph pbeta = new Paragraph("\t beta", PdfRtfExporter.FONT_DOC_11); pbeta.setAlignment(Element.ALIGN_JUSTIFIED); pbeta.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pbeta); autoProcTable.addCell(new Paragraph(unitCell_beta, PdfRtfExporter.FONT_DOC_11)); Paragraph pgamma = new Paragraph("\t gamma", PdfRtfExporter.FONT_DOC_11); pgamma.setAlignment(Element.ALIGN_JUSTIFIED); pgamma.setIndentationLeft(PdfRtfExporter.INDENTATION_LEFT); autoProcTable.addCell(pgamma); autoProcTable.addCell(new Paragraph(unitCell_gamma, PdfRtfExporter.FONT_DOC_11)); // resolution range autoProcTable.addCell( new Paragraph("Resolution range (" + Constants.ANGSTROM + ")", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(resolutionRange, PdfRtfExporter.FONT_DOC_11)); // Observed reflections autoProcTable.addCell(new Paragraph("Observed reflections", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(nTotalObservations, PdfRtfExporter.FONT_DOC_11)); // No. of unique reflections autoProcTable.addCell(new Paragraph("No. of unique reflections", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(nTotalUniqueReflections, PdfRtfExporter.FONT_DOC_11)); // Completeness autoProcTable.addCell(new Paragraph("Completeness (%)", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(completeness, PdfRtfExporter.FONT_DOC_11)); // multiplicity autoProcTable.addCell(new Paragraph("Multiplicity", PdfRtfExporter.FONT_DOC_11)); autoProcTable.addCell(new Paragraph(multiplicity, PdfRtfExporter.FONT_DOC_11)); new Phrase(); // I/(I) Phrase p = Phrase.getInstance("<I/" + (char) 963 + "(I)>"); p.setFont(PdfRtfExporter.FONT_DOC_11); autoProcTable.addCell(p); autoProcTable.addCell(new Paragraph(isigma, PdfRtfExporter.FONT_DOC_11)); // Rmerge Chunk c1 = new Chunk("R", PdfRtfExporter.FONT_DOC_11); Chunk c2 = new Chunk("merge", PdfRtfExporter.FONT_DOC_EXPONENT); c2.setTextRise(PdfRtfExporter.TEXT_RISE_SUB); Chunk c3 = new Chunk("(%)", PdfRtfExporter.FONT_DOC_11); Chunk c4 = new Chunk("#", PdfRtfExporter.FONT_DOC_EXPONENT_BLUE); c4.setTextRise(PdfRtfExporter.TEXT_RISE_EXP); Paragraph rMergeParagraph = new Paragraph(); rMergeParagraph.add(c1); rMergeParagraph.add(c2); rMergeParagraph.add(c3); rMergeParagraph.add(c4); autoProcTable.addCell(rMergeParagraph); autoProcTable.addCell(new Paragraph(rmerge, PdfRtfExporter.FONT_DOC_11)); document.add(autoProcTable); document.add(new Paragraph(" ", PdfRtfExporter.FONT_DOC_11)); // nota bene info Paragraph nbParagraph = new Paragraph(); nbParagraph.add(c4); nbParagraph.add(c1); nbParagraph.add(c2); Chunk cesp = new Chunk(" ", PdfRtfExporter.FONT_DOC_11); Chunk c5 = new Chunk(" = ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c5); Phrase pSigma = Phrase.getInstance("" + (char) 931); pSigma.setFont(PdfRtfExporter.FONT_DOC_11); nbParagraph.add(pSigma); Chunk chkl = new Chunk("hkl", PdfRtfExporter.FONT_DOC_EXPONENT); chkl.setTextRise(PdfRtfExporter.TEXT_RISE_SUB); nbParagraph.add(chkl); nbParagraph.add(cesp); nbParagraph.add(pSigma); Chunk ci = new Chunk("i", PdfRtfExporter.FONT_DOC_EXPONENT); ci.setTextRise(PdfRtfExporter.TEXT_RISE_SUB); nbParagraph.add(ci); Chunk c8 = new Chunk(" |I", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c8); nbParagraph.add(ci); Chunk c9 = new Chunk("(hkl) - (I(hkl))| / ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c9); nbParagraph.add(pSigma); nbParagraph.add(chkl); nbParagraph.add(cesp); nbParagraph.add(pSigma); nbParagraph.add(ci); nbParagraph.add(cesp); Chunk c10 = new Chunk("I", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c10); nbParagraph.add(ci); Chunk c11 = new Chunk("(hkl), where ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c11); Chunk c12 = new Chunk("I", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(c12); Chunk cii = new Chunk("i", PdfRtfExporter.FONT_DOC_EXPONENT_ITALIC); cii.setTextRise(PdfRtfExporter.TEXT_RISE_SUB); nbParagraph.add(cii); Chunk c13 = new Chunk("(hkl)", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(c13); Chunk c14 = new Chunk(" is the ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c14); Chunk c15 = new Chunk("i", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(c15); Chunk c16 = new Chunk("th observation of reflection ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c16); Chunk chklI = new Chunk("hkl", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(chklI); Chunk c17 = new Chunk(" and ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c17); Chunk c18 = new Chunk("<I(hkl)> ", PdfRtfExporter.FONT_DOC_11_ITALIC); nbParagraph.add(c18); Chunk c19 = new Chunk(" is the weighted average intensity for all observations of reflection ", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c19); nbParagraph.add(chklI); Chunk c20 = new Chunk(".", PdfRtfExporter.FONT_DOC_11); nbParagraph.add(c20); document.add(nbParagraph); document.add(new Paragraph(" ", PdfRtfExporter.FONT_DOC_11)); }
From source file:ispyb.common.util.export.ExiPdfRtfExporter.java
License:Open Source License
/*** * sets the sessions informations in the pdf document for fx or ix accounts * (Issue 1049)/*from w ww.j ava 2s .c o m*/ * * @param document * @throws Exception */ private void setSessionTable(Document document) throws Exception { String proposalCode = proposalDesc.substring(0, 2); if (slv != null && (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX) || proposalCode.equals(Constants.PROPOSAL_CODE_IX))) { if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) { // session // title // only // for // FX // accounts document.add(new Paragraph("Session title:", FONT_TITLE)); document.add(new Paragraph(slv.getSessionTitle(), FONT_DOC)); } Table sessionTable = new Table(2); // sessionTable.setWidth(50); // percentage sessionTable.setPadding(3); sessionTable.setCellsFitPage(true); sessionTable.getDefaultCell().setBorderWidth(0); sessionTable.setBorder(0); sessionTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); boolean hasData = false; // print only if the value > 0 if (proposalCode.toLowerCase().equals(Constants.PROPOSAL_CODE_FX)) { // structure // determinations // only // for // FX // accounts if (slv.getStructureDeterminations() != null && !slv.getStructureDeterminations().isNaN() && slv.getStructureDeterminations() != 0) { hasData = true; sessionTable.addCell(new Paragraph("Structure determinations", FONT_DOC_BOLD)); sessionTable.addCell(new Paragraph("" + slv.getStructureDeterminations(), FONT_DOC)); } } if (slv.getDewarTransport() != null && !slv.getDewarTransport().isNaN() && slv.getDewarTransport() != 0) { hasData = true; sessionTable.addCell(new Paragraph("Dewar transport", FONT_DOC_BOLD)); sessionTable.addCell(new Paragraph("" + slv.getDewarTransport(), FONT_DOC)); } if (slv.getDatabackupFrance() != null && !slv.getDatabackupFrance().isNaN() && slv.getDatabackupFrance() != 0) { hasData = true; sessionTable.addCell(new Paragraph("Data backup & Express delivery France", FONT_DOC_BOLD)); sessionTable.addCell(new Paragraph("" + slv.getDatabackupFrance(), FONT_DOC)); } if (slv.getDatabackupEurope() != null && !slv.getDatabackupEurope().isNaN() && slv.getDatabackupEurope() != 0) { hasData = true; sessionTable.addCell(new Paragraph("Data backup & Express delivery Europe", FONT_DOC_BOLD)); sessionTable.addCell(new Paragraph("" + slv.getDatabackupEurope(), FONT_DOC)); } if (hasData) { document.add(sessionTable); } } }
From source file:ispyb.common.util.export.ExiPdfRtfExporter.java
License:Open Source License
/** * set a line for a specified dataCollection in the dataCollection table * /*from w w w . j a v a2 s . c om*/ * @param document * @param table * @param col * @param session * @param df2 * @param df3 * @throws Exception */ private void setDataCollectionMapData(Document document, Map<String, Object> dataCollectionMapItem) throws Exception { // 1st row String parag = getCellParam(dataCollectionMapItem, "DataCollectionGroup_experimentType") + " " + getCellParam(dataCollectionMapItem, "DataCollection_startTime"); Paragraph p = new Paragraph(parag, FONT_DOC_BLUE); document.add(p); //row2 parag = getCellParam(dataCollectionMapItem, "DataCollection_imageDirectory"); document.add(new Paragraph(parag, FONT_DOC_ITALIC)); //row3 Table table = new Table(NB_COL_DATACOLLECTION); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setBorderWidth(0); // 1st Cell parag = "Workflow: \n" + "Protein: \n" + "Sample: \n" + "Prefix: \n" + "Run #: \n" + "Images: \n" + "Transmission: \n"; LOG.info("parag=" + parag); p = new Paragraph(parag, FONT_DOC); table.addCell(p); // Cell2 parag = getCellParam(dataCollectionMapItem, "Workflow_workflowType") + "\n" + getCellParam(dataCollectionMapItem, "Protein_acronym") + "\n" + getCellParam(dataCollectionMapItem, "BLSample_name") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_imagePrefix") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_dataCollectionNumber") + "\n" + getCellParam(dataCollectionMapItem, "Protein_acronym") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_transmission") + "\n"; LOG.info("parag=" + parag); p = new Paragraph(parag, FONT_DOC_BOLD); table.addCell(p); // 3 Cell parag = "Resolution (corner): \n" + "Wavelength: \n" + "Omega range: \n" + "Omega start: \n" + "Exposure time: \n" + "Flux start: \n" + "Flux end: \n"; table.addCell(new Paragraph(parag, FONT_DOC)); // Cell 4 parag = getCellParam(dataCollectionMapItem, "DataCollection_resolutionAtCorner") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_wavelength") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_axisRange") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_omegaStart") + "\n" + getCellParam(dataCollectionMapItem, "exposureTime") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_flux") + "\n" + getCellParam(dataCollectionMapItem, "DataCollection_flux_end") + "\n"; table.addCell(new Paragraph(parag, FONT_DOC_BOLD)); // 5 Cell add cell containing autoproc results table.addCell(" "); // 6 Cell : thumbnail if (!getCellParam(dataCollectionMapItem, "lastImageId").isEmpty()) { String thumbnailPath = (imageService .findByPk(new Integer(getCellParam(dataCollectionMapItem, "lastImageId")))) .getJpegThumbnailFileFullPath(); Cell cellThumbnail = getCellImage(thumbnailPath); cellThumbnail.setBorderWidth(0); table.addCell(cellThumbnail); } else { table.addCell(" "); } //cellThumbnail.setRowspan(nbRows); // 7 Cell : snapshot Cell cellSnapshot = getCellImage(dataCollectionMapItem, "DataCollection_xtalSnapshotFullPath1"); //cellSnapshot.setRowspan(nbRows); cellSnapshot.setBorderWidth(0); table.addCell(cellSnapshot); // 8 Cell : graph or other plot if (!getCellParam(dataCollectionMapItem, "DataCollection_dataCollectionId").isEmpty()) { String plotPath = (dcService.findByPk( new Integer(getCellParam(dataCollectionMapItem, "DataCollection_dataCollectionId")), false, false)).getImageQualityIndicatorsPlotPath(); Cell cellGraph = getCellImage(plotPath); cellGraph.setBorderWidth(0); table.addCell(cellGraph); } else { table.addCell(" "); } document.add(table); // row3 if (dataCollectionMapItem.get("DataCollection_comments") != null && dataCollectionMapItem.get("DataCollection_comments") != "") document.add(new Paragraph(dataCollectionMapItem.get("DataCollection_comments").toString(), FONT_DOC)); else document.add(new Paragraph(" ")); return; }
From source file:jdbreport.model.io.pdf.itext2.ITextWriter.java
License:Apache License
protected int toPdfHAlignment(int horizontalAlignment) { switch (horizontalAlignment) { case CellStyle.LEFT: return Element.ALIGN_LEFT; case CellStyle.RIGHT: return Element.ALIGN_RIGHT; case CellStyle.CENTER: return Element.ALIGN_CENTER; case CellStyle.JUSTIFY: return Element.ALIGN_JUSTIFIED; }//from ww w . j av a 2 s . c om return Element.ALIGN_LEFT; }
From source file:jm.fac.pdf.pdfArqueoCaja.java
License:GNU General Public License
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request// www .ja v a2 s . c o m * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession sesion = request.getSession(true); String usuario = (String) sesion.getAttribute("usuario"); String clave = (String) sesion.getAttribute("clave"); response.setContentType("application/pdf"); response.setHeader("Pragma", "no-cache"); response.setHeader("Expires", "Mon, 01 Jan 2001 00:00:01 GMT"); response.setHeader("Cache-Control", "no-store"); response.setHeader("Cache-Control", "must-revalidate"); response.setHeader("Cache-Control", "no-cache"); //PrintWriter out = response.getWriter(); Configuracion conf = new Configuracion(this._ip, this._puerto, this._db, usuario, clave); String titulo = conf.getValor("razon_social"); conf.cerrar(); String path = String.valueOf(request.getRequestURL()); path = path.substring(0, path.lastIndexOf("/")); /*Archivo archivo = new Archivo(this._ip, this._puerto, this._db, usuario, clave); String logo = path + "/img/" + archivo.getArchivo(this._dir, 1); archivo.cerrar();*/ ArqueoCaja objArqueoCaja = new ArqueoCaja(this._ip, this._puerto, this._db, usuario, clave); Empleado objEmpleado = new Empleado(this._ip, this._puerto, this._db, usuario, clave); String id = request.getParameter("id"); //int i=0; String num_documento = "0"; String fecha = Fecha.getFecha("SQL"); String hora = Fecha.getHora(); String cajero = ""; String saldo_caja = "0"; String num_cheques = "0"; String valor_cheques = "0"; String num_comp_pagos = "0"; String valor_comp_pagos = "0"; String num_retenciones = "0"; String valor_retenciones = "0"; String valor_efectivo = "0"; String total_caja = "0"; String diferencia = "0"; String tipo_diferencia = "0"; //boolean anulado = false; if (id.compareTo("-1") != 0) { try { ResultSet rsArqueoCaja = objArqueoCaja.getArqueoCaja(id); if (rsArqueoCaja.next()) { num_documento = (rsArqueoCaja.getString("num_documento") != null) ? rsArqueoCaja.getString("num_documento") : "0"; fecha = (rsArqueoCaja.getString("fecha") != null) ? rsArqueoCaja.getString("fecha") : ""; hora = (rsArqueoCaja.getString("Hora") != null) ? rsArqueoCaja.getString("Hora") : ""; cajero = (rsArqueoCaja.getString("cajero") != null) ? rsArqueoCaja.getString("cajero") : ""; saldo_caja = (rsArqueoCaja.getString("saldo_caja") != null) ? rsArqueoCaja.getString("saldo_caja") : ""; num_cheques = (rsArqueoCaja.getString("num_cheques") != null) ? rsArqueoCaja.getString("num_cheques") : "0.00"; valor_cheques = (rsArqueoCaja.getString("valor_cheques") != null) ? rsArqueoCaja.getString("valor_cheques") : "0.00"; num_comp_pagos = (rsArqueoCaja.getString("num_comp_pagos") != null) ? rsArqueoCaja.getString("num_comp_pagos") : "0.00"; valor_comp_pagos = (rsArqueoCaja.getString("valor_comp_pagos") != null) ? rsArqueoCaja.getString("valor_comp_pagos") : "0.00"; num_retenciones = (rsArqueoCaja.getString("num_retenciones") != null) ? rsArqueoCaja.getString("num_retenciones") : "0"; valor_retenciones = (rsArqueoCaja.getString("valor_retenciones") != null) ? rsArqueoCaja.getString("valor_retenciones") : "0.00"; valor_efectivo = (rsArqueoCaja.getString("valor_efectivo") != null) ? rsArqueoCaja.getString("valor_efectivo") : "0.00"; total_caja = (rsArqueoCaja.getString("total") != null) ? rsArqueoCaja.getString("total") : "0.00"; diferencia = (rsArqueoCaja.getString("diferencia") != null) ? rsArqueoCaja.getString("diferencia") : "0.00"; tipo_diferencia = (rsArqueoCaja.getString("tipo_diferencia") != null) ? rsArqueoCaja.getString("tipo_diferencia") : ""; //anulado = (rsArqueoCaja.getString("anulado")!=null) ? rsArqueoCaja.getBoolean("anulado") : false; rsArqueoCaja.close(); } } catch (Exception e) { e.printStackTrace(); } } String sucursal = ""; String empleado = ""; try { ResultSet rs = objEmpleado.getCajero(cajero); if (rs.next()) { sucursal = rs.getString("sucursal") != null ? rs.getString("sucursal") : ""; empleado = rs.getString("empleado") != null ? rs.getString("empleado") : ""; } } catch (Exception e) { e.printStackTrace(); } /* inicio PDF */ Document doc = new Document(PageSize.A4);// paso 1 /* tambien establesco el alto del tope para la primera impresion de la factura */ float ancho = PageSize.A4.getWidth(); float alto = PageSize.A4.getHeight(); try { PdfWriter writer = PdfWriter.getInstance(doc, response.getOutputStream()); // paso 2 doc.open(); // paso 3 // Para enviar a la impresora automticamente. writer.addJavaScript("this.print(false);", false); /* todo el cuerpo del doc es el paso 4 */ PdfPTable tbl_titulo = new PdfPTable(1); tbl_titulo .addCell(Addons.setCeldaPDF(titulo, Font.HELVETICA, 14, Font.NORMAL, Element.ALIGN_CENTER, 0)); tbl_titulo.addCell(Addons.setCeldaPDF("ARQUEO DE CAJA\n\n", Font.HELVETICA, 14, Font.BOLD, Element.ALIGN_CENTER, 0)); tbl_titulo.addCell(Addons.setCeldaPDF("No. " + num_documento + "\n", Font.HELVETICA, 12, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_titulo.addCell(Addons.setCeldaPDF("Sucursal: " + sucursal, Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_titulo.addCell(Addons.setCeldaPDF("Usuario de caja: " + cajero, Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_titulo.addCell(Addons.setCeldaPDF("Responsable de caja: " + empleado, Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 0)); doc.add(tbl_titulo); PdfPTable tbl_det = new PdfPTable(2); tbl_det.addCell( Addons.setCeldaPDF("Fecha: " + fecha, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell( Addons.setCeldaPDF("Hora: " + hora, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setFilaBlanco(3, 10)); doc.add(tbl_det); /* efectivo */ try { String denominacion = ""; String cantidad = ""; String total = ""; ResultSet rsArqueoEfectivo = objArqueoCaja.getArqueoCajaEfectivo(id); if (objArqueoCaja.getFilas(rsArqueoEfectivo) > 0) { doc.add(Addons.setCabeceraTabla(new String[] { "DENOMINACION", "CANTIDAD", "TOTAL ($)" }, new float[] { 60f, 20f, 20f })); PdfPTable tbl_efectivo = new PdfPTable(new float[] { 60f, 20f, 20f }); while (rsArqueoEfectivo.next()) { denominacion = (rsArqueoEfectivo.getString("denominacion") != null) ? rsArqueoEfectivo.getString("denominacion") : ""; cantidad = (rsArqueoEfectivo.getString("cantidad") != null) ? rsArqueoEfectivo.getString("cantidad") : ""; total = (rsArqueoEfectivo.getString("total") != null) ? rsArqueoEfectivo.getString("total") : ""; tbl_efectivo.addCell(Addons.setCeldaPDF(denominacion, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_efectivo.addCell(Addons.setCeldaPDF(cantidad, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); tbl_efectivo.addCell( Addons.setCeldaPDF(total, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); } tbl_efectivo.addCell(Addons.setFilaBlanco(3, 10)); doc.add(tbl_efectivo); } rsArqueoEfectivo.close(); } catch (Exception e) { e.printStackTrace(); } /* cheque */ try { String efectivizado = ""; String banco = ""; String num_cheque = ""; String valor = ""; ResultSet rsArqueoCheque = objArqueoCaja.getArqueoCajaCheque(id); if (objArqueoCaja.getFilas(rsArqueoCheque) > 0) { doc.add(Addons.setCabeceraTabla( new String[] { "BANCO", "Nro. CHEQUE", "VALOR ($)", "EFECTIVIZADO" }, new float[] { 60f, 30f, 20f, 15f })); PdfPTable tbl_cheque = new PdfPTable(new float[] { 60f, 30f, 20f, 15f }); while (rsArqueoCheque.next()) { efectivizado = (rsArqueoCheque.getString("efectivizado") != null) ? rsArqueoCheque.getString("efectivizado") : ""; banco = (rsArqueoCheque.getString("banco") != null) ? rsArqueoCheque.getString("banco") : ""; num_cheque = (rsArqueoCheque.getString("num_cheque") != null) ? rsArqueoCheque.getString("num_cheque") : ""; valor = (rsArqueoCheque.getString("valor") != null) ? rsArqueoCheque.getString("valor") : ""; tbl_cheque.addCell( Addons.setCeldaPDF(banco, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_cheque.addCell(Addons.setCeldaPDF(num_cheque, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_cheque.addCell( Addons.setCeldaPDF(valor, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); tbl_cheque.addCell(Addons.setCeldaPDF(efectivizado, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); } tbl_cheque.addCell(Addons.setFilaBlanco(4, 10)); doc.add(tbl_cheque); } rsArqueoCheque.close(); } catch (Exception e) { e.printStackTrace(); } /* otros documentos */ try { String num_comp_pago = ""; String valor = ""; ResultSet rsArqueoDocs = objArqueoCaja.getArqueoCajaOtros(id); if (objArqueoCaja.getFilas(rsArqueoDocs) > 0) { doc.add(Addons.setCabeceraTabla(new String[] { "Nro. COMP. PAGO", "VALOR ($)" }, new float[] { 70f, 30f })); PdfPTable tbl_otros = new PdfPTable(new float[] { 70f, 30f }); while (rsArqueoDocs.next()) { num_comp_pago = (rsArqueoDocs.getString("num_comp_pago") != null) ? rsArqueoDocs.getString("num_comp_pago") : ""; valor = (rsArqueoDocs.getString("valor") != null) ? rsArqueoDocs.getString("valor") : "0"; tbl_otros.addCell(Addons.setCeldaPDF(num_comp_pago, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_otros.addCell( Addons.setCeldaPDF(valor, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); } tbl_otros.addCell(Addons.setFilaBlanco(3, 10)); doc.add(tbl_otros); } rsArqueoDocs.close(); } catch (Exception e) { e.printStackTrace(); } /* retenciones */ try { String num_retencion = ""; String valor_retencion = ""; ResultSet rsArqueoRets = objArqueoCaja.getArqueoCajaRetenciones(id); if (objArqueoCaja.getFilas(rsArqueoRets) > 0) { doc.add(Addons.setCabeceraTabla(new String[] { "Nro. RETENCION", "VALOR ($)" }, new float[] { 70f, 30f })); PdfPTable tbl_otros = new PdfPTable(new float[] { 70f, 30f }); while (rsArqueoRets.next()) { num_retencion = (rsArqueoRets.getString("num_retencion") != null) ? rsArqueoRets.getString("num_retencion") : ""; valor_retencion = (rsArqueoRets.getString("valor_retencion") != null) ? rsArqueoRets.getString("valor_retencion") : "0"; tbl_otros.addCell(Addons.setCeldaPDF(num_retencion, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_otros.addCell(Addons.setCeldaPDF(valor_retencion, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); } tbl_otros.addCell(Addons.setFilaBlanco(3, 10)); doc.add(tbl_otros); } rsArqueoRets.close(); } catch (Exception e) { e.printStackTrace(); } PdfPTable tbl_totales = new PdfPTable(new float[] { 60f, 40f }); tbl_totales.addCell(Addons.setFilaBlanco(3, 5)); tbl_totales.addCell(Addons.setCeldaPDF("Saldo en caja actual:", Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_totales.addCell( Addons.setCeldaPDF(saldo_caja, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); tbl_totales.addCell(Addons.setCeldaPDF("Total monedas y billetes:", Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_totales.addCell( Addons.setCeldaPDF(valor_efectivo, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); tbl_totales.addCell(Addons.setCeldaPDF("Total cheques (" + num_cheques + "):", Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_totales.addCell( Addons.setCeldaPDF(valor_cheques, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); tbl_totales.addCell(Addons.setCeldaPDF("Total comprobantes de pago (" + num_comp_pagos + "):", Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_totales.addCell( Addons.setCeldaPDF(valor_comp_pagos, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); tbl_totales.addCell(Addons.setCeldaPDF("Total retenciones (" + num_retenciones + "):", Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_totales.addCell( Addons.setCeldaPDF(valor_retenciones, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); tbl_totales.addCell( Addons.setCeldaPDF("Total en caja:", Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_totales.addCell( Addons.setCeldaPDF(total_caja, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); tbl_totales.addCell(Addons.setCeldaPDF( "Diferencia: " + (tipo_diferencia.compareTo("f") == 0 ? "faltante" : (tipo_diferencia.compareTo("s") == 0 ? "sobrante" : "")), Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_totales.addCell( Addons.setCeldaPDF(diferencia, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); doc.add(tbl_totales); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); PdfPTable tbl_firmas = new PdfPTable(3); tbl_firmas.addCell( Addons.setCeldaPDF("RESPONSABLE", Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_CENTER, 0)); tbl_firmas.addCell( Addons.setCeldaPDF("VERIFICADO", Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_CENTER, 0)); tbl_firmas.addCell( Addons.setCeldaPDF("AUTORIZADO", Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_CENTER, 0)); doc.add(tbl_firmas); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } finally { objEmpleado.cerrar(); objArqueoCaja.cerrar(); } doc.close(); // paso 5 /* fin PDF */ }
From source file:jm.nom.clas.Carnet.java
public void imprimir(HttpServletResponse response, ResultSet rsCarnets, String path) { response.setContentType("application/pdf"); response.setHeader("Pragma", "no-cache"); response.setHeader("Expires", "Mon, 01 Jan 2001 00:00:01 GMT"); response.setHeader("Cache-Control", "no-store"); response.setHeader("Cache-Control", "must-revalidate"); response.setHeader("Cache-Control", "no-cache"); /*try{/*from w w w .j a va 2 s . co m*/ rsCarnets = objEmpleado.getCarnets(id); if(rsCarnets.next()){ id_sucursal = ((rsCarnets.getString("id_sucursal")!=null) ? rsCarnets.getString("id_sucursal") : ""); id_instalacion = ((rsCarnets.getString("id_instalacion")!=null) ? rsCarnets.getString("id_instalacion") : ""); serie_factura = ((rsCarnets.getString("serie_factura")!=null) ? rsCarnets.getString("serie_factura") : ""); num_factura = ((rsCarnets.getString("num_factura")!=null) ? rsCarnets.getString("num_factura") : ""); razon_social = ((rsCarnets.getString("razon_social")!=null) ? rsCarnets.getString("razon_social") : "CONSUMIDOR FINAL"); fecha_emision = ((rsCarnets.getString("fecha_emision")!=null) ? Fecha.ISOaSQL(rsCarnets.getString("fecha_emision")) : ""); direccion = ((rsCarnets.getString("direccion")!=null) ? rsCarnets.getString("direccion") : ""); vendedor = ((rsCarnets.getString("vendedor")!=null) ? rsCarnets.getString("vendedor") : ""); total = ((rsCarnets.getString("total")!=null) ? rsCarnets.getString("total") : "0.00"); de_activo = ((rsCarnets.getString("de_activo")!=null) ? rsCarnets.getBoolean("de_activo") : false); rsCarnets.close(); } }catch(Exception ie){ ie.printStackTrace(); }*/ try { /* inicio PDF */ Document document = new Document(PageSize.A4.rotate());// paso 1 document.setMargins(-47, 0, 38, 0); /*Izquierda, derecha, tope, pie */ PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Carnet(this._dir)); document.open(); // paso 3 //writer.addJavaScript("this.print(false);", false); // Para enviar a la impresora automticamente. /* todo el cuerpo del doc es el paso 4 */ //PdfPTable tbl = new PdfPTable(new float[]{40f,60f}); PdfPTable tbl = new PdfPTable(4); int i = 0; try { //rsCarnets = objEmpleado.getCarnets(id); while (rsCarnets.next()) { PdfPTable tbl1 = new PdfPTable(1); PdfPTable tbl2 = new PdfPTable(new float[] { 90f, 5f, 5f }); String foto = ((rsCarnets.getString("padre_nombre") != null) ? rsCarnets.getString("padre_nombre") : ""); //_dir="C:\\Users\\SoulGael\\Documents\\NetBeansProjects\\trunk\\saitel\\build\\web\\img\\luis.jpg"; tbl1.addCell(Addons.setCeldaPDFBottom(" ", Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 0, 26, 0)); tbl1.addCell(Addons.setLogoCarnet(_dir + foto, 79, 103)); //tbl1.addCell(Addons.setLogoCarnet(_dir,79,103)); String nombre = ((rsCarnets.getString("nombre") != null) ? rsCarnets.getString("nombre") : ""); String apellidos = ((rsCarnets.getString("apellido") != null) ? rsCarnets.getString("apellido") : ""); String cargo = ((rsCarnets.getString("cargo") != null) ? rsCarnets.getString("cargo") : ""); ; String[] nombresArray = nombre.split(" "); String[] apellidosArray = apellidos.split(" "); String n_completos = nombresArray[0] + " " + apellidosArray[0]; String CI = ((rsCarnets.getString("dni") != null) ? rsCarnets.getString("dni") : ""); ; String sangre = ((rsCarnets.getString("tipo_sangre") != null) ? rsCarnets.getString("tipo_sangre") : ""); ; String carnet = ((rsCarnets.getString("carnet") != null) ? rsCarnets.getString("carnet") : ""); //String carnet="A,B,C,D,E,F,G"; Color A = Color.WHITE; Color B = Color.WHITE; Color C = Color.WHITE; Color D = Color.WHITE; Color E = Color.WHITE; Color F = Color.WHITE; Color G = Color.WHITE; String[] carnetArray = carnet.split(","); for (int j = 0; j < carnetArray.length; j++) { if (carnetArray[j].equals("A")) { A = Color.ORANGE; j++; if (j > carnetArray.length - 1) j = carnetArray.length - 1; } if (carnetArray[j].equals("B")) { B = Color.ORANGE; j++; if (j > carnetArray.length - 1) j = carnetArray.length - 1; } if (carnetArray[j].equals("C")) { C = Color.ORANGE; ; j++; if (j > carnetArray.length - 1) j = carnetArray.length - 1; } if (carnetArray[j].equals("D")) { D = Color.ORANGE; ; j++; if (j > carnetArray.length - 1) j = carnetArray.length - 1; } if (carnetArray[j].equals("E")) { E = Color.ORANGE; ; j++; if (j > carnetArray.length - 1) j = carnetArray.length - 1; } if (carnetArray[j].equals("F")) { F = Color.ORANGE; ; j++; if (j > carnetArray.length - 1) j = carnetArray.length - 1; } if (carnetArray[j].equals("G")) { G = Color.ORANGE; ; j++; if (j > carnetArray.length - 1) j = carnetArray.length - 1; } break; } tbl1.addCell(Addons.setCeldaPDFBottom(" ", Font.ITALIC, 7, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 0)); tbl1.addCell(Addons.setCeldaPDFBottom(n_completos, Font.ITALIC, 13, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 0)); tbl1.addCell(Addons.setCeldaPDFBottom(cargo, Font.ITALIC, 12, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 0)); tbl1.addCell(Addons.setCeldaPDFBottom(CI, Font.ITALIC, 12, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 0)); tbl1.addCell(Addons.setCeldaPDFBottom(sangre, Font.ITALIC, 12, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 0)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 7, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 7, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 7, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3)); tbl2.addCell(Addons.setCeldaPDFCarnet(" LICENCIA INTERNA DE ", Font.ITALIC, 9, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 3)); tbl2.addCell(Addons.setCeldaPDFCarnet(" PREVENCION DE RIESGOS", Font.ITALIC, 9, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 3)); tbl2.addCell(Addons.setCeldaPDFCarnet(" Con la induccin recibida y aprobada usted", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3)); tbl2.addCell(Addons.setCeldaPDFCarnet(" est autorizado para:", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3)); tbl2.addCell(Addons.setCeldaPDFCarnet(" a. Trabajo de Oficina.", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 1, 2, 0, A)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" b. Trabajo de Marketing y propaganda", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 1, 2, 0, B)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" c. Trabajo de mantenimiento y limpieza", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 1, 2, 0, C)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" d. Trabajo de instalaciones menores a los ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 2)); tbl2.addCell(Addons.setCeldaPDFCarnet(" ocho metros sobre el nivel.", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 0)); tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 1, 0, 0, D)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" (Domicilios, postes, cableado)", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0, 2, 2)); tbl2.addCell(Addons.setCeldaPDFCarnet(" e. Trabajo de instalaciones, antenas,", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 2)); tbl2.addCell(Addons.setCeldaPDFCarnet(" infraestructura mayores a los ocho", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 0)); tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 1, 0, 0, E)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" metros sobre el nivel", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0, 2, 2)); tbl2.addCell(Addons.setCeldaPDFCarnet(" f. Planes de emergencia y contingencia", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 1, 2, 0, F)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnet(" g. Planes de rescate", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 1, 2, 0, G)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3)); tbl2.addCell( Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 10, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3)); tbl2.addCell(Addons.setCeldaPDFCarnet("Ing. FREDDY ROSERO", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 3, Color.BLUE)); tbl2.addCell(Addons.setCeldaPDFCarnet("GERENTE", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 3, Color.BLUE)); tbl2.addCell(Addons.setCeldaPDFCarnet("Fecha de Expedicin: Mayo 2015", Font.ITALIC, 5, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 3, Color.BLUE)); tbl2.addCell(Addons.setCeldaPDFCarnet("Fecha de Caducidad: Mayo 2016", Font.ITALIC, 5, Font.BOLD, Element.ALIGN_CENTER, 0, 0, 3, Color.BLUE)); /* tbl1.addCell(Addons.setCeldaPDF(((rsCarnets.getString("nombres")!=null) ? rsCarnets.getString("nombres") : ""), Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl1.addCell(Addons.setCeldaPDF(((rsCarnets.getString("rol")!=null) ? rsCarnets.getString("rol") : ""), Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl1.addCell(Addons.setCeldaPDF(((rsCarnets.getString("dni")!=null) ? rsCarnets.getString("dni") : ""), Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl1.addCell(Addons.setCeldaPDF(((rsCarnets.getString("tipo_sangre")!=null) ? rsCarnets.getString("tipo_sangre") : ""), Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 1)); String idcarnet=(rsCarnets.getString("id_empleado")!=null) ? rsCarnets.getString("id_empleado") : "";*/ tbl.addCell(Addons.setCeldaPDF(tbl1, 0, 0)); tbl.addCell(Addons.setCeldaPDF(tbl2, 0, 0)); if (i % 2 != 0) { tbl1.addCell( Addons.setCeldaPDF(" ", Font.ITALIC, 10, Font.BOLD, Element.ALIGN_LEFT, 0, 16, 3)); } i++; } if (i % 2 != 0) { tbl.addCell(" "); tbl.addCell(" "); } /*Archivo archivo = new Archivo(_ip, _puerto, _db, _usuario, _clave); //path = path.substring(0, path.lastIndexOf("/")); String carnet = path + "/img/" + archivo.getArchivo(_dir, "vta_empleado", idcarnet, "padre_nombre", "foto"); archivo.cerrar(); Image imagen = null; try{ imagen = Image.getInstance(carnet); imagen.scaleAbsolute(50, 70); PdfPCell celdaImg = new PdfPCell(imagen); celdaImg.setBorderWidth(0); celdaImg.setPadding(0); tbl.addCell(celdaImg); document.add(tbl1); }catch(Exception e){ tbl.addCell(" "); }*/ } catch (Exception e) { e.printStackTrace(); } document.add(tbl); document.close(); // paso 5 /* fin PDF */ } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:jm.Reporte.java
License:GNU General Public License
public void lista(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {//from w w w . j a v a2 s . c om PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 1; i <= numCols; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } num++; } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void lista(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, int lim) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {//from w w w . j a v a 2 s.co m PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; int alineacion = Element.ALIGN_LEFT; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 1; i <= lim; i++) { //alineacion = (i==lim) ? Element.ALIGN_RIGHT : Element.ALIGN_LEFT; tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, alineacion, 1)); } num++; } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }