List of usage examples for com.itextpdf.text Paragraph add
@Override public boolean add(Element o)
Element
to the Paragraph
. From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSectionGoalDelegations(Section section) { String sectionIntro = "Stakeholders interact with others to achieve some of their goals by means of goal delegations. Goal delegations are graphically represented as a relation that starts from a delegator actor to a delegatee actor (following the direction of the arrow), having a rounded corner rectangle representing the goal being delegated. Security needs are graphically specified as labels that appear below the delegated goal " + socialDiagRef() + "."; section.add(createParagraph(sectionIntro)); List<Actor> selActor = getGoalDelegationsActors(); List<Paragraph> phrases = new ArrayList<Paragraph>(); for (Actor a : selActor) { for (Delegation d : a.getOutgoingDelegations()) { Paragraph par = createParagraph("%b" + a.getName() + "% delegates goal %i" + d.getSourceGoal().getName() + "% to %b" + d.getTarget().getName() + "%."); List<String> secNeeds = buildDelegationSecNeedList(d); if (secNeeds.size() > 0) { par.add(new Phrase(" The following security needs apply to this delegation:")); par.add(Chunk.NEWLINE);/*from w w w . jav a2 s. c o m*/ par.add(new Phrase(separateListOfString(secNeeds) + ".")); } phrases.add(par); } /* * StringBuilder sbInc = new StringBuilder(); sbInc.append("%b" + * a.getName() + "% is delegated by "); * * int incCount = 0; for (Delegation d : a.getIncomingDelegations()) * { if (incCount > 0) sbInc.append(", and is delegated by "); * sbInc.append("%i" + d.getSource().getName() + "% goal %i" + * d.getSourceGoal().getName() + "%"); List<String> secNeed1 = * buildSecNeedString(d, false, 'i'); List<String> secNeed2 = * buildSecNeedString(d, true, 'i'); * * if (secNeed2.size() > 0) { switch (secNeed2.size()) { case 1: * sbInc.append(" and is required to comply with the " + * separateListOfString(secNeed2) + " security need"); break; * default: sbInc.append(" and is required to comply with the " + * separateListOfString(secNeed2) + " security needs"); break; } } * if (secNeed1.size() > 0) { switch (secNeed1.size()) { case 1: * sbInc.append(" and requires it to comply with the " + * separateListOfString(secNeed1) + " security need"); break; * default: sbInc.append(" and requires it to comply with the " + * separateListOfString(secNeed1) + " security needs"); break; } * * } List<String> parmSecNeed = buildParamterizedSecNeedString(d, * 'i'); if (parmSecNeed.size() > 0) { * sbInc.append(" and is required for a level of " + * separateListOfString(parmSecNeed)); } if (secNeed1.size() == 0 && * secNeed2.size() == 0 && parmSecNeed.size() == 0) { * sbInc.append(": no security need is speccified"); } incCount++; } * * * StringBuilder sbOut = new StringBuilder(); int outCount = 0; for * (Delegation d : a.getOutgoingDelegations()) { if (outCount > 0) * sbOut.append(", and delegates to "); sbOut.append("%i" + * d.getTarget().getName() + "% goal %i" + * d.getSourceGoal().getName() + "%"); List<String> secNeed1 = * buildSecNeedString(d, true, 'i'); List<String> secNeed2 = * buildSecNeedString(d, false, 'i'); * * if (secNeed1.size() > 0) { switch (secNeed1.size()) { case 1: * sbOut.append(" and requires it to comply with the " + * separateListOfString(secNeed1) + " security need"); break; * default: sbOut.append(" and requires it to comply with the " + * separateListOfString(secNeed1) + " security needs"); break; } } * if (secNeed2.size() > 0) { switch (secNeed2.size()) { case 1: * sbOut.append(" and is required to comply with the " + * separateListOfString(secNeed2) + " security need"); break; * default: sbOut.append(" and is required to comply with the " + * separateListOfString(secNeed2) + " security needs"); break; } } * List<String> parmSecNeed = buildParamterizedSecNeedString(d, * 'i'); if (parmSecNeed.size() > 0) { * sbOut.append(" and requires a level of " + * separateListOfString(parmSecNeed)); } if (secNeed1.size() == 0 && * secNeed2.size() == 0 && parmSecNeed.size() == 0) { * sbOut.append(": no security need is speccified"); } * * outCount++; } * * StringBuilder sb = new StringBuilder(); if (incCount > 0) { if * (outCount > 0) { sb.append(sbInc.toString() + * " while it delegates to " + sbOut.toString() + "."); } else { * sb.append(sbInc.toString() + "."); } } else { if (outCount > 0) { * sb.append("%b" + a.getName() + "% delegates to " + * sbOut.toString() + "."); } } if (sb.length() > 0) { * phrases.add(createParagraph(sb.toString())); } */ } if (phrases.size() != 0) { sectionIntro = "The following description enlists all the delegations from one role/agent to the others. When applicable, security needs expressed over the delegations are enumerated."; section.add(createParagraph(sectionIntro)); String t = "In the " + getProjectName() + " project" + socialDiagRef() + ", we have the following goal delegations:"; section.add(createParagraph(t)); section.add(listParagraphs(phrases)); section.add(createParagraph(ftc.getTable(FigureConstant.DELEGATION_TABLE) + " summarises %igoal delegations%, together with the eventual %isecurity needs%, and the possible %ipreconditions% and %ipostconditions%, which determine when the delegation can take place, and the expected outcome of the delegation, respectively.")); List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Delegator" }); headers.add(new String[] { "Goal" }); headers.add(new String[] { "Delegatee" }); headers.add(new String[] { "Security", "Needs" }); headers.add(new String[] { "Delegation", "Description" }); headers.add(new String[] { "Pre-", "conditions" }); headers.add(new String[] { "Post-", "conditions" }); PdfPTable table = createTable(headers); for (Actor a : selActor) { if (a.getOutgoingDelegations().size() > 0) { PdfPCell cell = getContentCell(); cell.setPhrase(new Phrase(a.getName(), TABLE_CONTENT)); cell.setRowspan(a.getOutgoingDelegations().size()); table.addCell(cell); for (Delegation d : a.getOutgoingDelegations()) { table.addCell(getContentCell(d.getSourceGoal().getName())); table.addCell(getContentCell(d.getTarget().getName())); List<String> sn = buildDelegationSecNeedList(d); Phrase p = null; for (int i = 0; i < sn.size(); i++) { if (i == 0) p = new Phrase(sn.get(i), TABLE_CONTENT_SMALL); else { p.add(Chunk.NEWLINE); p.add(new Phrase(sn.get(i), TABLE_CONTENT_SMALL)); } } PdfPCell c = getContentCell(); c.addElement(p); table.addCell(c); table.addCell(getContentCell(d.getDescription())); table.addCell(getContentCell(d.getPreConditions())); table.addCell(getContentCell(d.getPostConditions())); } } } addTableCaption(table, ftc.getTable(FigureConstant.DELEGATION_TABLE) + " - Goal Delegations and Security Needs"); section.add(table); table.setComplete(true); } else { section.add(createParagraph("In the " + getProjectName() + " project there are no goal delegations taking place for the given agents/roles.")); } section.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSectionDocumentProvisions(Section section) { String sectionIntro = "Stakeholders exchange information by means of documents with other stakeholders. The following description enlists all the provisions from one role/agent representing the stakeholder, to other roles/agents. %iDocument provision% is represented as an arrow from the provider to the providee, with a rectangle representing the document. The security needs expressed over the provisions are described, if applicable. Security needs are specified with the help of labels that appear below the document."; section.add(createParagraph(sectionIntro)); List<Actor> selActor = getDocumentProvisionsActors(); List<Paragraph> phrases = new ArrayList<Paragraph>(); for (Actor a : selActor) { for (Provision p : a.getOutgoingProvisions()) { Paragraph par = createParagraph("%b" + a.getName() + "% provides document %i" + p.getSourceResource().getName() + "% to %b" + p.getTarget().getName() + "%."); List<String> secNeeds = buildProvisionSecNeedList(p); if (secNeeds.size() > 0) { par.add(new Phrase(" The following security needs apply to this provision:")); par.add(Chunk.NEWLINE);// w w w . j a va2 s. co m par.add(new Phrase(separateListOfString(secNeeds) + ".")); } phrases.add(par); } } /* * for (Actor a : selActor) { StringBuilder sbInc = new StringBuilder(); * sbInc.append("%b" + a.getName() + "% is provided by "); int incCount * = 0; for (Provision p : a.getIncomingProvisions()) { if (incCount > * 0) sbInc.append(", and is provided by "); sbInc.append("%i" + * p.getSource().getName() + "% document %i" + * p.getSourceResource().getName() + "%"); if (p.isIntegrity()) { * sbInc.append(" and requires %b" + p.getSource().getName() + * "% to ensure %iintegrity of transmission% over the provision of this document" * ); } * * incCount++; } * * StringBuilder sbOut = new StringBuilder(); int outCount = 0; for * (Provision p : a.getOutgoingProvisions()) { if (outCount > 0) * sbOut.append(", and it provides to "); sbOut.append("%i" + * p.getTarget().getName() + "% document %i" + * p.getSourceResource().getName() + "%"); if (p.isIntegrity()) { * sbInc.append(" and requires %iAvailability% level of " + * p.getAvailabilityValue() + "%"); } outCount++; } * * StringBuilder sb = new StringBuilder(); if (incCount > 0) { if * (outCount > 0) { sb.append(sbInc.toString() + * " while it provides to " + sbOut.toString() + "."); } else { * sb.append(sbInc.toString() + "."); } } else { if (outCount > 0) { * sb.append("%b" + a.getName() + "% provides to " + sbOut.toString() + * "."); } } * * if (sb.length() > 0) { phrases.add(createParagraph(sb.toString())); } * } */ if (phrases.size() != 0) { String s = "In the " + getProjectName() + " project " + socialDiagRef() + ", we have the following %idocument provisions%:"; section.add(createParagraph(s)); section.add(listParagraphs(phrases)); section.add(createParagraph(ftc.getTable(FigureConstant.PROVISION_TABLE) + " summarises the %idocument provisions% for the " + getProjectName() + " project.")); List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Providor" }); headers.add(new String[] { "Document" }); headers.add(new String[] { "Providee" }); headers.add(new String[] { "Security", "Needs" }); headers.add(new String[] { "Provision", "Descr." }); PdfPTable table = createTable(headers); for (Actor a : selActor) { if (a.getOutgoingProvisions().size() > 0) { PdfPCell cell = getContentCell(); cell.setPhrase(new Phrase(a.getName(), TABLE_CONTENT)); cell.setRowspan(a.getOutgoingProvisions().size()); table.addCell(cell); for (Provision p : a.getOutgoingProvisions()) { table.addCell(getContentCell(p.getSourceResource().getName())); table.addCell(getContentCell(p.getTarget().getName())); List<String> sn = buildProvisionSecNeedList(p); Phrase pr = null; for (int i = 0; i < sn.size(); i++) { if (i == 0) pr = new Phrase(sn.get(i), TABLE_CONTENT_SMALL); else { pr.add(Chunk.NEWLINE); pr.add(new Phrase(sn.get(i), TABLE_CONTENT_SMALL)); } } PdfPCell c = getContentCell(); c.addElement(pr); table.addCell(c); table.addCell(getContentCell(p.getDescription())); } } } addTableCaption(table, ftc.getTable(FigureConstant.PROVISION_TABLE) + " - Document Provisions"); section.add(table); table.setComplete(true); } else { section.add(createParagraph("In the " + getProjectName() + " project there are no document provisions taking place for the given agents/roles.")); } section.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildAppendixCChapter(Chapter c, Document d) { c.setTitle(getChapterTitleParagraph("Appendix C")); c.setNumberDepth(0);//from www . j a va2 s . c o m c.setTriggerNewPage(true); String sectionIntro = "STS-ml allows for the specification of security needs over actors interactions. It currently supports a non-exhaustive set of security needs and organisational constraints, namely non-repudiation, redundancy, no-delegation, non-usage, non-modification, non-production, non-disclosure and need-to-know. The purpose of security analysis is to verify whether there are any violations of security needs. As such, it includes defining the rules necessary to detect violations. In the following are provided the details for all the checks performed during security analysis."; c.add(createParagraph(sectionIntro)); List<Paragraph> plist = new ArrayList<Paragraph>(); int kk = 0; for (kk = kk; kk < 4; kk++) { plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } c.add(listParagraphs(plist)); plist.clear(); Paragraph parList = getDefaultParagraph(); com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); list.setListSymbol("\u2022" + " "); list.setSymbolIndent(30f); parList.add(list); parList.setSpacingBefore(0f); parList.setSpacingAfter(0f); list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++]))); com.itextpdf.text.List subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); subList.setListSymbol("\u2022" + " "); subList.setSymbolIndent(15f); for (kk = kk; kk < 10; kk++) { subList.add( new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]))); // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } list.add(subList); c.add(parList); /* * Paragraph actorName = createParagraph(type + "%b" + a.getName() + * "%:"); actorName.setSpacingAfter(5); * * com.itextpdf.text.List list = new * com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); * list.setListSymbol("\u2022" + " "); list.setSymbolIndent(10f); * list.add(new ListItem(actorName)); * * if (sbOut.length() > 0) { com.itextpdf.text.List sublist = new * com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); * sublist.setListSymbol("- "); sublist.setSymbolIndent(30f); * //Paragraph p=createParagraph("%b" + a.getName() + "% " + * sbOut.toString() + "."); Paragraph p = * createParagraph(sbOut.toString() + "."); * * if (sbInc.length() > 0) { p.setSpacingAfter(10); } * * sublist.add(new ListItem(p)); list.add(sublist); */ String text = "Apart from the verification of violations of security needs, security analysis performs checks to verify that actors comply with their authorities. For this, it searches for eventual unauthorised passages of rights. For the time being, the following violations are detected:"; c.add(createParagraph(text)); parList = getDefaultParagraph(); list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); list.setListSymbol("\u2022" + " "); list.setSymbolIndent(30f); parList.add(list); parList.setSpacingBefore(0f); parList.setSpacingAfter(0f); list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++]))); subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); subList.setListSymbol("\u2022" + " "); subList.setSymbolIndent(15f); for (kk = kk; kk < 16; kk++) { subList.add( new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]))); // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } list.add(subList); c.add(parList); text = "As far as organisational constraints are concerned, security analysis verifies that the specification of SoD and BoD constraints can be satisfied in the given model. The satisfaction of role-based SoD and BoD are already covered by the consistency analysis, security analysis deals with goal-based SoD and BoD instead."; c.add(createParagraph(text)); for (kk = kk; kk < SecurityAnalysisTasksNames.ALL_TASKS_NAMES.length; kk++) { plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } c.add(listParagraphs(plist)); c.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private Paragraph getRiskAnalysisDescription(final String analysis) { Paragraph desc = createParagraph("?"); if (analysis.equals(RiskAnalysisTasksNames.THREAT_ANALISIS)) { desc = createParagraph(/*from w w w . j a v a2 s . co m*/ "This analysis starts with the known events, and propagates their impact over goal trees, documents and social relationships. The new discovered elements are treated as threated elements. The analysis ends when no new elements are found."); desc.add(Chunk.NEWLINE); desc.add(new Phrase("The propagation rules are the following:")); List<Paragraph> pr = new ArrayList<Paragraph>(); pr.add(createP( "If the threatened element is a goal, then the following are also threatened: goal's decomposition's parents, porduced document and delegated goals.")); pr.add(createP( "If the threatened element is a document, then the following are also threatened: document's partOf's parents, goals that need or modify the document and if the document is provided the provided goal.")); desc.add(listParagraphs(pr)); } return getAlaysisDescription(analysis, desc); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private Paragraph getAlaysisDescription(String analysisName, Paragraph analysisDesc) { Paragraph res = createParagraph("%b" + analysisName + "% "); res.add(Chunk.NEWLINE); analysisDesc.setSpacingAfter(0);/*from w w w . j a v a 2 s . c o m*/ analysisDesc.setSpacingBefore(0); res.add(analysisDesc); return res; }
From source file:eu.trentorise.smartcampus.citizenportal.service.PdfCreator.java
private static void addTitlePage(Document document) throws DocumentException { Paragraph preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);//from w w w .j a va 2s .c om // Lets write a big header preface.add(new Paragraph("Title of the document", catFont)); addEmptyLine(preface, 1); // Will create: Report generated by: _name, _date preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); addEmptyLine(preface, 3); preface.add(new Paragraph("This document describes something which is very important ", smallBold)); addEmptyLine(preface, 8); preface.add(new Paragraph( "This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).", redFont)); document.add(preface); // Start a new page document.newPage(); }
From source file:Export.CertificadoCargaMaritima.java
public String criarDoc(String numApolice, String numCliente, Contrato c, CargaMaritimaBean cm, String user, String moeda, String arquivo) { try {/*from ww w .jav a 2 s. c o m*/ SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); Font fontUK = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 5.5f, Font.ITALIC); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres2 = 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(Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN)); pCellPolice.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); pTableEmpresaInforImpres1.addCell(pCellPolice); 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.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); PdfPTable pTableTitulo = new PdfPTable(1); Phrase pTitulo = new Phrase("CErtificado Seguro de Carga Maritima".toUpperCase(), fontCorpoNG); pTitulo.add(new Phrase("\nMARINE CARGO CERTIFICATE", fontUK)); PdfPCell cellTitulo = new PdfPCell(pTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); PdfPTable pTableCorpoUm = new PdfPTable(new float[] { 100 }); PdfPTable pTableCorpoDois = new PdfPTable(new float[] { 50, 50 }); PdfPTable pTableCorpoTres = new PdfPTable(new float[] { 100 }); PdfPCell cellCorpopUm = new PdfPCell(); cellCorpopUm.setBorder(0); PdfPCell cellCorpopDois1 = new PdfPCell(); cellCorpopDois1.setBorder(0); PdfPCell cellCorpopDois2 = new PdfPCell(); cellCorpopDois2.setBorder(0); PdfPCell cellCorpopTres = new PdfPCell(); cellCorpopTres.setBorder(0); Paragraph pCorpoUm1 = new Paragraph( "Certificado de seguro emitido sob contracto aberto n".toUpperCase(), fontCorpoN); pCorpoUm1.add( new Phrase("\ncertificate OF insurance issued under contract open No.".toUpperCase(), fontUK)); Paragraph pCorpoUm2 = new Paragraph("mbito da cobertura: ".toUpperCase(), fontCorpoN); pCorpoUm2.add(new Phrase("\nSCOPE OF COVER", fontUK)); Paragraph pCorpoUm3 = new Paragraph( "Este certificado atesta que a Companhia tem as mencionadas, sob seguro para viagem (s) e valore (s) declarados em favor de", fontCorpo); pCorpoUm3.add(new Phrase( "\nTHIS IS TO CERTIFY THAT THE COMPANY HAS INSURED THE UNDER MENTIONED GOODS FOR THE VOYGE (S) AND VALUE (S) STATED ON BEHALF OF", fontUK)); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); cellCorpopUm.addElement(pCorpoUm3); pTableCorpoUm.addCell(cellCorpopUm); Paragraph pCorpoDois11 = new Paragraph("Taxa Maritima: ", fontCorpo); pCorpoDois11.add(new Phrase("\nMARINE RATE", fontUK)); Paragraph pCorpoDois12 = new Paragraph("Taxa Guerra: ", fontCorpo); pCorpoDois12.add(new Phrase("\nWAR RATE", fontUK)); cellCorpopDois1.addElement(pCorpoDois11); cellCorpopDois1.addElement(pCorpoDois12); pTableCorpoDois.addCell(cellCorpopDois1); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); Paragraph pCorpoDois21 = new Paragraph("Nota de Bebito: ", fontCorpo); pCorpoDois21.add(new Phrase("\nDEBIT NOTE NO", fontUK)); Paragraph pCorpoDois22 = new Paragraph("Total de Prmio: ", fontCorpo); pCorpoDois22.add(new Phrase("\nGROSS PREMIUM", fontUK)); cellCorpopDois2.addElement(pCorpoDois21); cellCorpopDois2.addElement(pCorpoDois22); pTableCorpoDois.addCell(cellCorpopDois2); Paragraph pCorpoTres1 = new Paragraph("Taxa Superintendente: ", fontCorpo); pCorpoTres1.add(new Phrase("\nSuperintendent RATE".toUpperCase(), fontUK)); Paragraph pCorpoTres2 = new Paragraph("Taxa Interna de Trnsito: ", fontCorpo); pCorpoTres2.add(new Phrase("\nINLANDTraffic Rate", fontUK)); Paragraph pCorpoTres3 = new Paragraph("Taxa Total: ", fontCorpo); pCorpoTres3.add(new Phrase("\nTOTAL RATE", fontUK)); Paragraph pCorpoTres4 = new Paragraph("Segurado: ", fontCorpo); pCorpoTres4.add(new Phrase("\nInsured".toUpperCase(), fontUK)); Paragraph pCorpoTres5 = new Paragraph("Meio de Transporte: " + cm.getCargaMaritima().getFormaEnvio(), fontCorpo); pCorpoTres5.add(new Phrase("\nMODE OF CONVEYANCE", fontUK)); //Paragraph pCorpoTres6_1 = new Paragraph("Medadoria Assegurada: ",fontCorpo); Paragraph pCorpoTres6 = new Paragraph("De " + cm.getCargaMaritima().getPaisOrigem() + " Para: " + cm.getCargaMaritima().getPaisDestino(), fontCorpo); pCorpoTres6.add(new Phrase("\nFROM TO", fontUK)); Paragraph pCorpoTres7 = new Paragraph("Juros: ", fontCorpo); pCorpoTres7.add(new Phrase("\nINTEREST", fontUK)); Paragraph pCorpoTres8 = new Paragraph("Valor Segurado: ", fontCorpo); pCorpoTres8.add(new Phrase("\nINSURED VALUE", fontUK)); Paragraph pCorpoTres9 = new Paragraph( "CONDIES: Sujeitas as seguintes clsulas e garantias (Ver anexo A)", fontCorpoN); pCorpoTres9.add(new Phrase( "\nCONDITIONS : Subject to the following clsulas and warranteis (SEE APPENDICIX A)", fontUK)); Paragraph pCorpoTres10 = new Paragraph( "No caso de perda ou dano que se presume a companhia ser reponsvel, deve-se comunicar de imediato NICOM SEGUROS STP" + " para ser feita a vistoria (Por favor volte).", fontCorpo); pCorpoTres10.add(new Phrase( "\nIn the event of loss or damage for which company is presumed to be liable, immediate resquest for survey must be made to NICON SEGUROS STP (PLEASE TURN OVER).", fontUK)); Paragraph pCorpoTres11 = new Paragraph( "No caso de perda ou dano este certificado, depois de autenticado, deve ser anexo a reclamao acompanhado" + " de relatrio de auditoria e da factura original do desembarque, a cpia autenticada ou original da factura e uaisquer outros documentos relativo.", fontCorpo); pCorpoTres10.add(new Phrase( "\nIn case of loss or damage this certificate, must be annexed to the claim note accompaneid by the repost, original bill of landing, true copy" + " or original invoice and any other relevant documenent.", fontUK)); Paragraph pCorpoTres12 = new Paragraph(); Phrase p1 = new Phrase("Nota: ", fontCorpoN); Phrase p2 = new Phrase( "A Empresa compromete-se a emitir uma aplice que cobre as mercadorias descritas no pedido", fontCorpo); Phrase p3 = new Phrase( "\nThe Company undertakes to issue a policy covering the good described herein on request.", fontUK); pCorpoTres12.add(p1); pCorpoTres12.add(p2); pCorpoTres12.add(p3); cellCorpopTres.addElement(pCorpoTres1); cellCorpopTres.addElement(pCorpoTres2); cellCorpopTres.addElement(pCorpoTres3); cellCorpopTres.addElement(pCorpoTres4); cellCorpopTres.addElement(pCorpoTres5); //cellCorpopTres.addElement(pCorpoTres6_1); cellCorpopTres.addElement(pCorpoTres6); cellCorpopTres.addElement(pCorpoTres7); cellCorpopTres.addElement(pCorpoTres8); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres9); cellCorpopTres.addElement(pCorpoTres10); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres11); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres12); pTableCorpoTres.addCell(cellCorpopTres); PdfPTable pTableAssinaturaTitulo = new PdfPTable(1); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); Paragraph pUK = new Paragraph("", fontCorpo); pUK.add(new Phrase("Assinaturas", fontCorpoN)); pUK.add(new Phrase("Signature", fontUK)); PdfPCell cellAssinatora = new PdfPCell(pUK); cellAssinatora.setBorder(0); cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha1 = new PdfPCell( new Phrase("___________________________________".toUpperCase(), fontCorpo)); celllinha1.setBorder(0); celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha2 = new PdfPCell( new Phrase("___________________________________".toUpperCase(), fontCorpo)); celllinha2.setBorder(0); celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER); pUK = new Paragraph("", fontCorpo); pUK.add(new Phrase("Pela NICON SEGUROS STP", fontCorpoN)); pUK.add(new Phrase("For NICON SEGUROS STP", fontUK)); PdfPCell celllinha11 = new PdfPCell(pUK); celllinha11.setBorder(0); celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER); pUK = new Paragraph("", fontCorpo); pUK.add(new Phrase("O Segurado", fontCorpoN)); pUK.add(new Phrase("Insured", fontUK)); PdfPCell celllinha21 = new PdfPCell(pUK); celllinha21.setBorder(0); celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER); pTableAssinaturaTitulo.addCell(cellAssinatora); pTableAssinatura.addCell(celllinha1); pTableAssinatura.addCell(celllinha2); pTableAssinatura.addCell(celllinha11); pTableAssinatura.addCell(celllinha21); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 35f, 5f); File f = new File(arquivo + "/" + user + "/Seguro Carga Maritima/"); f.mkdirs(); String Ddata = sdf.format(new Date()); f = new File(f.getAbsoluteFile() + "/" + "Certificado Carga Maritima " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Carga Maritima/" + "Certificado Carga Maritima " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(f); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); if (MarcaDAgua.isSimulation) { MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical(); writer.setPageEvent(v); } if (MarcaDAgua.isCanceled) { MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical(); writer.setPageEvent(v); } documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableCorpoUm); documento.add(pTableNull); documento.add(pTableCorpoDois); documento.add(pTableCorpoTres); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinaturaTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinatura); documento.close(); // PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); // //PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); // // printPdf.print(); } catch (BadElementException | IOException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } return reString; }
From source file:Export.CertificadoMaritimo.java
public String criarDoc(String numApolice, String numCliente, MaritimoBean mb, Contrato c, String user, String moeda, String arquivo) { try {//from w w w. j a v a 2s .co m SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres2 = 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(Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN)); pCellPolice.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); pTableEmpresaInforImpres1.addCell(pCellPolice); 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.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); PdfPTable pTableTitulo = new PdfPTable(1); Phrase pTitulo = new Phrase("CErtificado Seguro de Maritimo".toUpperCase(), fontCorpoNG); PdfPCell cellTitulo = new PdfPCell(pTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); PdfPTable pTableCorpoUm = new PdfPTable(new float[] { 100 }); PdfPTable pTableCorpoDois = new PdfPTable(new float[] { 50, 50 }); PdfPTable pTableCorpoTres = new PdfPTable(new float[] { 100 }); PdfPCell cellCorpopUm = new PdfPCell(); cellCorpopUm.setBorder(0); PdfPCell cellCorpopDois1 = new PdfPCell(); cellCorpopDois1.setBorder(0); PdfPCell cellCorpopDois2 = new PdfPCell(); cellCorpopDois2.setBorder(0); PdfPCell cellCorpopTres = new PdfPCell(); cellCorpopTres.setBorder(0); Paragraph pCorpoUm1 = new Paragraph( "Certificado de seguro emitido sob contracto aberto n".toUpperCase(), fontCorpoN); Paragraph pCorpoUm2 = new Paragraph("Abimto de Cortura: ".toUpperCase(), fontCorpoN); Paragraph pCorpoUm3 = new Paragraph( "Este certificado atesta que a Companhia tem as mencionadas, sob seguro para viagem (s) e valore (s) declarados em favor de", fontCorpo); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); cellCorpopUm.addElement(pCorpoUm3); pTableCorpoUm.addCell(cellCorpopUm); Paragraph pCorpoDois11 = new Paragraph("Taxa Maritima: ", fontCorpo); Paragraph pCorpoDois12 = new Paragraph("Taxa Guerra: ", fontCorpo); cellCorpopDois1.addElement(pCorpoDois11); cellCorpopDois1.addElement(pCorpoDois12); pTableCorpoDois.addCell(cellCorpopDois1); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); Paragraph pCorpoDois21 = new Paragraph("Nota de Bebito: ", fontCorpo); Paragraph pCorpoDois22 = new Paragraph("Total de Prmio: ", fontCorpo); cellCorpopDois2.addElement(pCorpoDois21); cellCorpopDois2.addElement(pCorpoDois22); pTableCorpoDois.addCell(cellCorpopDois2); Paragraph pCorpoTres1 = new Paragraph("Taxa Superintendente: ", fontCorpo); Paragraph pCorpoTres2 = new Paragraph("Taxa Interna de Trnsito: ", fontCorpo); Paragraph pCorpoTres3 = new Paragraph("Taxa Total: ", fontCorpo); Paragraph pCorpoTres4 = new Paragraph("Segurado: ", fontCorpo); Paragraph pCorpoTres5 = new Paragraph("Meio de Transporte: ", fontCorpo); Paragraph pCorpoTres6 = new Paragraph("De Para: ", fontCorpo); Paragraph pCorpoTres7 = new Paragraph("Juros: ", fontCorpo); Paragraph pCorpoTres8 = new Paragraph("Valor Segurado: ", fontCorpo); Paragraph pCorpoTres9 = new Paragraph( "CONDIES: Sujeitas as seguintes clsulas e garantias (Ver anexo A)", fontCorpoN); Paragraph pCorpoTres10 = new Paragraph( "No caso de perda ou dano que se presume a companhia ser reponsvel, deve-se comunicar de imediato NICOM SEGUROS STP" + " para ser feita a vistoria (Por favor volte).", fontCorpo); Paragraph pCorpoTres11 = new Paragraph( "No caso de perda ou dano este certificado, depois de autenticado, deve ser anexo a reclamao acompanhado" + " de relatrio de auditoria e da factura original do desembarque, a cpia autenticada ou original da factura e uaisquer outros documentos relativo.", fontCorpo); Paragraph pCorpoTres12 = new Paragraph(); Phrase p1 = new Phrase("Nota: ", fontCorpoN); Phrase p2 = new Phrase( "A Empresa compromete-se a emitir uma aplice que cobre as mercadorias descritas no pedido", fontCorpo); pCorpoTres12.add(p1); pCorpoTres12.add(p2); cellCorpopTres.addElement(pCorpoTres1); cellCorpopTres.addElement(pCorpoTres2); cellCorpopTres.addElement(pCorpoTres3); cellCorpopTres.addElement(pCorpoTres4); cellCorpopTres.addElement(pCorpoTres5); cellCorpopTres.addElement(pCorpoTres6); cellCorpopTres.addElement(pCorpoTres7); cellCorpopTres.addElement(pCorpoTres8); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres9); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres10); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres11); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres12); pTableCorpoTres.addCell(cellCorpopTres); PdfPTable pTableAssinaturaTitulo = new PdfPTable(1); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); PdfPCell cellAssinatora = new PdfPCell(new Phrase("Assinaturas e Carimbo".toUpperCase(), fontCorpoN)); cellAssinatora.setBorder(0); cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha1 = new PdfPCell( new Phrase("___________________________________".toUpperCase(), fontCorpo)); celllinha1.setBorder(0); celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha2 = new PdfPCell( new Phrase("___________________________________".toUpperCase(), fontCorpo)); celllinha2.setBorder(0); celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha11 = new PdfPCell(new Phrase("para nicon Seguro sa stp".toUpperCase(), fontCorpoP)); celllinha11.setBorder(0); celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha21 = new PdfPCell(new Phrase("o segurado ".toUpperCase(), fontCorpoP)); celllinha21.setBorder(0); celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER); pTableAssinaturaTitulo.addCell(cellAssinatora); pTableAssinatura.addCell(celllinha1); pTableAssinatura.addCell(celllinha2); pTableAssinatura.addCell(celllinha11); pTableAssinatura.addCell(celllinha21); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 35f, 5f); // File f= new File("Documentos\\"+user+"\\Seguro Maritimo\\"); // f.mkdirs(); // f =new File(f.getAbsoluteFile()+"\\"+"Certificado Seguro Maritimo "+sdf.format(new Date())+".pdf"); File f = new File(arquivo + "/" + user + "/Seguro Maritimo/"); f.mkdirs(); String Ddata = sdf.format(new Date()); f = new File(f.getAbsoluteFile() + "/" + "Certificado Seguro Maritimo " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Maritimo/" + "Certificado Seguro Maritimo " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(f); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); if (MarcaDAgua.isSimulation) { MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical(); writer.setPageEvent(v); } if (MarcaDAgua.isCanceled) { MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical(); writer.setPageEvent(v); } documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableCorpoUm); documento.add(pTableNull); documento.add(pTableCorpoDois); documento.add(pTableCorpoTres); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinaturaTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinatura); documento.close(); // PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); // //PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); // // printPdf.print(); } catch (BadElementException | IOException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } return reString; }
From source file:Export.CertificadoViatura.java
public String criarDoc(String numApolice, String numCliente, Contrato c, VeiculoBean vf, String user, String moeda, String arquivo) { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH'.'mm'.'ss"); SimpleDateFormat sdfPT = new SimpleDateFormat("dd/MM/yyyy"); try {/*from w ww . j a v a 2s .c o m*/ Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(2f, 2f, 35f, 5f); // File ff= new File("Documentos\\"+user+"\\Seguro Automovel\\"); // ff.mkdirs(); // ff =new File(ff.getAbsoluteFile()+"\\"+"Certificado Seguro Automovel "+sdf.format(new Date())+".pdf"); File ff = new File(arquivo + "/" + user + "/Seguro Automovel/"); ff.mkdirs(); String Ddata = sdf.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Certificado Seguro Automovel " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Automovel/" + "Certificado Seguro Automovel " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(ff); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); if (MarcaDAgua.isSimulation) { MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical(); writer.setPageEvent(v); } if (MarcaDAgua.isCanceled) { MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical(); writer.setPageEvent(v); } // MyFooter event = new MyFooter(); // writer.setPageEvent(event); Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.5f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.5f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 11f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); Font fontUK = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 5f, Font.ITALIC); documento.open(); int total = vf.getInfo().size(); int i = 0; for (Veiculo v : vf.getInfo()) { i++; PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f }); pTableEmpresaPricipal.setWidthPercentage(93f); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); // PdfPTable pTableEmpresaInforImpres2 = 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(Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN)); pCellPolice.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(190f, 100f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); pTableEmpresaInforImpres1.addCell(pCellPolice); 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.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); PdfPTable pTableTitulo = new PdfPTable(1); Paragraph PTitulo = new Paragraph(new Phrase("", fontCorpo)); Phrase pTitulo = new Phrase("Certificado Seguro de automvel".toUpperCase(), fontCorpoNG); Phrase pTituloUK = new Phrase("\nCertificate of motor insurance".toUpperCase(), fontUK); PTitulo.add(pTitulo); PTitulo.add(pTituloUK); PdfPCell cellTitulo = new PdfPCell(PTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); PdfPTable pTableDetalhes = new PdfPTable(new float[] { 55, 45 }); pTableDetalhes.setWidthPercentage(93f); Paragraph pNunCetificado = new Paragraph(new Phrase("", fontCorpo)); pNunCetificado.add(new Phrase("1. Certificado: ", fontCorpo)); pNunCetificado.add(new Phrase(v.getCertificado() == null || v.getCertificado().equals("") ? "" : v.getCertificado().toUpperCase(), fontCorpoN)); pNunCetificado.add(new Phrase("\n1. Certificate NO".toUpperCase(), fontUK)); pNunCetificado.setPaddingTop(0f); ClienteI ci = new ClienteI(numCliente); Paragraph pNomeSegurado = new Paragraph(new Phrase("", fontCorpo)); pNomeSegurado.add(new Phrase("3. Segurado: ", fontCorpo)); pNomeSegurado.add(new Phrase(ci.getNOME_().toUpperCase(), fontCorpoN)); pNomeSegurado.add(new Phrase("\n3. Insured".toUpperCase(), fontUK)); pNomeSegurado.setPaddingTop(0f); Paragraph pMarca = new Paragraph(new Phrase("", fontCorpo)); pMarca.add(new Phrase("5. Marca do Veiculo: ", fontCorpo)); pMarca.add(new Phrase((v.getMarca() == null) ? " " : v.getMarca().toUpperCase(), fontCorpoN)); pMarca.add(new Phrase("\n5. vehicle mark".toUpperCase(), fontUK)); // pMarca.setPaddingTop(1f); Paragraph pModelo = new Paragraph(new Phrase("", fontCorpo)); pModelo.add(new Phrase("7. Modelo do Veiculo: ", fontCorpo)); pModelo.add(new Phrase((v.getModelo() == null) ? " " : v.getModelo().toUpperCase(), fontCorpoN)); pModelo.add(new Phrase("\n7. Model Vehicle".toUpperCase(), fontUK)); pModelo.setPaddingTop(0f); Paragraph pPeriodo = new Paragraph(new Phrase("", fontCorpo)); pPeriodo.add(new Phrase("9. Perodo de Seguro - De: ", fontCorpo)); pPeriodo.add(new Phrase( (sdfPT.format(c.getDataInicio()) + " " + sdfPT.format(c.getDataFim())).toUpperCase(), fontCorpoN)); pPeriodo.add(new Phrase("\n9. period of insurance - from to".toUpperCase(), fontUK)); pPeriodo.setPaddingTop(0f); Paragraph pCategoria = new Paragraph(new Phrase("", fontCorpo)); pCategoria.add(new Phrase("11. Categoria/Uso do Veculo: ", fontCorpo)); pCategoria.add(new Phrase(" ", fontCorpoN)); pCategoria.add(new Phrase("\n11. category/use of vehicle".toUpperCase(), fontUK)); pCategoria.setPaddingTop(0f); PdfPCell cellDetalhesRi = new PdfPCell(); cellDetalhesRi.addElement(pNunCetificado); cellDetalhesRi.addElement(pNomeSegurado); cellDetalhesRi.addElement(pMarca); cellDetalhesRi.addElement(pModelo); cellDetalhesRi.addElement(pPeriodo); cellDetalhesRi.addElement(pCategoria); Paragraph pNumApolice = new Paragraph(new Phrase("", fontCorpo)); pNumApolice.add(new Phrase("2. Aplice N ", fontCorpo)); pNumApolice.add(new Phrase(numApolice, fontCorpoN)); pNumApolice.add(new Phrase("\n2. policy no".toUpperCase(), fontUK)); pNumApolice.setPaddingTop(0f); Paragraph pOcupacaoSegurado = new Paragraph(new Phrase("", fontCorpo)); pOcupacaoSegurado.add(new Phrase("4. Ocupao do Seguros: ", fontCorpo)); pOcupacaoSegurado.add(new Phrase(ci.getPROFISSAO_().toUpperCase(), fontCorpoN)); pOcupacaoSegurado.add(new Phrase("\n4. insured's occupation".toUpperCase(), fontUK)); pOcupacaoSegurado.setPaddingTop(0f); Paragraph pNumChassi = new Paragraph(new Phrase("", fontCorpo)); pNumChassi.add(new Phrase("6. N de Chassi/Motor: ", fontCorpo)); pNumChassi.add(new Phrase(v.getChassi() + ((v.getNumMotor() == null || v.getNumMotor().isEmpty()) ? " " : "/" + v.getNumMotor()), fontCorpoN)); pNumChassi.add(new Phrase("\n6 EnGINE", fontUK)); pNumChassi.setPaddingTop(0f); Paragraph pDataFabrico = new Paragraph(new Phrase("", fontCorpo)); pDataFabrico.add(new Phrase("8. Data de Fabrico: ", fontCorpo)); pDataFabrico.add(new Phrase(((v.getAnoFabrico() == null) ? " " : v.getAnoFabrico()), fontCorpo)); pDataFabrico.add(new Phrase("\n8. Date of manofacturing", fontUK)); pDataFabrico.setPaddingTop(0f); Paragraph pTipoCobertura = new Paragraph(new Phrase("", fontCorpo)); pTipoCobertura.add(new Phrase("10. Tipo de Cobertura: ", fontCorpo)); pTipoCobertura .add(new Phrase( ((v.getTipoCobertura() != null) ? (vf.getVeiculo().getTipoCobertura().equals("41") ? "Contra Terceiros".toUpperCase() : (vf.getVeiculo().getTipoCobertura().equals("42") ? "CONTRA Todos os riscos".toUpperCase() : (vf.getVeiculo().getTipoCobertura().equals("43") ? "Compreensivo limitado".toUpperCase() : vf.getVeiculo().getTipoCobertura()))) : " "), fontCorpoN)); pTipoCobertura.add(new Phrase("\n10. Tipo of Cover".toUpperCase(), fontUK)); pTipoCobertura.setPaddingTop(0f); PdfPCell cellDetalhesLe = new PdfPCell(); cellDetalhesLe.addElement(pNumApolice); cellDetalhesLe.addElement(pOcupacaoSegurado); cellDetalhesLe.addElement(pNumChassi); cellDetalhesLe.addElement(pDataFabrico); cellDetalhesLe.addElement(pTipoCobertura); pTableDetalhes.addCell(cellDetalhesRi); pTableDetalhes.addCell(cellDetalhesLe); String f = ""; Paragraph para = new Paragraph(new Phrase("", fontCorpo)); para.add(new Phrase("12. Pessoas ou Classe de Pessoas Habilitadas Para Conduzir", fontCorpoN)); para.add(new Phrase("\n12. Persons or Class of Persons Entitled to Drive", fontUK)); pTableDetalhes.addCell(new PdfPCell(para)); para = new Paragraph(new Phrase("", fontCorpo)); para.add(new Phrase("14. Categorias/Uso de Veculos", fontCorpoN)); para.add(new Phrase("\n14. Categories / Use of Vehicles", fontUK)); pTableDetalhes.addCell(new PdfPCell(para)); Paragraph p11 = new Paragraph(new Phrase("", fontCorpo)); p11.add(new Phrase( "Qualquer pessoa que conduza sob a ordem do detentor da aplice ou com a sua permisso:", fontCorpo)); p11.add(new Phrase("\nAny person who is driving on the policy holder's or with his permission", fontUK)); p11.setPaddingTop(0f); Paragraph p12 = new Paragraph(new Phrase("", fontCorpo)); p12.add(new Phrase( "Desde que o/a condutor/a esteja habilitado/a para conduzir de acordo com a licena/normas que regulam " + "a conduo de veculos a motor ou instrues para conduo lhe tenha sido passada e no esteja impedido de conduzir por" + " ordem do tribunal ou por alguma outra razo.", fontCorpo)); p12.add(new Phrase( "\nProvided that the person diving is permitted in accodance with the licensing or outher laws or regulations to dive the" + "motor vehicles or has been premitted and is not disiqualified by order of a court of law or reason of any enactment or regulation in that behalf from diving such motor vehice", fontUK)); p12.setPaddingTop(0f); Paragraph p13 = new Paragraph(new Phrase("", fontCorpo)); p13.add(new Phrase("13. Limite para uso:", fontCorpoN)); p13.add(new Phrase("\n13. Limitation as to use", fontUK)); p13.setPaddingTop(0f); Paragraph p14 = new Paragraph(new Phrase("", fontCorpo)); p14.add(new Phrase(" - Usado apenas como descrito na categoria aqui indicada.", fontCorpo)); p14.add(new Phrase("\n - Used only as prescribed under the applicable category stated there in.", fontUK)); p14.setPaddingTop(0f); Paragraph p15 = new Paragraph(new Phrase("", fontCorpo)); p15.add(new Phrase( " - Em todo caso, a aplice no cobre corridas, prova de segurana teste de velocidade, nem para qualquer outro propsito relacionado com a venda do automvel.", fontCorpo)); p15.add(new Phrase( "\n - In all cases, the policy does not cover racing, pace-making, reliability trial, speed testing, nor use for any purpose in connection with the trade", fontUK)); p15.setPaddingTop(0f); cellDetalhesRi = new PdfPCell(); cellDetalhesRi.addElement(p11); cellDetalhesRi.addElement(p12); cellDetalhesRi.addElement(p13); cellDetalhesRi.addElement(p14); cellDetalhesRi.addElement(p15); Paragraph p21 = new Paragraph(new Phrase("", fontCorpo)); p21.add(new Phrase("CATEGORIA 1 ", fontCorpoN)); p21.add(new Paragraph( "- Veculos usados para actividade social, domstica e de lazer e do segurado incluindo uso comercial.", fontCorpo)); p21.add(new Phrase( "Vehicles used for social, domestic and pleasure including business use of the insured.", fontUK)); p21.setPaddingTop(0f); Paragraph p22 = new Paragraph(new Phrase("", fontCorpo)); p22.add(new Phrase("CATEGORIA 2 ", fontCorpoN)); p22.add(new Paragraph("- Veculo pertence ao segurado e usado no transporte de mercadorias.", fontCorpo)); p22.add(new Phrase("Vehicle used for transportation of good and belonging to the insured", fontUK)); p22.setPaddingTop(0f); Paragraph p23 = new Paragraph(new Phrase("", fontCorpo)); p23.add(new Phrase("CATEGORIA 3 ", fontCorpoN)); p23.add(new Paragraph( "- Veculos alugados utilizados no transporte Comercial de mercadorias pertencente terceiros.", fontCorpo)); p23.add(new Phrase( "Vehicles used for commercial transportation of good belonging to third parteis fare paying.", fontUK)); p23.setPaddingTop(0f); Paragraph p24 = new Paragraph(new Phrase("", fontCorpo)); p24.add(new Phrase("CATEGORIA 5 ", fontCorpoN)); p24.add(new Paragraph( "- Veculos a motor com duas ou trs rodas para o transporte pblico de passageiro (mediante pagamento de bilhetes).", fontCorpo)); p24.add(new Phrase("Motor vehicles with two or three wheels for carrying fare paying pessengers.", fontUK)); p24.setPaddingTop(0f); Paragraph p25 = new Paragraph(new Phrase("", fontCorpo)); p25.add(new Phrase("CATEGORIA 6-10 ", fontCorpoN)); p25.add(new Paragraph( "- Veculos para fins especiais: Garagem (6), Escola de Conduo (7), Para Aluguer sem motorista (8), Veculo Pesado (9) e Ambulncia, Transporte de distribuio de mercadoria, etc. (10).", fontCorpo)); p25.add(new Phrase( "To special purposes vehicles: Garage (6) Driving School (7) Haring without driver ( 8) , Heavy trucks ( 9) and ambulance, refuse disposal vans etc. ( 10).", fontUK)); p25.setPaddingTop(0f); cellDetalhesLe = new PdfPCell(); cellDetalhesLe.addElement(p21); cellDetalhesLe.addElement(p22); cellDetalhesLe.addElement(p23); cellDetalhesLe.addElement(p24); cellDetalhesLe.addElement(p25); pTableDetalhes.addCell(cellDetalhesRi); pTableDetalhes.addCell(cellDetalhesLe); PdfPTable pTableArtigo = new PdfPTable(1); pTableArtigo.setWidthPercentage(93f); Paragraph pArtigoCetificado = new Paragraph(new Phrase("", fontCorpo)); pArtigoCetificado.add(new Phrase( "O Contrato de seguro cessa, nos termos da legislao em vigor, os efeitos s 24 horas do dia da alienao do veculo.", fontCorpo)); pArtigoCetificado.add(new Phrase( "\nThe insurance contract ceases, according to law in force, from its effects from 24 hours from the date of alienation of the vehicle.", fontUK)); PdfPCell cellArtigoCetificado = new PdfPCell(pArtigoCetificado); cellArtigoCetificado.setBorder(0); Paragraph pLeis = new Paragraph(new Phrase("", fontCorpo)); pLeis.add(new Phrase( "Este certificado foi emitido em conformidade com os Artigos 1 a 36, lei n 30/2000 da Repblica Democrtica de So Tom e Prncipe e que institui a existncia de uma cobertura pelo seguro", fontCorpo)); pLeis.add(new Phrase( "\nThis certificate is issurd in pursuat to the prevision of Articles 1 to 36 , Law No. 30/2000 of the Democratic Republic of Sao Tome and Principe and it constitutes the existence of an insurance cover", fontUK)); PdfPCell cellLeis = new PdfPCell(pLeis); cellLeis.setBorder(0); pTableArtigo.addCell(cellArtigoCetificado); pTableArtigo.addCell(cellLeis); PdfPTable pTableAssinaturaTitulo = new PdfPTable(1); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); PdfPCell cellAssinatora = new PdfPCell( new Phrase("Assinaturas e Carimbo".toUpperCase(), fontCorpoN)); cellAssinatora.setBorder(0); cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha1 = new PdfPCell( new Phrase("___________________________________".toUpperCase(), fontCorpo)); celllinha1.setBorder(0); celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha2 = new PdfPCell( new Phrase("___________________________________".toUpperCase(), fontCorpo)); celllinha2.setBorder(0); celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha11 = new PdfPCell(new Phrase("Nicon Seguros sa STP".toUpperCase(), fontCorpoP)); celllinha11.setBorder(0); celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha21 = new PdfPCell(new Phrase("o segurado ".toUpperCase(), fontCorpoP)); celllinha21.setBorder(0); celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell assinaturaUK = new PdfPCell( new Phrase("Signature of Insurer and stamp".toUpperCase(), fontUK)); assinaturaUK.setBorder(0); assinaturaUK.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); assinaturaUK.setColspan(2); pTableAssinaturaTitulo.addCell(cellAssinatora); pTableAssinatura.addCell(celllinha1); pTableAssinatura.addCell(celllinha2); pTableAssinatura.addCell(celllinha11); pTableAssinatura.addCell(celllinha21); pTableAssinatura.addCell(assinaturaUK); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableDetalhes); documento.add(pTableNull); documento.add(pTableArtigo); documento.add(pTableNull); documento.add(pTableAssinaturaTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinatura); if (i != total) documento.newPage(); } documento.close(); // PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); // //PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); // // printPdf.print(); } catch (BadElementException | IOException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } return reString; }
From source file:Export.DocNotaCredito.java
@SuppressWarnings("CallToPrintStackTrace") private void docSeguros(String nomeSeguro, String interCod, String user, String arquivo, int idResseguro, TypeNotaCredito tnc) {/*from w w w. j a v a 2 s.co m*/ String reString; try { Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f); Font fontLinha = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 0.000000358f); Font fontCabecalhoS = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontNull = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f); Font fontMenor = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 3f); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 }); pTableEmpresaPricipal.setWidthPercentage(95); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres3 = new PdfPTable(2); PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(2); PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1); DataResseguro resS = new DataResseguro(); HashMap<String, Object> map = new LinkedHashMap<>(); if (tnc == TypeNotaCredito.RESEGURO) { resS = DataReseguro.getDadosReseguro(idResseguro); } else { map = loadNotaConta(); } PdfPTable pTableFatura = new PdfPTable(new float[] { 80, 20 }); PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoN)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); PdfPCell pCellCapital = new PdfPCell(new Phrase(Empresa.CAPITALSOCIAL, fontCabecalhoN)); pCellCapital.setBorder(0); PdfPCell pCellPolice = new PdfPCell(new Phrase( Empresa.APOLICE + ((TypeNotaCredito.RESEGURO == tnc) ? resS.getAPOLICE() : map.get(APOLICE)), fontCabecalhoN)); pCellPolice.setBorder(0); PdfPCell pCellDebNF = new PdfPCell(new Phrase("Cre. N", fontCabecalhoS)); pCellDebNF.setHorizontalAlignment(Element.ALIGN_RIGHT); pCellDebNF.setBorder(0); PdfPCell pCellDebN = new PdfPCell(new Phrase( ((TypeNotaCredito.RESEGURO == tnc) ? resS.getIDSEGURO() : map.get(ID) + ""), fontCabecalhoS)); pCellDebN.setHorizontalAlignment(Element.ALIGN_CENTER); pCellDebN.setBorder(0); PdfPCell pCellInterCoF = new PdfPCell(new Phrase("Inter COD:", fontCabecalhoS)); pCellInterCoF.setHorizontalAlignment(Element.ALIGN_RIGHT); pCellInterCoF.setBorder(0); PdfPCell pCellInterCo = new PdfPCell(new Phrase(interCod, fontCabecalhoS)); pCellInterCo.setHorizontalAlignment(Element.ALIGN_CENTER); pCellInterCo.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 100f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); pTableEmpresaInforImpres2.addCell(pCellCapital); pTableEmpresaInforImpres2.addCell(pCellPolice); pTableEmpresaInforImpres3.addCell(pCellDebNF); pTableEmpresaInforImpres3.addCell(pCellDebN); pTableEmpresaInforImpres3.addCell(pCellInterCoF); pTableEmpresaInforImpres3.addCell(pCellInterCo); PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2); cellTabela1.setBorder(0); pTableEmpresaInforImpres4.addCell(cellTabela1); PdfPCell cellTabela2 = new PdfPCell(pTableEmpresaInforImpres3); cellTabela2.setBorder(0); pTableEmpresaInforImpres4.addCell(cellTabela2); PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1); cellTabela3.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela3); PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4); cellTabela4.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela4); PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5); cellTabela5.setBorder(0); pTableEmpresaPricipal.addCell(cellTabela5); PdfPCell cellTabela6 = new PdfPCell(imageEmpresa); cellTabela6.setBorder(0); cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT); pTableEmpresaPricipal.addCell(cellTabela6); // PdfPTable pTableLinha = new PdfPTable(1); pTableLinha.setWidthPercentage(95); PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha)); linha.setBorderWidthTop(0.5f); linha.setBorderWidthBottom(0); linha.setBorderWidthLeft(0); linha.setBorderWidthRight(0); pTableLinha.addCell(linha); PdfPTable pTableCorpoEndTitile = new PdfPTable(new float[] { 100 }); pTableCorpoEndTitile.setWidthPercentage(95); PdfPCell cellCorpoEndTitile = new PdfPCell(); Paragraph paragraphCorpoEndTitile = new Paragraph(); Paragraph titile = new Paragraph("NOTA DE CREDITO", fontCabecalhoN); titile.setAlignment(Paragraph.ALIGN_CENTER); PdfPTable pTableNumNota = new PdfPTable(new float[] { 100f }); Paragraph titileSub = new Paragraph(nomeSeguro, fontCabecalhoN); titileSub.setAlignment(Paragraph.ALIGN_CENTER); paragraphCorpoEndTitile.add(titile); if (tnc == TypeNotaCredito.ANULACAO) { PdfPCell titileNum = new PdfPCell(new Paragraph("Deb. N " + map.get(NOTADEBITO), fontCabecalhoN)); titileNum.setBorder(PdfPCell.NO_BORDER); titileNum.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableNumNota.addCell(titileNum); paragraphCorpoEndTitile.add(pTableNumNota); } paragraphCorpoEndTitile.add(titileSub); paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo)); paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo)); ArrayList<DataReseguro.DataEmpresa> listaDataEmpresas = new ArrayList<>(); ClienteI ci = null; if (tnc == TypeNotaCredito.RESEGURO) { listaDataEmpresas = DataReseguro.getDadosEmpresa(idResseguro); } else { ci = new ClienteI(map.get(IDCLIENTE) + ""); } Phrase pCr = new Phrase("BENEFICI?RIO: ", fontCabecalhoN); paragraphCorpoEndTitile.add(pCr); @SuppressWarnings("null") Phrase pCrTex = new Phrase( ((tnc == TypeNotaCredito.RESEGURO) ? resS.getCLIENTE() : map.get(BENEFICIARIO) + "\n"), fontCabecalhoS); paragraphCorpoEndTitile.add(pCrTex); Phrase pEndereco = new Phrase("Endereo: ".toUpperCase(), fontCabecalhoN); paragraphCorpoEndTitile.add(pEndereco); Phrase pEnderecoTex = new Phrase( ((tnc == TypeNotaCredito.RESEGURO) ? ConfigDoc.Empresa.ENDERECO : ci.getENDERECO_()) + "\n", fontCabecalhoS); paragraphCorpoEndTitile.add(pEnderecoTex); Phrase pPolice = new Phrase("Apolice: ".toUpperCase(), fontCabecalhoN); paragraphCorpoEndTitile.add(pPolice); Phrase pPoliceTex = new Phrase( ((tnc == TypeNotaCredito.RESEGURO) ? resS.getAPOLICE() : map.get(APOLICE)) + "\n", fontCabecalhoS); paragraphCorpoEndTitile.add(pPoliceTex); // Phrase pInterCod = new Phrase("intermediry Code".toUpperCase(), fontCabecalhoN); // paragraphCorpoEndTitile.add(pInterCod); // Phrase pInterCodTex = new Phrase(/*SessionUtil.getUserlogado().getResidencia()*/"In ----\n", fontCabecalhoS); // paragraphCorpoEndTitile.add(pInterCodTex); Phrase pDate = new Phrase("DATA: ".toUpperCase(), fontCabecalhoN); paragraphCorpoEndTitile.add(pDate); Phrase pDateTex = new Phrase(((TypeNotaCredito.ANULACAO != tnc) ? resS.getINICIO() + " " + resS.getFIM() : map.get(DATAINICIO) + " " + map.get(DATAFIM)) + "\n", fontCabecalhoS); paragraphCorpoEndTitile.add(pDateTex); Phrase pSegurado = new Phrase("Segurado: ".toUpperCase(), fontCabecalhoN); paragraphCorpoEndTitile.add(pSegurado); Phrase pSeguradoTex = new Phrase( ((tnc == TypeNotaCredito.RESEGURO) ? ConfigDoc.Empresa.NOME + "(" + resS.getCLIENTE() + ")" : ci.getNOME_()), fontCabecalhoS); paragraphCorpoEndTitile.add(pSeguradoTex); paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo)); paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo)); //Tabela Principal PdfPTable pTableNotaCredito = new PdfPTable(new float[] { 21.5f, 21.5f, 22f, 27f, 7f }); // PdfPTable pTableNotaCreditos = new PdfPTable(new float[]{70f, 30f}); pTableNotaCredito.setWidthPercentage(100f); // pTableNotaCreditos.setWidthPercentage(100f); PdfPCell cellParticular = new PdfPCell(new Phrase("Particular".toUpperCase(), fontCorpoN)); cellParticular.setBorderWidth(1); pTableNotaCredito.addCell(cellParticular); PdfPCell cellPremioGrosso = new PdfPCell(new Phrase("Prmio Grosso".toUpperCase(), fontCorpoN)); cellPremioGrosso.setBorderWidth(1); pTableNotaCredito.addCell(cellPremioGrosso); PdfPCell cellComissaoDedutivel = new PdfPCell( new Phrase("Comisso Dedutvel".toUpperCase(), fontCorpoN)); cellComissaoDedutivel.setBorderWidth(1); pTableNotaCredito.addCell(cellComissaoDedutivel); PdfPCell cellValorLiquidoD = new PdfPCell(new Phrase("Valor Liqudo Devido", fontCorpoN)); cellValorLiquidoD.setBorderWidth(1); cellValorLiquidoD.setBorderWidthRight(0); pTableNotaCredito.addCell(cellValorLiquidoD); PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpoN)); PdfPCell cellNull1 = new PdfPCell(new Phrase("(NET)", fontCorpoN)); cellNull.setBorder(0); cellNull1.setBorderWidthTop(1); cellNull1.setBorderWidthRight(1); cellNull1.setBorderWidthLeft(0); cellNull1.setBorderWidthBottom(1); cellNull1.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableNotaCredito.addCell(cellNull1); cellParticular = new PdfPCell( new Phrase(((TypeNotaCredito.RESEGURO == tnc) ? resS.getDESCRICAO().toUpperCase() : map.get(DESCRICAO) + ""), fontCorpo)); cellParticular.setBorderWidth(1); pTableNotaCredito.addCell(cellParticular); cellPremioGrosso = new PdfPCell(new Phrase( ((TypeNotaCredito.RESEGURO == tnc) ? Moeda.format(Double.valueOf(resS.getPREMIOGROSSO())) : Moeda.format(Double.valueOf(map.get(PREMIOGROSSO) + ""))), fontCorpo)); cellPremioGrosso.setBorderWidth(1); cellPremioGrosso.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellPremioGrosso.setPaddingTop(30f); pTableNotaCredito.addCell(cellPremioGrosso); cellComissaoDedutivel = new PdfPCell(new Phrase( ((TypeNotaCredito.RESEGURO == tnc) ? resS.getDEDUCAO() + "%" : map.get(DECUCAO) + "%"), fontCorpo)); cellComissaoDedutivel.setBorderWidth(1); cellComissaoDedutivel.setPaddingTop(30f); cellComissaoDedutivel.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableNotaCredito.addCell(cellComissaoDedutivel); cellValorLiquidoD = new PdfPCell(new Phrase( Moeda.format(Double .valueOf(((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + ""))), fontCorpo)); cellValorLiquidoD.setBorderWidth(1); cellValorLiquidoD.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellValorLiquidoD.setPaddingTop(30f); cellValorLiquidoD.setPaddingBottom(75f); pTableNotaCredito.addCell(cellValorLiquidoD); pTableNotaCredito.addCell(cellNull); PdfPCell cellTotalDebito = new PdfPCell(new Phrase("TOTAL ", fontCorpoN)); cellTotalDebito.setBorder(PdfPCell.NO_BORDER); cellTotalDebito.setColspan(3); pTableNotaCredito.addCell(cellTotalDebito); PdfPCell cellTotalDebitoV = new PdfPCell(new Phrase( Moeda.format(Double .valueOf(((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + ""))), fontCorpo)); cellTotalDebitoV.setBorderWidth(1); cellTotalDebitoV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableNotaCredito.addCell(cellTotalDebitoV); pTableNotaCredito.addCell(cellNull); double cambio; double totalSTD = 0; if (!((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA)).equals("STD")) { PdfPCell cellCambio = new PdfPCell(new Phrase( "CAMBIO " + ((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA)), fontCorpoN)); cellCambio.setBorder(PdfPCell.NO_BORDER); cellCambio.setColspan(3); pTableNotaCredito.addCell(cellCambio); cambio = valorCompra( ((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA) + ""), ((TypeNotaCredito.RESEGURO == tnc) ? new Date() : map.get(CTT_DTREG))); PdfPCell cellCambioV = new PdfPCell(new Phrase(Moeda.format(cambio), fontCorpo)); cellCambioV.setBorderWidth(1); cellCambioV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableNotaCredito.addCell(cellCambioV); pTableNotaCredito.addCell(cellNull); PdfPCell cellValorDobras = new PdfPCell(new Phrase("VALOR EM DOBRAS", fontCorpoN)); cellValorDobras.setBorder(PdfPCell.NO_BORDER); cellValorDobras.setColspan(3); pTableNotaCredito.addCell(cellValorDobras); totalSTD = cambio * Double.valueOf((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + ""); PdfPCell cellValorDobrasV = new PdfPCell(new Phrase(Moeda.format(totalSTD), fontCorpo)); cellValorDobrasV.setBorderWidth(1); cellValorDobrasV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableNotaCredito.addCell(cellValorDobrasV); pTableNotaCredito.addCell(cellNull); } paragraphCorpoEndTitile.add(pTableNotaCredito); JTextPane jtp = new JTextPane(); Moeda.EscreverEstenso(totalSTD, jtp, "Dobras"); paragraphCorpoEndTitile.add(new Phrase("POR EXTENSO: ", fontCorpoN)); paragraphCorpoEndTitile.add(new Phrase(jtp.getText().toUpperCase().trim() + "\n", fontCorpo)); paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN)); paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN)); paragraphCorpoEndTitile.add(new Phrase("NOTA: ZERO PRMIO, ZERO COBERTURA", fontCorpoN)); paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN)); paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN)); PdfPTable pTableRodape = new PdfPTable(new float[] { 33.333333333f, 33.333333333f, 33.333333333f }); pTableRodape.setWidthPercentage(100.0f); PdfPCell cellRodapeData = new PdfPCell( new Phrase(".......................................................", fontCorpo)); cellRodapeData.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellRodapeData.setBorder(PdfPCell.NO_BORDER); pTableRodape.addCell(cellRodapeData); PdfPCell cellRodapeVerificado = new PdfPCell( new Phrase(".......................................................", fontCorpoN)); cellRodapeVerificado.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellRodapeVerificado.setBorder(PdfPCell.NO_BORDER); pTableRodape.addCell(cellRodapeVerificado); PdfPCell cellAssinatura = new PdfPCell( new Phrase(".......................................................", fontCorpo)); cellAssinatura.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellAssinatura.setBorder(PdfPCell.NO_BORDER); pTableRodape.addCell(cellAssinatura); cellRodapeData = new PdfPCell(new Phrase(" ", fontCorpo)); cellRodapeData.setBorder(PdfPCell.NO_BORDER); pTableRodape.addCell(cellRodapeData); cellRodapeVerificado = new PdfPCell(new Phrase("VERIFICADO POR", fontCorpoN)); cellRodapeVerificado.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellRodapeVerificado.setBorder(PdfPCell.NO_BORDER); pTableRodape.addCell(cellRodapeVerificado); cellAssinatura = new PdfPCell(new Phrase("ASSINATURA", fontCorpo)); cellAssinatura.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellAssinatura.setBorder(PdfPCell.NO_BORDER); pTableRodape.addCell(cellAssinatura); paragraphCorpoEndTitile.add(pTableRodape); cellCorpoEndTitile.addElement(paragraphCorpoEndTitile); cellCorpoEndTitile.setBorder(PdfPCell.NO_BORDER); pTableCorpoEndTitile.addCell(cellCorpoEndTitile); SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 70f, 5f); String f1 = (arquivo + "/" + interCod + "/Seguro " + nomeSeguro + "/"); File f = new File(f1); String Ddata = sdf1.format(new Date()); f.mkdirs(); f = new File(f.getAbsoluteFile() + "/" + "Nota de Credito " + Ddata + ".pdf"); reString = "../Documentos/" + interCod + "/Seguro " + nomeSeguro + "/" + "Nota de Credito " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(f); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableLinha); documento.add(pTableLinha); documento.add(pTableCorpoEndTitile); documento.close(); RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (FileNotFoundException | DocumentException e) { e.printStackTrace(); } catch (IOException ex) { Logger.getLogger(DocNotaCredito.class.getName()).log(Level.SEVERE, null, ex); } }