List of usage examples for com.itextpdf.text Font ITALIC
int ITALIC
To view the source code for com.itextpdf.text Font ITALIC.
Click Source Link
From source file:Controllers.ExportController.java
public static void exportExam(String path) { model = (DefaultTableModel) tableExam.getModel(); int selectRow = tableExam.getSelectedRow(); if (selectRow != -1) { int idExam = (int) model.getValueAt(selectRow, 0) - 1; exams = ExamModel.readExam();/* w ww . j a v a2s .c o m*/ Exam ex = exams.getExam(idExam); try { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open(); BaseFont f = BaseFont.createFont("/font/vuArial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font titleExamFont = new Font(f, 25.0f, Font.BOLD); Font titlePartFont = new Font(f, 18.0f, Font.BOLD); Font headFont = new Font(f, 13.0f, Font.BOLD); Font suggestionFont = new Font(f, 13.0f, Font.ITALIC); Font contentFont = new Font(f, 13.0f, Font.NORMAL); Paragraph align = new Paragraph(" "); Paragraph title = new Paragraph(ex.getNameExam(), titleExamFont); title.setAlignment(Paragraph.ALIGN_CENTER); document.add(title); document.add(align); ArrayList<Question> question = ex.getQuestions(); boolean haveMultipleChoice = false; boolean haveEssay = false; // Kim tra xem c phn t lun khng for (Question q : question) { if (q instanceof Essay) { haveEssay = true; } // Kim tra xem c phn trc nghim khng} else { haveMultipleChoice = true; } if (haveEssay && haveMultipleChoice) break; } int count; if (haveMultipleChoice) { count = 0; Paragraph titlePart = new Paragraph("Trc nghim", titlePartFont); document.add(align); document.add(titlePart); document.add(align); for (Question q : question) if (q instanceof MultipleChoice) { count++; Phrase numberQuestion = new Phrase("Cu " + count + ": ", headFont); Phrase contentQuestion = new Phrase(q.getContentQuestion(), contentFont); Paragraph questionParagraph = new Paragraph(); questionParagraph.add(numberQuestion); questionParagraph.add(contentQuestion); document.add(questionParagraph); MultipleChoice mc = (MultipleChoice) q; ArrayList<Answer> answers = mc.getAnswers(); boolean ok = true; for (int i = 0; i < answers.size(); ++i) { Answer answer = answers.get(i); if (answer.getContentAnswer().length() > 30) ok = false; } if (ok == true) { PdfPTable table = new PdfPTable(2); for (int i = 0; i < answers.size(); ++i) { Answer answer = answers.get(i); PdfPCell answerParagraph = new PdfPCell(new Paragraph( (char) (65 + i) + ". " + answer.getContentAnswer(), contentFont)); answerParagraph.setBorder(Rectangle.NO_BORDER); table.addCell(answerParagraph); } document.add(table); } else { PdfPTable table = new PdfPTable(1); for (int i = 0; i < answers.size(); ++i) { Answer answer = answers.get(i); PdfPCell answerParagraph = new PdfPCell(new Paragraph( (char) (65 + i) + ". " + answer.getContentAnswer(), contentFont)); answerParagraph.setBorder(Rectangle.NO_BORDER); table.addCell(answerParagraph); } document.add(table); } } } if (haveEssay) { count = 0; Paragraph titlePart = new Paragraph("T Lun", titlePartFont); document.add(align); document.add(titlePart); document.add(align); for (Question q : question) if (q instanceof Essay) { count++; Phrase numberQuestion = new Phrase("Cu " + count + ": ", headFont); Phrase contentQuestion = new Phrase(q.getContentQuestion(), contentFont); Paragraph questionParagraph = new Paragraph(); questionParagraph.add(numberQuestion); questionParagraph.add(contentQuestion); Essay es = (Essay) q; Phrase headerSuggestion = new Phrase("Gi : ", suggestionFont); Phrase contentSuggestion = new Phrase(es.getSuggest(), contentFont); Paragraph suggestion = new Paragraph(); suggestion.add(headerSuggestion); suggestion.add(contentSuggestion); document.add(questionParagraph); document.add(suggestion); } } document.close(); } catch (FileNotFoundException exp) { exp.printStackTrace(); } catch (DocumentException exp) { exp.printStackTrace(); } catch (IOException exp) { exp.printStackTrace(); } } }
From source file:de.domjos.schooltools.core.utils.fileUtils.PDFBuilder.java
License:Open Source License
public void addFont(String key, Font.FontFamily fontFamily, float size, boolean bold, boolean italic, BaseColor color) {/*from w w w . j a va2s . c o m*/ if (bold) { if (italic) { this.fonts.put(key, new Font(fontFamily, size, Font.BOLDITALIC, color)); } else { this.fonts.put(key, new Font(fontFamily, size, Font.BOLD, color)); } } else { if (italic) { this.fonts.put(key, new Font(fontFamily, size, Font.ITALIC, color)); } else { this.fonts.put(key, new Font(fontFamily, size, Font.NORMAL, color)); } } }
From source file:de.extra.xtt.util.pdf.PdfCreatorImpl.java
License:Apache License
private Chunk getChunkTextItalic(String text) { return new Chunk(text, FontFactory.getFont(fontNameStandard, fontSizeText, Font.ITALIC)); }
From source file:de.extra.xtt.util.pdf.PdfCreatorImpl.java
License:Apache License
private Paragraph getParagraphTextItalic(String text) { return new Paragraph(text, FontFactory.getFont(fontNameStandard, fontSizeText, Font.ITALIC)); }
From source file:de.knurt.heinzelmann.util.itext.TextBlock.java
License:Creative Commons License
private List<Chunk> getChunks(String content) { Font italic = new Font(this.font); italic.setStyle(Font.ITALIC); Font normal = new Font(this.font); normal.setStyle(Font.NORMAL); Font bold = new Font(this.font); bold.setStyle(Font.BOLD);//from w w w . j av a2s . c o m Font bolditalic = new Font(this.font); bolditalic.setStyle(Font.BOLDITALIC); Font markfont = null; boolean markModus = false; List<Chunk> result = new ArrayList<Chunk>(); List<Chunk> tmp = new ArrayList<Chunk>(); StringTokenizer tokenizer = new StringTokenizer(content, "\\*", true); while (tokenizer.hasMoreTokens()) { String tok = tokenizer.nextToken(); if (tok.equals("*")) { if (markModus) { if (markfont.getStyle() == Font.ITALIC) { markfont = bold; } else { markfont = bolditalic; } } else { if (markfont == null) { markfont = italic; markModus = true; } else if (markfont.getStyle() == Font.BOLDITALIC) { markfont = bold; } else if (markfont.getStyle() == Font.BOLD) { markfont = italic; } else if (markfont.getStyle() == Font.ITALIC) { markfont = null; } } continue; } if (markfont != null) { tmp.add(new Chunk(tok, markfont)); markModus = false; } else { tmp.add(new Chunk(tok, normal)); } } result.addAll(tmp); return result; }
From source file:de.tuttas.servlets.DokuServlet.java
private Document createUmfrageauswertung(List<UmfrageResult> res1, List<UmfrageResult> res2, int idUmfrage1, int idUmfrage2, String filter1, String filter2, String kopf, OutputStream out) throws DocumentException, BadElementException, IOException { Document document = new Document(); /* Basic PDF Creation inside servlet */ Umfrage u1 = em.find(Umfrage.class, idUmfrage1); Umfrage u2 = em.find(Umfrage.class, idUmfrage2); // Bild einfgen String url = "http://www.mmbbs.de/fileadmin/template/mmbbs/gfx/mmbbs_logo_druck.gif"; Image image = Image.getInstance(url); image.setAbsolutePosition(45f, 720f); image.scalePercent(50f);/*from ww w .j a v a2 s .com*/ StringBuilder htmlString = new StringBuilder(); htmlString.append(kopf); htmlString.append("<br></br>"); int maxRows = res1.size(); if (res2.size() > maxRows) { maxRows = res2.size(); } PdfWriter writer = PdfWriter.getInstance(document, out); document.open(); writer.setPageEmpty(false); Font boldFont = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD); Font normalFont = new Font(Font.FontFamily.HELVETICA, 10, Font.ITALIC); PdfPTable table = new PdfPTable(new float[] { 1, 2, 2 }); PdfPCell qestionCell; PdfPCell group1Cell; PdfPCell group2Cell; int i = 0; for (i = 0; i < maxRows; i++) { Log.d("Print Row " + i); if (i % 5 == 0) { if (i != 0) { document.add(table); document.newPage(); document = printHead(writer, document, htmlString, out, image); } else { document = printHead(writer, document, htmlString, out, image); } table = new PdfPTable(new float[] { 1, 2, 2 }); table.setWidthPercentage((float) 100.0); qestionCell = new PdfPCell(new Phrase("\nFragen", boldFont)); group1Cell = new PdfPCell(); group1Cell.addElement(new Phrase("Hauptgruppe:", boldFont)); group1Cell.addElement(new Phrase(u1.getNAME() + "\n" + filter1, normalFont)); group2Cell = new PdfPCell(); group2Cell.addElement(new Phrase("Vergleichsgruppe:", boldFont)); group2Cell.addElement(new Phrase(u2.getNAME() + "\n" + filter2, normalFont)); qestionCell.setBorderWidth(2.0f); group1Cell.setBorderWidth(2.0f); group2Cell.setBorderWidth(2.0f); table.addCell(qestionCell); table.addCell(group1Cell); table.addCell(group2Cell); } String url1 = UmfrageUtil.getCharUrl(res1.get(i)); Log.d("URL1=" + url1); Image image1 = Image.getInstance(url1); Image image2 = null; if (res2.size() > i) { String url2 = UmfrageUtil.getCharUrl(res2.get(i)); Log.d("URL2=" + url2); image2 = Image.getInstance(url2); } Log.d("Write to pdf:" + res1.get(i).getFrage()); qestionCell = new PdfPCell(new Phrase(res1.get(i).getFrage(), normalFont)); qestionCell.setBorderWidth(1.0f); group1Cell = new PdfPCell(image1, true); group1Cell.setBorderWidth(1.0f); group1Cell.setPadding(10); if (image2 != null) group2Cell = new PdfPCell(image2, true); else group2Cell = new PdfPCell(); group2Cell.setBorderWidth(1.0f); group2Cell.setPadding(10); table.addCell(qestionCell); table.addCell(group1Cell); table.addCell(group2Cell); } if (!(i % 5 == 0)) { document.add(table); } document.close(); return document; }
From source file:edu.harvard.mcz.precapture.ui.ContainerLabel.java
License:Open Source License
/** * //from w w w . j av a2 s . c om * @return a PDF paragraph cell containing a text encoding of the fields in this set. */ public PdfPCell toPDFCell(LabelDefinitionType printDefinition) { PdfPCell cell = new PdfPCell(); ; if (printDefinition.getTextOrentation().toString().toLowerCase() .equals(TextOrentationType.VERTICAL.toString().toLowerCase())) { log.debug("Print orientation of text is Vertical"); cell.setRotation(90); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); } cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); cell.disableBorderSide(PdfPCell.RIGHT); cell.setPaddingLeft(3); cell.setNoWrap(false); int leading = (int) (fields.get(0).getField().getFontSize() + printDefinition.getFontDelta()) - 1; Paragraph higher = new Paragraph(leading, "", new Font(Font.FontFamily.TIMES_ROMAN, fields.get(0).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL)); higher.setSpacingBefore(0); higher.setSpacingAfter(0); boolean added = false; boolean hasContent = false; for (int i = 0; i < fields.size(); i++) { log.debug(i); if (fields.get(i).getField().isNewLine() || (i == fields.size() - 1)) { if (!higher.isEmpty()) { log.debug(higher.getContent()); cell.addElement(higher); } leading = (int) (fields.get(i).getField().getFontSize() + printDefinition.getFontDelta()) - 1; higher = new Paragraph(leading, "", new Font(Font.FontFamily.TIMES_ROMAN, fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL)); higher.setSpacingBefore(0); higher.setSpacingAfter(0); added = false; hasContent = false; } log.debug(fields.get(i).getTextField().getText().trim()); Chunk chunk = new Chunk(fields.get(i).getTextField().getText().trim()); if (fields.get(i).getField().isUseItalic()) { chunk.setFont(new Font(Font.FontFamily.TIMES_ROMAN, fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.ITALIC)); } else { chunk.setFont(new Font(Font.FontFamily.TIMES_ROMAN, fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL)); } if (!chunk.isEmpty()) { hasContent = true; higher.add(chunk); log.debug(fields.get(i).getField().getSuffix()); if (fields.get(i).getField().getSuffix() != null && fields.get(i).getField().getSuffix().length() > 0) { higher.add(new Chunk(fields.get(i).getField().getSuffix())); } if (fields.get(i).getTextField().getText().trim().length() > 0) { // add a trailing space as a separator if there was something to separate. higher.add(new Chunk(" ")); } } } if (!added) { log.debug(higher.getContent()); cell.addElement(higher); } String extraText = PreCaptureSingleton.getInstance().getProperties().getProperties() .getProperty(PreCaptureProperties.KEY_EXTRAHUMANTEXT); if (extraText != null && extraText.length() > 0) { log.debug(extraText); cell.addElement(new Chunk(extraText)); } return cell; }
From source file:Export.CertificadoCargaMaritima.java
public String criarDoc(String numApolice, String numCliente, Contrato c, CargaMaritimaBean cm, String user, String moeda, String arquivo) { try {// 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.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 www.j av a 2 s. com 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.ReciboPagamento.java
/** * new Documento Pagamento//w w w .ja va 2 s. co m * * @param Prestacao * @param user * @return String */ public String criarDoc(Integer Prestacao, String user) { try { SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); numPrestacao = Prestacao; File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Recebimento " + Ddata + ".pdf"); OutputStream outputStraem = new FileOutputStream(ff); reString = "../Documentos/" + user + "/Pagamentos/" + "Recebimento " + Ddata + ".pdf"; Document document = new Document(PageSize.A4); document.setMargins(20f, 20f, 0f, 0f); PdfWriter writer = PdfWriter.getInstance(document, outputStraem); Font fontTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 17f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontTitileShort = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontRecibo = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontReciboTxt = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f, Font.NORMAL, BaseColor.BLACK.darker().darker().darker()); Font fontConteudo = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontConteudoTxt = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f, Font.ITALIC, BaseColor.BLACK.darker().darker().darker()); Font fontConteudoTxtUl = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f, Font.ITALIC + Font.UNDERLINE, BaseColor.BLACK.darker().darker().darker()); MyFooter event = new MyFooter(); writer.setPageEvent(event); daoRecibo r = new daoRecibo(); HashMap<String, Object> map = r.getDados(); document.open(); PdfPTable table = detaDoc(map, fontTitile, fontRecibo, fontTitileShort, fontReciboTxt, fontConteudo, fontConteudoTxt, fontConteudoTxtUl); // document.add(table); // document.add(new Paragraph("\n\n\n\n\n\n\n\n\n", fontTitileShort)); // document.add(table); // document.newPage(); table.setTotalWidth(555); table.writeSelectedRows(-1, 100, 22.5f, 820f, writer.getDirectContent()); table.writeSelectedRows(-1, 100, 22.5f, 400f, writer.getDirectContent()); // table.writeSelectedRows(-1, 2, 52.5f, 402.5f, writer.getDirectContent()); document.close(); return reString; } catch (DocumentException ex) { Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex); return reString; } catch (FileNotFoundException ex) { Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex); } return reString; }