List of usage examples for com.itextpdf.text.pdf PdfPTable setComplete
public void setComplete(final boolean complete)
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSectionRepresentationInformation(Section section) { String sectionIntro = "Information is represented (%imade tangible by%) by documents, which stakeholders have and exchange."; section.add(createParagraph(sectionIntro)); List<Actor> selActor = getRepresentationInformationActors(); Set<IResource> validResource = new HashSet<IResource>(); for (Actor a : selActor) { for (Own o : a.getIResources()) { if (o.getTarget().getTangibleElements().size() > 0) validResource.add(o.getTarget()); }//from w ww. j a v a2s. c o m } if (validResource.size() > 0) { String s = "The documents stakeholders in the " + getProjectName() + " project" + infDiagRef() + " have and exchange with one another contain the information as summarised in " + ftc.getTable(FigureConstant.RAPPRES_INFORMA_TABLE) + ":"; section.add(createParagraph(s)); List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Information" }); headers.add(new String[] { "Document" }); headers.add(new String[] { "Description" }); PdfPTable table = createTable(headers); for (IResource r : validResource) { List<TangibleBy> tbList = new ArrayList<TangibleBy>(); for (TangibleBy tb : r.getTangibleElements()) { if (tb.getTarget() != null) { tbList.add(tb); } } if (tbList.size() != 0) { PdfPCell infCell = getContentCell(r.getName()); infCell.setRowspan(tbList.size()); table.addCell(infCell); for (TangibleBy o : tbList) { table.addCell(getContentCell(o.getTarget().getName())); table.addCell(getContentCell(o.getDescription())); } } } addTableCaption(table, ftc.getTable(FigureConstant.RAPPRES_INFORMA_TABLE) + " - Representation of Information through Documents"); section.add(table); table.setComplete(true); } else { section.add(createParagraph("In the " + getProjectName() + " project there are no \"Tangible By\" relations specified for the documents of the given agents/roles.")); } section.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSectionComposition(Section section) { String sectionIntro = "Documents (information) are composed of other documents (information). Composition of documents (information) is captured through %i part of % relations."; section.add(createParagraph(sectionIntro)); List<Actor> selActor = getCompositionActors(); Set<Resource> validResource = new HashSet<Resource>(); for (Actor a : selActor) { for (Own o : a.getIResources()) { if (o.getTarget().getSubParts().size() > 0) validResource.add(o.getTarget()); }//from w ww. j a va2 s. c o m for (TResource r : a.getTResources()) { if (r.getSubParts().size() > 0) validResource.add(r); } } if (validResource.size() > 0) { String s = ftc.getTable(FigureConstant.COMPOSITION_TABLE) + " summarises the documents and information in the " + getProjectName() + " project" + infDiagRef() + ", showing how they are composed and describing the composition."; section.add(createParagraph(s)); List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Information", "/ Document" }); headers.add(new String[] { "Composition" }); headers.add(new String[] { "Description" }); PdfPTable table = createTable(headers); for (Resource r : validResource) { List<PartOf> pofList = new ArrayList<PartOf>(); for (PartOf p : r.getSubParts()) { if (p.getTarget() != null) pofList.add(p); } if (pofList.size() > 0) { PdfPCell infCell = getContentCell(r.getName()); infCell.setRowspan(pofList.size()); table.addCell(infCell); for (PartOf p : pofList) { table.addCell(getContentCell(p.getSource().getName())); table.addCell(getContentCell(p.getDescription())); } } } addTableCaption(table, ftc.getTable(FigureConstant.COMPOSITION_TABLE) + " - Information and documents composition"); section.add(table); table.setComplete(true); } else { section.add(createParagraph( "In the " + getProjectName() + " project there are no composite documents or information.")); } section.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSecurityRequirementsChapterContentTable(Chapter chapter) { List<Actor> selActors = getSecurityRequirementsActors(); List<String[]> headers = new ArrayList<String[]>();// headers.add(new String[] { "Responsible" }); headers.add(new String[] { "Security Requirement" }); headers.add(new String[] { "Requester" }); headers.add(new String[] { "Description" }); PdfPTable table = createTable(headers); for (Actor act : selActors) { List<PdfPCell> cells = new ArrayList<PdfPCell>(); for (Delegation d : act.getIncomingDelegations()) { if (selActors.contains(d.getSource()) && (d.getTimesTransferable() >= 0 || d.getRepudiationType() != RepudiationType.NO_REPUDIATION || d.getRedundancyType() != RedundancyType.NO_REDUNDANCY || d.isAvailability())) { if (d.getRedundancyType() != RedundancyType.NO_REDUNDANCY) { String red = ""; switch (d.getRedundancyType()) { case TRUE_SINGLE: red = "single-actor-true-redundancy"; break; case TRUE_MULTI: red = "multi-actor-true-redundancy"; break; case FALLBACK_SINGLE: red = "single-actor-fallback-redundancy"; break; case FALLBACK_MULTI: red = "single-actor-fallback-redundancy"; break; }/*from w ww .j a v a 2 s. c o m*/ cells.add(getContentCell(new String[] { red, "(" + d.getSourceGoal().getName() + ")" })); cells.add(getContentCell(d.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(d.getTarget().getName() + " requires " + red + " for goal " + d.getSourceGoal().getName() + ","); sb.append("when delegating " + d.getSourceGoal().getName() + " to " + d.getTarget().getName() + "."); cells.add(getContentCell(sb.toString())); } if (d.getTimesTransferable() >= 0) { String s = "no-delegation"; cells.add(getContentCell(new String[] { s, "(" + d.getSourceGoal().getName() + ")" })); cells.add(getContentCell(d.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(d.getTarget().getName() + " requires " + s + " for goal " + d.getSourceGoal().getName() + ","); sb.append("when delegating " + d.getSourceGoal().getName() + " to " + d.getTarget().getName() + "."); cells.add(getContentCell(sb.toString())); } if (d.getRepudiationType() == RepudiationType.DUAL_REPUDIATION || d.getRepudiationType() == RepudiationType.DELEGATEEE_REPUDIATION) { cells.add(getContentCell(new String[] { "non-repudiation-of-acceptance", "(delegated(" + d.getSource().getName() + "," + d.getTarget().getName() + "," + d.getSourceGoal().getName() + "))" })); cells.add(getContentCell(d.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(d.getSource().getName() + " require non-repudiation-of-acceptance for goal " + d.getSourceGoal().getName() + ","); sb.append("when delegating " + d.getSourceGoal().getName() + " to " + d.getTarget().getName() + "."); cells.add(getContentCell(sb.toString())); } if (d.isAvailability()) { cells.add(getContentCell(new String[] { "availability", "(" + d.getSourceGoal().getName() + "," + d.getAvailabilityValue() + "%)" })); cells.add(getContentCell(d.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(d.getSource().getName() + " require " + d.getTarget().getName() + " to assure an availability level of " + d.getAvailabilityValue() + "% for goal " + d.getSourceGoal().getName() + "."); cells.add(getContentCell(sb.toString())); } } } for (Delegation d : act.getOutgoingDelegations()) { if (selActors.contains(d.getTarget()) && (d.getRepudiationType() != RepudiationType.NO_REPUDIATION || d.isTrustworthiness())) { if (d.getRepudiationType() == RepudiationType.DUAL_REPUDIATION || d.getRepudiationType() == RepudiationType.DELEGATOR_REPUDIATION) { cells.add(getContentCell(new String[] { "non-repudiation-of-delegation", "(delegated(" + d.getSource().getName() + "," + d.getTarget().getName() + "," + d.getSourceGoal().getName() + "))" })); cells.add(getContentCell(d.getTarget().getName())); StringBuilder sb = new StringBuilder(); sb.append(d.getTarget().getName() + " require non-repudiation-of-delegation for goal " + d.getSourceGoal().getName() + ","); sb.append("when delegated " + d.getSourceGoal().getName() + " by " + d.getSource().getName() + "."); cells.add(getContentCell(sb.toString())); } if (d.isTrustworthiness()) { cells.add(getContentCell( new String[] { "trustworthiness", "(delegatedTo(" + d.getTarget().getName() + ", trustworthiness level: " + d.getTrustworthinessValue() + "))" })); cells.add(getContentCell(d.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(d.getSource().getName() + " will delegate to " + d.getTarget().getName() + " that have trustwhorthiness level only grater than " + d.getTrustworthinessValue()); cells.add(getContentCell(sb.toString())); } } } for (Provision p : act.getIncomingProvisions()) { if (selActors.contains(p.getTarget()) && (p.isAvailability())) { if (p.isAvailability()) { cells.add(getContentCell(new String[] { "availability", "(" + p.getSourceResource().getName() + "," + p.getAvailabilityValue() + "%)" })); cells.add(getContentCell(p.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(p.getSource().getName() + " require " + p.getTarget().getName() + " to assure an availability level of " + p.getAvailabilityValue() + "% for document " + p.getSourceResource().getName() + "."); cells.add(getContentCell(sb.toString())); } } } for (Provision p : act.getOutgoingProvisions()) { if (selActors.contains(p.getTarget()) && (p.isIntegrity() || p.isConfidentiality())) { if (p.isIntegrity()) { cells.add( getContentCell(new String[] { "integrity", "(provided(" + p.getSource().getName() + "," + p.getTarget().getName() + "," + p.getSourceResource().getName(), "))" })); cells.add(getContentCell(p.getSource().getName())); StringBuilder sb = new StringBuilder(); String a = p.getTarget().getName(); String b = p.getSource().getName(); String d = p.getSourceResource().getName(); sb.append(a + " requires " + b + " to ensure integrity of transmission over the provision of document " + d + ", when " + b + " provides " + d + " to " + a + "."); cells.add(getContentCell(sb.toString())); } if (p.isConfidentiality()) { cells.add( getContentCell(new String[] { "confidentiality", "(provided(" + p.getSource().getName() + "," + p.getTarget().getName() + "," + p.getSourceResource().getName(), "))" })); cells.add(getContentCell(p.getSource().getName())); StringBuilder sb = new StringBuilder(); String a = p.getTarget().getName(); String b = p.getSource().getName(); String d = p.getSourceResource().getName(); sb.append(a + " requires " + b + " to ensure confidentiality of transmission over the provision of document " + d + ", when " + b + " provides " + d + " to " + a + "."); cells.add(getContentCell(sb.toString())); } } } for (Authorisation a : act.getIncomingAuthorisations()) { if (selActors.contains(a.getSource()) && a.getResources().size() > 0 && (a.isDistribution() || a.isModification() || a.isUsage() || a.isProduce())) { List<String> res = new ArrayList<String>(); List<String> goal = new ArrayList<String>(); for (IResource r : a.getResources()) { res.add(r.getName()); } for (Goal g : a.getGoals()) { goal.add(g.getName()); } if (!a.isUsage()) { String s = "non-usage"; cells.add(getContentCell( new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" })); cells.add(getContentCell(a.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s + " of Information "); sb.append(separateListOfString(res) + "."); cells.add(getContentCell(sb.toString())); } if (!a.isModification()) { String s = "non-modification"; cells.add(getContentCell( new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" })); cells.add(getContentCell(a.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s + " of Information "); sb.append(separateListOfString(res) + "."); cells.add(getContentCell(sb.toString())); } if (!a.isProduce()) { String s = "non-production"; cells.add(getContentCell( new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" })); cells.add(getContentCell(a.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s + " of Information "); sb.append(separateListOfString(res) + "."); cells.add(getContentCell(sb.toString())); } if (!a.isDistribution()) { String s = "non-disclosure"; cells.add(getContentCell( new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" })); cells.add(getContentCell(a.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s + " of Information "); sb.append(separateListOfString(res) + "."); cells.add(getContentCell(sb.toString())); } if (a.getGoals().size() > 0) { String s = "need-to-know"; cells.add(getContentCell(new String[] { s, "(" + separateListOfString(res, ",", ",") + ")", "(" + separateListOfString(goal, ",", ",") + ")" })); cells.add(getContentCell(a.getSource().getName())); StringBuilder sb = new StringBuilder(); sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s + " of Information "); sb.append(separateListOfString(res) + ", in the scope of goal " + separateListOfString(goal) + "."); cells.add(getContentCell(sb.toString())); } } } PdfPCell respCell = getContentCell(act.getName()); if (cells.size() > 0) { if (cells.size() >= 3) { respCell.setRowspan(cells.size() / 3); } table.addCell(respCell); for (PdfPCell c : cells) { table.addCell(c); } } } List<PdfPCell> cells = new ArrayList<PdfPCell>(); for (Actor act : selActors) { if (act instanceof Role) { Role r = (Role) act; for (IncompatibleDuties id : r.getIncompatibleDutiesIn()) { cells.add(getContentCell(new String[] { "not-play-both", "(" + ((Role) id.getSource()).getName() + "," + ((Role) id.getTarget()).getName() + ")" })); cells.add(getContentCell( "Any agent that play " + r.getName() + " or " + ((Role) id.getSource()).getName() + ", is required not to play (adopt) the other role too.")); } } for (Goal g : act.getGoals()) { for (IncompatibleDuties id : g.getIncompatibleDutiesIn()) { cells.add(getContentCell(new String[] { "not-achieve-both", "(" + g.getName() + "," + ((Goal) id.getSource()).getName() + ")" })); cells.add(getContentCell( "Any agent that achieves " + g.getName() + " or " + ((Goal) id.getSource()).getName() + ", is required not to achieve the other goal too.")); } for (CompatibleDuties cd : g.getCompatibleDutiesIn()) { cells.add(getContentCell(new String[] { "achieve-in-combination", "(" + g.getName() + "," + ((Goal) cd.getSource()).getName() + ")" })); cells.add(getContentCell("Any agent that achieves one of " + g.getName() + " or " + ((Goal) cd.getSource()).getName() + ", is required to achieve the other goal too.")); } } /* * for(Goal g:act.getGoals()){ for (IncompatibleDuties id : * g.getIncompatibleDutiesIn()) { cells.add(getContentCell(new * String[] {"achieves(a,"+g.getName()+")", * "then not achieve(a,"+((Goal)id.getSource()).getName()+")"})); * cells * .add(getContentCell("Org requires any agent a that achieves " * +g.getName * ()+" not to achieve "+((Goal)id.getSource()).getName())); } for * (IncompatibleDuties id : g.getIncompatibleDutiesOut()) { * cells.add(getContentCell(new String[] * {"achieves(a,"+g.getName()+")", * "then not achieve(a,"+((Goal)id.getTarget()).getName()+")"})); * cells * .add(getContentCell("Org requires any agent a that achieves " * +g.getName * ()+" not to achieve "+((Goal)id.getTarget()).getName())); } * * for (CompatibleDuties cd : g.getCompatibleDutiesIn()) { * cells.add(getContentCell(new String[] * {"achieves(a,"+g.getName()+")", * "then achieve(a,"+((Goal)cd.getSource()).getName()+")"})); * cells.add * (getContentCell("Org requires any agent a that achieves " * +g.getName * ()+" to achieve "+((Goal)cd.getSource()).getName()+" as well")); * } for (CompatibleDuties cd : g.getCompatibleDutiesOut()) { * cells.add(getContentCell(new String[] * {"achieves(a,"+g.getName()+")", * "then achieve(a,"+((Goal)cd.getTarget()).getName()+")"})); * cells.add * (getContentCell("Org requires any agent a that achieves " * +g.getName * ()+" to achieve "+((Goal)cd.getTarget()).getName()+" as well")); * } } */ } PdfPCell respCell = getContentCell("\"Any agents\""); if (cells.size() > 0) { if (cells.size() >= 2) { respCell.setRowspan(cells.size() / 2); } table.addCell(respCell); for (int i = 0; i < cells.size(); i++) { table.addCell(cells.get(i)); table.addCell(getContentCell("-")); table.addCell(cells.get(++i)); } } addTableCaption(table, ftc.getTable(FigureConstant.COMM_TABLE) + " - Security Requirements for the " + getProjectName() + " Project"); chapter.add(table); table.setComplete(true); boolean addAuthTable = false; // Chapter section = chapter; List<String[]> headers2 = new ArrayList<String[]>(); headers2.add(new String[] { "Authorisor" }); headers2.add(new String[] { "Information" }); headers2.add(new String[] { "Goal" }); headers2.add(new String[] { "Operation" }); headers2.add(new String[] { "Authorisee" }); headers2.add(new String[] { "Description" }); PdfPTable table2 = createTable(headers2); for (Actor a : selActors) { List<Authorisation> validAuth = new ArrayList<Authorisation>(); for (Authorisation au : a.getOutgoingAuthorisations()) { if (isValidAuth(au)) validAuth.add(au); } if (validAuth.size() > 0) { addAuthTable = true; PdfPCell actorCell = getContentCell(a.getName()); actorCell.setRowspan(validAuth.size()); table2.addCell(actorCell); for (Authorisation au : validAuth) { Phrase p = null; for (int i = 0; i < au.getResources().size(); i++) { if (i == 0) p = new Phrase(au.getResources().get(i).getName(), TABLE_CONTENT_SMALL); else { p.add(Chunk.NEWLINE); p.add(new Phrase(au.getResources().get(i).getName(), TABLE_CONTENT_SMALL)); } } /* * com.itextpdf.text.List resList = new * com.itextpdf.text.List(com.itextpdf.text.List.ORDERED, * com.itextpdf.text.List.NUMERICAL); for (IResource r : * au.getResources()) { ListItem listItem = new ListItem(new * Phrase(r.getName(), TABLE_CONTENT)); * resList.add(listItem); } */ PdfPCell c = getContentCell(); c.addElement(p); table2.addCell(c); // -------------------------------------// if (au.getGoals().size() > 0) { Phrase p1 = null; for (int i = 0; i < au.getGoals().size(); i++) { if (i == 0) p1 = new Phrase(au.getGoals().get(i).getName(), TABLE_CONTENT_SMALL); else { p1.add(Chunk.NEWLINE); p1.add(new Phrase(au.getGoals().get(i).getName(), TABLE_CONTENT_SMALL)); } } /* * com.itextpdf.text.List goalList = new * com.itextpdf.text * .List(com.itextpdf.text.List.ORDERED, * com.itextpdf.text.List.NUMERICAL); for (Goal g : * au.getGoals()) { ListItem listItem = new ListItem(new * Phrase(g.getName(), TABLE_CONTENT)); * goalList.add(listItem); } */ PdfPCell c1 = getContentCell(); c1.addElement(p1); table2.addCell(c1); } else { table2.addCell(getContentCell("")); } // -------------------------------------// table2.addCell(getContentCell(getOperationsTable(au))); // -------------------------------------// table2.addCell(getContentCell(au.getTarget().getName())); if (au.getTimesTransferable() == 0) { table2.addCell(getContentCell("Non-transferable authority")); } else { table2.addCell(getContentCell("Transferable authority")); } } } } if (addAuthTable) { chapter.add(createParagraph("")); chapter.add(createParagraph( ftc.getTable(FigureConstant.AUTH_TABLE) + " summarises the authorisations actors in the " + getProjectName() + " project grant to one another.")); chapter.add(table2); addTableCaption(table2, ftc.getTable(FigureConstant.AUTH_TABLE) + " - Authorisations in the " + getProjectName() + " project"); table2.setComplete(true); } }
From source file:Export.TableOfSalary.java
public static void ciarDoc(String user, String idProcesso, String data) { FileOutputStream outputStraem; try {/* ww w. j a v a 2 s. co m*/ Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f); Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f); Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Relatorio"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Tabela de Salrio " + Ddata + ".pdf"); outputStraem = new FileOutputStream(ff); String reString = "../Documentos/" + user + "/Relatorio/Tabela de Salrio " + Ddata + ".pdf"; PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 7f, 93f }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1); PdfPTable pTableNull = new PdfPTable(1); PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo)); cellNull.setBorder(0); pTableNull.addCell(cellNull); PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1); cellTabela3.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela3); PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5); cellTabela5.setBorder(0); PdfPCell cellTabela6 = new PdfPCell(imageEmpresa); cellTabela6.setBorder(0); pTableEmpresaPricipal.setWidthPercentage(97); pTableEmpresaPricipal.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); Document documento = new Document(PageSize.A3.rotate()); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); PdfPTable pTableDados = new PdfPTable(new float[] { 2.5f, 7.5f, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }); pTableDados.setWidthPercentage(105); /** * primeira linha de titulo inicio */ PdfPCell cellDados; Paragraph pTitile = new Paragraph(); // SimpleDateFormat sdfPT = new SimpleDateFormat("MMMM yyyy",new Locale("pt", "BR")); pTitile.add(new Paragraph(ConfigDoc.Empresa.NOME + "\n" + "TABELA SAL?RIO REFERENTE A " + data, fontCorpoN)); cellDados = new PdfPCell(pTitile); cellDados.setColspan(10); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("F\nSOC. SEGU. 4%", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("G", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("H", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("I", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("IMPOSTO\n18% : 20%", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); for (int j = 0; j < 8; j++) { cellDados = new PdfPCell(new Phrase(" ", fontCorpo)); pTableDados.addCell(cellDados); } cellDados = new PdfPCell(new Phrase("6\nSOC. SEGU.", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); /** * primeira linha de titulo Fim */ /** * Segunda linha de titulo Inicio */ for (int j = 0; j < 3; j++) { cellDados = new PdfPCell(new Phrase(" ", fontCorpo)); pTableDados.addCell(cellDados); } cellDados = new PdfPCell(new Phrase("A", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("B", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("C", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("D", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("E", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("SUBSIDIO DE", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("VALOR A SER", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("F=(E*4%)", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("G=(E-F)", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("I=G+", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("J=", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); for (int j = 0; j < 4; j++) { cellDados = new PdfPCell(new Phrase(" ", fontCorpo)); pTableDados.addCell(cellDados); } cellDados = new PdfPCell(new Phrase("SUBSIDIO DE", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("k=E-(F+G)", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("PYT", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("I", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("J", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); /** * Segunda linha de titulo Fim */ /** * Terceira linha de titulo Inicio */ for (int i = 0; i < 25; i++) { cellDados = new PdfPCell(new Phrase(getTitile(i), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); } /** * Terceira linha de titulo FIM */ ArrayList<Processo> ps = getListData(idProcesso); for (Processo p : ps) { cellDados = new PdfPCell(new Phrase(p.CODIGO1, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.NOME2, fontCorpo)); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.DIAS3, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.S_BASE4, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.S_ALOJAMENTO5, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.S_TRANSPORTE6, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.S_ALMOCO7, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.TT_SEM8, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.ALMOCOLIVREIMPOSTO9, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.TRIBUTADO10, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.SSFUNCIONARIO11, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.MENOS_SS_FUNCIONARIO12, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.COMISOES13, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.TOTAL_E_COMISAO14, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.IRS15, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.PARCELABATER16, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.IRSAPURADO17, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.SITUAFAMILIAR18, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.IRSLIQUIDO19, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.ALMOCO20, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.SALARIOLIQUIDO21, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.AVANCO22, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.NETOUT23, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.SSEMPRESA24, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.TOTAL25, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); } PdfPTable pTableRodape = new PdfPTable(new float[] { 33.333333333f, 33.333333333f, 33.333333333f }); PdfPTable pTableSegurancaSocial = new PdfPTable( new float[] { 35f, 21.666666667f, 21.666666667f, 21.666666667f }); pTableSegurancaSocial.setWidthPercentage(75f); PdfPTable pTableImpostoSalario = new PdfPTable(new float[] { 25f, 25f, 25f, 25f }); pTableImpostoSalario.setWidthPercentage(75f); PdfPTable pTableNetSalaryPayble = new PdfPTable(new float[] { 70f, 30f }); pTableNetSalaryPayble.setWidthPercentage(75f); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 25f, 25f, 25f, 25f }); /** * segurano social inicio */ cellDados = new PdfPCell(new Phrase("SEGURANA SOCIAL", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setPaddingTop(8.5f); pTableRodape.addCell(cellDados); /** * segurano social Fim */ /** * IMPOSTO DE SAL?RIO inicio */ cellDados = new PdfPCell(new Phrase("IMPOSTO DE SAL?RIO", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setPaddingTop(8.5f); pTableRodape.addCell(cellDados); /** * IMPOSTO DE SAL?RIO Fim */ /** * NET SALARY PAYABLE incial */ cellDados = new PdfPCell(new Phrase("NET SALARY PAYABLE", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setPaddingTop(8.5f); pTableRodape.addCell(cellDados); /** * NET SALARY PAYABLE Fim */ /** * segurano social inicio */ cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setBorder(PdfPCell.NO_BORDER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase("4%", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase("6%", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase( Moeda.format(Double.valueOf(psList.get(0).SSFUNCIONARIO11.replace(',', '.'))), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase( Moeda.format(Double.valueOf(psList.get(0).SSEMPRESA24.replace(',', '.'))), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell( new Phrase(Moeda.format((Double.valueOf(psList.get(0).SSFUNCIONARIO11.replace(',', '.')) + Double.valueOf(psList.get(0).SSEMPRESA24.replace(',', '.')))), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); pTableSegurancaSocial.setComplete(true); cellDados = new PdfPCell(pTableSegurancaSocial); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setPadding(8.5f); // cellDados.setCalculatedHeight(100); pTableRodape.addCell(cellDados); /** * segurano social Fim */ /** * IMPOSTO DE SAL?RIO inicio */ cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableImpostoSalario.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableImpostoSalario.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableImpostoSalario.addCell(cellDados); cellDados = new PdfPCell(new Phrase( Moeda.format(Double.valueOf(psList.get(0).IRSLIQUIDO19.replace(',', '.'))), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableImpostoSalario.addCell(cellDados); pTableImpostoSalario.setComplete(true); cellDados = new PdfPCell(pTableImpostoSalario); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cellDados.setCalculatedHeight(100); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setPadding(8.5f); pTableRodape.addCell(cellDados); /** * IMPOSTO DE SAL?RIO Fim */ /** * NET SALARY PAYABLE incial */ for (Map.Entry<String, TotalBank> entrySet : tbs.entrySet()) { cellDados = new PdfPCell( new Phrase(((entrySet.getValue().nome.isEmpty()) ? "INDEFINIDO" : entrySet.getValue().nome), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); pTableNetSalaryPayble.addCell(cellDados); cellDados = new PdfPCell(new Phrase(Moeda.format(entrySet.getValue().value), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableNetSalaryPayble.addCell(cellDados); } cellDados = new PdfPCell(pTableNetSalaryPayble); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cellDados.setCalculatedHeight(100); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setPadding(8.5f); pTableRodape.addCell(cellDados); /** * NET SALARY PAYABLE Fim */ /** * Asssinatura inicio */ cellDados = new PdfPCell(new Phrase("VISTO\nRESPONS?VEL CONTABILIDADE", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(20.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell(new Phrase("VISTO\nDIRETOR ADMINISTRATIVO & FINANCEIRO", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(20.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell(new Phrase("VISTO\nDIRETOR GERAL", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(20.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell(new Phrase("VISTO\nAUDITOR INTERNO", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(20.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell( new Phrase("______________________________________________________", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(5.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell( new Phrase("______________________________________________________", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell( new Phrase("______________________________________________________", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell( new Phrase("______________________________________________________", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell(pTableAssinatura); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setColspan(3); pTableRodape.addCell(cellDados); /** * Asssinatura fim */ cellDados = new PdfPCell(pTableRodape); cellDados.setColspan(25); pTableDados.addCell(cellDados); documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableDados); documento.close(); psList = new ArrayList<>(); tbs = new LinkedHashMap<>(); RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (FileNotFoundException ex) { Logger.getLogger(TableOfSalary.class.getName()).log(Level.SEVERE, null, ex); } catch (BadElementException ex) { Logger.getLogger(TableOfSalary.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException | DocumentException ex) { Logger.getLogger(TableOfSalary.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:gestionEtat.imprimerBulletin.BulletinCtrl.java
@Override public void enregistrerBulletin() { if (FacesContext.getCurrentInstance().getExternalContext().getSessionMap().containsKey("user")) { if (eleveAnneeClasse.getId() != null) { classematieres.clear();//from ww w. j a v a2 s. co m matieres.clear(); notesPropres.clear(); matiereCompses.clear(); eleveAnneeClasse = eleveAnneeClasseFacade.find(eleveAnneeClasse.getId()); if (sequence != null) { Annee an = anneeFacade.findByEtatSingle(true); Eleveanneeclasse eleveClasse = eleveAnneeClasseFacade.getEleveAnneeClaseByAnneClasse( eleveAnneeClasse.getEleve().getIdeleve(), an.getIdannee()); if (eleveClasse != null) { List<Naturematiere> nature = natureMatiereFacade.findAll(); if (!nature.isEmpty()) { List<Evaluation> notes = evaluationFacadeLocal.getByEleveAnneeSequence( eleveAnneeClasse.getEleve().getIdeleve(), an.getIdannee(), sequence.getIdsequencean()); /*if (!notes.isEmpty()) {*/ try { String bulletinName = "" + eleveAnneeClasse.getEleve().getNom() + "_" + eleveAnneeClasse.getEleve().getPrenom() + "_" + sequence.getIdsequence().getNom() + ".pdf"; Document bulletin = new Document(); PdfWriter.getInstance(bulletin, new FileOutputStream(Utilitaires.path + "/" + Utilitaires.repertoireParDefautBulletin + "/" + bulletinName)); bulletin.setMargins(5, 5, 5, 5); bulletin.addCreator("School Manager"); bulletin.setPageSize(PageSize.A4); bulletin.open(); //tableau qui va contenir les notes PdfPTable table = new PdfPTable(5); table.setComplete(true); //entete de bulletin table.addCell( PrintUtils.createPdfPCell("COLLEGE POZAM Anne Scolaire " + an.getCode() + " - " + (an.getCode() + 1) + " " + an.getTheme(), 5, detail)); table.addCell(PrintUtils.createPdfPCell( "BULLETIN DE NOTES DE : " + sequence.getIdsequence().getNom(), 5, true)); table.addCell(PrintUtils .createPdfPCell("Nom : " + eleveAnneeClasse.getEleve().getNom(), 2, false)); PdfPCell cellLogo = new PdfPCell(new Paragraph(" ")); cellLogo.setRowspan(2); table.addCell(cellLogo); table.addCell(PrintUtils.createPdfPCell( "Matricule : " + eleveAnneeClasse.getEleve().getMatricule(), 2, false)); table.addCell(PrintUtils.createPdfPCell( "Prnom : " + eleveAnneeClasse.getEleve().getPrenom(), 2, false)); //table.addCell("kenne"); PdfPCell cellClasse = new PdfPCell( new Paragraph("Classe : " + eleveClasse.getIdclasse().getNom())); cellClasse.setColspan(2); table.addCell(cellClasse); //debut de saisis de notes PdfPTable entete = new PdfPTable(5); table.addCell(new Paragraph("Dicipline")); table.addCell(PrintUtils.createPdfPCell("Note ", true)); table.addCell(PrintUtils.createPdfPCell("Cofficient ", true)); table.addCell(PrintUtils.createPdfPCell("Total", true)); table.addCell(PrintUtils.createPdfPCell("Apprciation", true)); //partie qui contient es totaux PdfPTable total = new PdfPTable(5); int totalCoef = 0; float totalPoint = 0; classematieres = classeMatiereFacade .get(eleveAnneeClasse.getIdclasse().getIdclasse()); if (!classematieres.isEmpty()) { for (Classematiere m : classematieres) { matieres.add(m.getIdmatiere()); } /*for (Evaluation e : notes) { if (matieres.contains(e.getIdmatiere())) { notesPropres.add(e); matiereCompses.add(e.getIdmatiere()); } }*/ for (int i = 0; i < nature.size(); i++) { table.addCell( PrintUtils.createPdfPCell("Matires " + nature.get(i).getLibelle(), 5, false, PrintUtils.blueFont)); int totalCoefBloc = 0; int totalPointBloc = 0; for (int a = 0; a < matieres.size(); a++) { if (matiereCompses.contains(matieres.get(a))) { //if (Objects.equals(notesPropres.get(a).getIdmatiere(), nature.get(i).getIdnaturematiere())) {; //decompte des coefficient et nombre point globaux //totalCoef += notesPropres.get(a).getIdmatiere().getCoeficient(); // totalPoint += notesPropres.get(a).getNote() * notesPropres.get(a).getIdmatiere().getCoeficient(); //decompte des coef et point par groupe //totalCoefBloc += notesPropres.get(a).getIdmatiere().getCoeficient(); //totalPointBloc += notesPropres.get(a).getNote() * notesPropres.get(a).getIdmatiere().getCoeficient(); // table.addCell(PrintUtils.createPdfPCell("" + notesPropres.get(a).getIdmatiere().getIdtypematiere().getLibelle(), false, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); //table.addCell(PrintUtils.createPdfPCell("" + notesPropres.get(a).getNote(), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); //table.addCell(PrintUtils.createPdfPCell("" + notesPropres.get(a).getIdmatiere().getCoeficient(), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); //table.addCell(PrintUtils.createPdfPCell("" + (notesPropres.get(a).getNote() * notesPropres.get(a).getIdmatiere().getCoeficient()), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); //table.addCell(PrintUtils.createPdfPCell("" + notesPropres.get(a).getObservation(), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.ITALIC))); // } } else { if (Objects.equals( matieres.get(a).getIdnaturematiere().getIdnaturematiere(), nature.get(i).getIdnaturematiere())) { //decompte des coefficient et nombre point globaux // totalCoef += matieres.get(a).get totalPoint += 0; //decompte des coef et point par groupe // totalCoefBloc += matieres.get(a).getCoeficient(); totalPointBloc += 0; // table.addCell(PrintUtils.createPdfPCell("" + matieres.get(a).getIdtypematiere().getLibelle(), false, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("O", true, new Font( Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); // table.addCell(PrintUtils.createPdfPCell("" + matieres.get(a).getCoeficient(), true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("0", true, new Font( Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("Pas encore valu", true, new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.ITALIC))); } } } //le texte Total pour chaque bloc PdfPCell cellTotalBlocText = new PdfPCell( new Paragraph("Total Matires " + nature.get(i).getLibelle() + " ", new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); cellTotalBlocText.setColspan(2); table.addCell(cellTotalBlocText); table.addCell(PrintUtils.createPdfPCell("" + totalCoefBloc, true, new Font( Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.RED))); table.addCell(PrintUtils.createPdfPCell("" + totalPointBloc, 2, true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.RED))); table.addCell(PrintUtils.createPdfPCell( "Moyenne Matires " + nature.get(i).getLibelle(), 3, false, PrintUtils.blueFont)); if (totalCoefBloc != 0) { table.addCell(PrintUtils.createPdfPCell( "" + (totalPointBloc / totalCoefBloc) + "/20", 2, true, PrintUtils.redFont)); } else { table.addCell(PrintUtils.createPdfPCell("......", 2, true, PrintUtils.redFont)); } table.addCell(PrintUtils.createPdfPCell(" ", 5, false)); } } else { } //on ecrit totaux table.addCell(PrintUtils.createPdfPCell("Totaux ", 2, false, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLUE))); //on met le total de coefficient table.addCell(PrintUtils.createPdfPCell("" + totalCoef, true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.RED))); //on met le total de point table.addCell(PrintUtils.createPdfPCell("" + totalPoint, 2, true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.RED))); table.addCell(PrintUtils.createPdfPCell( "Moyenne de la " + sequence.getIdsequence().getNom(), 3, false, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLUE))); if (totalCoef != 0) { table.addCell(PrintUtils.createPdfPCell((totalPoint / totalCoef) + "/20", 2, true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.RED))); } bulletin.add(table); bulletin.close(); JsfUtil.addSuccessMessage( "Opration russie,redirigez-vous dans le repertoire bulletin"); } catch (DocumentException ex) { Logger.getLogger(BulletinCtrl.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(BulletinCtrl.class.getName()).log(Level.SEVERE, null, ex); } /*} else { JsfUtil.addErrorMessage("L'lve selectionn n a aucune note la squence slectionne"); }*/ } else { JsfUtil.addErrorMessage("Aucune nature de matiere parametre"); } } else { JsfUtil.addErrorMessage("l'eleve n a pas de classe"); } } else { JsfUtil.addErrorMessage("veuillez selectionner une squence !"); } } else { JsfUtil.addErrorMessage("Veuillez selectionner un lve"); } } else { String sc = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); try { FacesContext.getCurrentInstance().getExternalContext().redirect(sc + "/login.html"); } catch (IOException ex) { Logger.getLogger(BulletinCtrl.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:gestionEtat.imprimerBulletin.BulletinCtrl.java
@Override public void imprimerListeClasse() { if (FacesContext.getCurrentInstance().getExternalContext().getSessionMap().containsKey("user")) { if (classe != null) { Annee an = anneeFacade.findByEtatSingle(true); if (an != null) { List<Eleveanneeclasse> elevs = eleveAnneeClasseFacade.findByAnneeClasse(an.getIdannee(), classe.getIdclasse()); if (!elevs.isEmpty()) { try { String listeName = "liste_des_eleve_" + classe.getNom() + ".pdf"; Document liste = new Document(); liste.setMargins(2, 2, 2, 2); PdfWriter.getInstance(liste, new FileOutputStream(Utilitaires.path + "/" + Utilitaires.repertoireParDefautClasse + "/" + listeName)); liste.open();//w w w. ja va 2 s . c om PdfPTable table = new PdfPTable(4); table.setComplete(true); table.addCell(PrintUtils.createPdfPCell("Liste des lves de la " + classe.getNom() + " Anne Scolaire : " + an.getCode() + " - " + (an.getCode() + 1), 4, true)); table.addCell(PrintUtils.createPdfPCell("NOM", true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("PRENOM", true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("MATRICULE", true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("DATE DE NAISSANCE", true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL))); //debut d'ecriture des lignes; for (int i = 0; i < elevs.size(); i++) { table.addCell(PrintUtils.createPdfPCell("" + elevs.get(i).getEleve().getNom(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("" + elevs.get(i).getEleve().getPrenom(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("" + elevs.get(i).getEleve().getMatricule(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell( "" + elevs.get(i).getEleve().getDatenaissance().getDay() + "-" + elevs.get(i).getEleve().getDatenaissance().getMonth() + "-" + elevs.get(i).getEleve().getDatenaissance().getYear(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); } liste.add(table); liste.close(); JsfUtil.addSuccessMessage("Impression russie !"); } catch (FileNotFoundException | DocumentException ex) { Logger.getLogger(BulletinCtrl.class.getName()).log(Level.SEVERE, null, ex); } } else { JsfUtil.addErrorMessage("La classe selectionne n'a aucune !"); } } else { JsfUtil.addFatalErrorMessage("L'anne en cours n'est pas parametre"); } } else { JsfUtil.addErrorMessage("Veuillez selectionner une classe !"); } } else { String sc = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); try { FacesContext.getCurrentInstance().getExternalContext().redirect(sc + "/login.html"); } catch (IOException ex) { Logger.getLogger(BulletinCtrl.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:gestionEtat.imprimerListeEleve.ListeEleveCtrl.java
@Override public void imprimerListeClasse() { if (FacesContext.getCurrentInstance().getExternalContext().getSessionMap().containsKey("user")) { if (classe != null) { Annee an = anneeFacade.findByEtatSingle(true); if (an != null) { List<Eleveanneeclasse> elevs = eleveAnneeClasseFacade.findByAnneeClasse(an.getIdannee(), classe.getIdclasse()); if (!elevs.isEmpty()) { try { String listeName = "liste_des_eleve_" + classe.getNom() + ".pdf"; Document liste = new Document(); liste.setMargins(2, 2, 2, 2); PdfWriter.getInstance(liste, new FileOutputStream(Utilitaires.path + "/" + Utilitaires.repertoireParDefautClasse + "/" + listeName)); liste.open();//from w w w . jav a 2s . c o m PdfPTable table = new PdfPTable(4); table.setComplete(true); table.addCell(PrintUtils.createPdfPCell("Liste des lves de la " + classe.getNom() + " Anne Scolaire : " + an.getCode() + " - " + (an.getCode() + 1), 4, true)); table.addCell(PrintUtils.createPdfPCell("NOM", true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("PRENOM", true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("MATRICULE", true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("DATE DE NAISSANCE", true, new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL))); //debut d'ecriture des lignes; for (int i = 0; i < elevs.size(); i++) { table.addCell(PrintUtils.createPdfPCell("" + elevs.get(i).getEleve().getNom(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("" + elevs.get(i).getEleve().getPrenom(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("" + elevs.get(i).getEleve().getMatricule(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell( "" + elevs.get(i).getEleve().getDatenaissance().getDay() + "-" + elevs.get(i).getEleve().getDatenaissance().getMonth() + "-" + elevs.get(i).getEleve().getDatenaissance().getYear(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); } liste.add(table); liste.close(); JsfUtil.addSuccessMessage("Impression russie !"); } catch (FileNotFoundException | DocumentException ex) { Logger.getLogger(ListeEleveCtrl.class.getName()).log(Level.SEVERE, null, ex); } } else { JsfUtil.addErrorMessage("La classe selectionne n'a aucune !"); } } else { JsfUtil.addFatalErrorMessage("L'anne en cours n'est pas parametre"); } } else { JsfUtil.addErrorMessage("Veuillez selectionner une classe !"); } } else { String sc = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); try { FacesContext.getCurrentInstance().getExternalContext().redirect(sc + "/login.html"); } catch (IOException ex) { Logger.getLogger(ListeEleveCtrl.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter.java
License:Open Source License
private void createTable(Paragraph paragrah) throws MalformedURLException, IOException, DocumentException { PdfPTable table = new PdfPTable(6); table.setHeaderRows(0);//w w w .j a va 2s . co m table.setWidthPercentage(95f); PdfPCell c1 = new PdfPCell(new Phrase(Messages.elementType)); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(Messages.name)); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(Messages.property)); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(Messages.information)); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(Messages.status)); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase(Messages.reviewed)); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); List<Change> changes = report.getChanges(); if (viewer != null) { for (int i = 0; i < changes.size(); i++) { addTableRow(table, (Change) viewer.getElementAt(i)); } } else { for (Change change : changes) { addTableRow(table, change); } } table.setWidths(new int[] { 3, 3, 3, 5, 2, 2 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setComplete(true); paragrah.add(table); }
From source file:privilege.mouchard.MouchardCtrl.java
@Override public void imprimerTraceurPdf() { try {// ww w .ja va 2s .com } catch (Exception e) { Personnel user = UtilitaireSession.getInstance().getuser(); if (user != null) { String fichier = "Liste_actionUtilisateur du " + new Date() + "_.pdf"; Document mouchard = new Document(); try { PdfWriter.getInstance(mouchard, new FileOutputStream(Utilitaires.path + "/" + fichier)); mouchard.setMargins(5, 5, 5, 5); mouchard.addCreator("School Manager"); mouchard.setPageSize(PageSize.A4); mouchard.open(); if (!getTraceurs().isEmpty()) { PdfPTable table = new PdfPTable(6); table.setComplete(true); table.addCell(PrintUtils.createPdfPCell("Liste des actions utilisateur", 6, detail)); table.addCell(new Paragraph("Nom")); table.addCell(PrintUtils.createPdfPCell("Prnom ", true)); table.addCell(PrintUtils.createPdfPCell("Action ", 3, true)); table.addCell(PrintUtils.createPdfPCell("Date", true)); for (int i = 0; i < getTraceurs().size(); i++) { } JsfUtil.addSuccessMessage("Liste cre avec succs !"); } mouchard.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(MouchardCtrl.class.getName()).log(Level.SEVERE, null, ex); } } else { JsfUtil.addWarningMessage("Aucune session utilisateur initie !"); } } }