List of usage examples for com.itextpdf.text Paragraph add
@Override public boolean add(Element o)
Element
to the Paragraph
. From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java
private void insertCellProtocol(PdfPTable table, LicensePFEntity license) { this.insertHeaderCell(table, "6- CONTROLE DE RECEBIMENTO DO PROCESSO", 4); Paragraph officialPhrase = new Paragraph("USO OFICIAL" + SEPARATOR, FONT_PARAGRAPH); officialPhrase.setAlignment(Element.ALIGN_LEFT); Paragraph protocolPhrase = new Paragraph("ETIQUETA PROTOCOLO" + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE, FONT_PROTOCOL);/* ww w .j av a2s.c o m*/ protocolPhrase.setAlignment(Element.ALIGN_LEFT); Paragraph obsPhrase = new Paragraph(SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + "Observao Importante!" + SEPARATOR, FONT_HEADER); Paragraph obsStringPhrase = new Paragraph("- Etiqueta com data e assinatura." + SEPARATOR + "- Renovao: verificar a data de vencimento da licena." + SEPARATOR + "- Alterao Cadastral: apresentar o Anexo VI." + SEPARATOR_DOUBLE, FONT_PARAGRAPH); Paragraph phraseProtocol = new Paragraph(); phraseProtocol.add(officialPhrase); phraseProtocol.add(protocolPhrase); Paragraph phraseObs = new Paragraph(); phraseObs.add(obsPhrase); phraseObs.add(obsStringPhrase); PdfPCell cellProtocol = new PdfPCell(phraseProtocol); cellProtocol.setColspan(2); cellProtocol.disableBorderSide(Rectangle.RIGHT); PdfPCell cellObs = new PdfPCell(phraseObs); cellObs.setColspan(2); cellObs.disableBorderSide(Rectangle.LEFT); table.addCell(cellProtocol); table.addCell(cellObs); }
From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java
private Paragraph createHeader() { Paragraph anexo = new Paragraph("ANEXO IV" + SEPARATOR + "REQUERIMENTO - HABILITAO DE PESSOA JUR?DICA", FONT_BIG_HEADER_BOLD);//from ww w . j a v a 2s . c o m anexo.setAlignment(Element.ALIGN_CENTER); Paragraph law = new Paragraph("( Lei n 10.357, de 27 de dezembro de 2001)" + SEPARATOR_DOUBLE, FONT_BIG_HEADER); law.setAlignment(Element.ALIGN_CENTER); Paragraph full = new Paragraph(); full.add(anexo); full.add(law); return full; }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private void createFooter(PdfPTable table) { this.insertHeaderCell(table, "Portaria 1.274/03", 4); Paragraph artigo = new Paragraph("Art. 6", FONT_HEADER); Paragraph text1 = new Paragraph( "A pessoa jurdica possuidora de Certificado de Registro Cadastral dever", FONT_PARAGRAPH); Paragraph text2 = new Paragraph(" comunicar ao DPF, no prazo de trinta dias, todo e qualquer " + "fato que justifique a atualizao de seu cadastro", FONT_HEADER); Paragraph text3 = new Paragraph( ", mediante preenchimento de formulrio prprio (Anexo VI). " + SEPARATOR_DOUBLE, FONT_PARAGRAPH); Paragraph text4 = new Paragraph("Pargrafo nico", FONT_HEADER); Paragraph text5 = new Paragraph("O pedido de atualizao do registro cadastral dever ser", FONT_PARAGRAPH);/* w w w . j a v a2s . c o m*/ Paragraph text6 = new Paragraph( "formalizado no prazo mximo de noventa dias, a partir da data do comunicado", FONT_HEADER); Paragraph text7 = new Paragraph(" a que se refere o caput, por meio de requerimento (Anexo IV).", FONT_PARAGRAPH); Paragraph paragraphFull = new Paragraph(); paragraphFull.add(artigo); paragraphFull.add(text1); paragraphFull.add(text2); paragraphFull.add(text3); paragraphFull.add(text4); paragraphFull.add(text5); paragraphFull.add(text6); paragraphFull.add(text7); PdfPCell cell = new PdfPCell(paragraphFull); cell.setColspan(4); table.addCell(cell); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private void insertCellProtocol(PdfPTable table, LicensePFEntity license) { PdfPTable tableProtocol = new PdfPTable(1); tableProtocol.setWidthPercentage(100f); Paragraph officialPhrase = new Paragraph("USO OFICIAL" + SEPARATOR, FONT_PARAGRAPH); officialPhrase.setAlignment(Element.ALIGN_LEFT); Paragraph protocolPhrase = new Paragraph("ETIQUETA PROTOCOLO" + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR, FONT_PROTOCOL); protocolPhrase.setAlignment(Element.ALIGN_LEFT); Paragraph obsPhrase = new Paragraph("Observao Importante!" + SEPARATOR, FONT_HEADER); Paragraph obsStringPhrase = new Paragraph( "Protocolar este Anexo somente quando no conjugado com a alterao efetiva ou a renovao da licena.", FONT_PARAGRAPH);/*from w ww. ja va 2 s . com*/ Paragraph fullPhrase = new Paragraph(); fullPhrase.add(officialPhrase); fullPhrase.add(protocolPhrase); fullPhrase.add(obsPhrase); fullPhrase.add(obsStringPhrase); PdfPCell cell = new PdfPCell(fullPhrase); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPadding(5f); tableProtocol.addCell(cell); PdfPCell cellProtocol = new PdfPCell(tableProtocol); cellProtocol.setColspan(2); table.addCell(cellProtocol); table.addCell(this.createCellEtiqueta(license)); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private Paragraph createHeader() { Paragraph anexo = new Paragraph("ANEXO VI" + SEPARATOR + "COMUNICADO DE ALTERAO CADASTRAL", FONT_BIG_HEADER_BOLD);/* w w w .ja v a 2 s. c o m*/ anexo.setAlignment(Element.ALIGN_CENTER); Paragraph law = new Paragraph("( Lei n 10.357, de 27 de dezembro de 2001)" + SEPARATOR_DOUBLE, FONT_BIG_HEADER); law.setAlignment(Element.ALIGN_CENTER); Paragraph full = new Paragraph(); full.add(anexo); full.add(law); return full; }
From source file:com.suyati.androidpdf.FirstPDFActivity.java
private static void addTitlePage(Document document) throws DocumentException { Paragraph preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);/*from ww w . ja v a2 s .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:com.swayam.bhasha.engine.io.writers.impl.PDFGenerator.java
License:Apache License
private Paragraph getParagraph(Para para) throws DocumentException, IOException, DocGenerationException { int align = para.getAlignment(); int pdfAlign; switch (align) { case Para.CENTER: pdfAlign = Paragraph.ALIGN_CENTER; break;//from www .ja va 2 s .c om case Para.RIGHT: pdfAlign = Paragraph.ALIGN_RIGHT; break; case Para.JUSTIFIED: pdfAlign = Paragraph.ALIGN_JUSTIFIED; break; case Para.LEFT: default: pdfAlign = Paragraph.ALIGN_LEFT; break; } List<ParaText> paraTextList = para.getParaTextList(); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(pdfAlign); for (ParaText paraText : paraTextList) { int fontStyle = Font.NORMAL; if (paraText.isBold()) { fontStyle |= Font.BOLD; } if (paraText.isUnderline()) { fontStyle |= Font.UNDERLINE; } if (paraText.isItalic()) { fontStyle |= Font.ITALIC; } Font font = FontFactory.getFont(paraText.getFontFamily(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED, paraText.getFontSize(), fontStyle, new BaseColor(paraText.getColor().getRGB())); // its very important to set the leading every time the font is set // otherwise, the chunks/phrases overlap. // paragraph.setLeading(font.getSize() * 1.5f); paragraph.add(new Phrase(paraText.getText(), font)); } return paragraph; }
From source file:com.thelinh.gui.PreviewExam.java
private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed if (this.txtExamCode.getText().equals("")) { JOptionPane.showMessageDialog(this, "Hy nhp m ?"); } else {/* w w w .j a va2s .com*/ JFileChooser fc = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("PDF files (*.pdf)", "pdf"); fc.setFileFilter(filter); int rt = fc.showSaveDialog(this); if (rt == JFileChooser.APPROVE_OPTION) { String filepath = fc.getSelectedFile().getPath(); if (filepath.indexOf(".") == -1) { filepath = filepath + ".pdf"; } String dafilepath = (new StringBuffer(filepath)).insert(filepath.length() - 4, ".da").toString(); try { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(filepath)); document.open(); // Add title Paragraph p = new Paragraph("Tr?ng ?i h?c Bch Khoa H Ni", timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(5); document.add(p); p = new Paragraph("?? thi mn " + this.lbSubject.getText(), timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(25); document.add(p); p = new Paragraph( "Ng?i ra ?: " + Controller.getCurrentAdmin().getAdminName() + ", Ngy ra ?: " + (new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())), times_15); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(5); document.add(p); p = new Paragraph("M ?: " + this.txtExamCode.getText() + " Th?i gian lm bi: " + spTime.getValue().toString() + " pht", timesBold_15); p.setSpacingAfter(25); document.add(p); for (int i = 0; i < this.questionList.size(); i++) { Question question = this.questionList.get(i); ArrayList<Answer> answerList = AnswerSql .getAnswersByQuestionId(question.getQuestionId().trim()); Phrase questionNumber = new Phrase("Cu " + (i + 1) + ": ", timesBold_15); Phrase questionContent = new Phrase(question.getQuestion(), times_15); Paragraph questionTitle = new Paragraph(); questionTitle.add(questionNumber); questionTitle.add(questionContent); document.add(questionTitle); PdfPTable table = new PdfPTable(2); for (int j = 0; j < answerList.size(); j++) { Answer ans = answerList.get(j); Phrase cap = new Phrase(Character.toString((char) (j + 65)) + ". ", timesBold_15); Phrase answerContent = new Phrase(ans.getAnswer(), times_15); Phrase elem = new Phrase(); elem.add(cap); elem.add(answerContent); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setPhrase(elem); cell.setFixedHeight(25); table.addCell(cell); } document.add(table); } document.close(); // if (Desktop.isDesktopSupported()) { // try { // File myFile = new File(filepath); // Desktop.getDesktop().open(myFile); // } catch (IOException ex) { // // no application registered for PDFs // System.out.println(ex.toString()); // } // } document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(dafilepath)); document.open(); // Add title p = new Paragraph("Tr?ng ?i h?c Bch Khoa H Ni", timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(5); document.add(p); p = new Paragraph("?? thi mn " + this.lbSubject.getText(), timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(25); document.add(p); p = new Paragraph( "Ng?i ra ?: " + Controller.getCurrentAdmin().getAdminName() + ", Ngy ra ?: " + (new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())), times_15); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(5); document.add(p); p = new Paragraph("M ?: " + this.txtExamCode.getText() + " Th?i gian lm bi: " + spTime.getValue().toString() + " pht", timesBold_15); p.setSpacingAfter(25); document.add(p); for (int i = 0; i < this.questionList.size(); i++) { Question question = this.questionList.get(i); ArrayList<Answer> answerList = AnswerSql .getAnswersByQuestionId(question.getQuestionId().trim()); Phrase questionNumber = new Phrase("Cu " + (i + 1) + ": ", timesBold_15); Phrase questionContent = new Phrase(question.getQuestion(), times_15); Paragraph questionTitle = new Paragraph(); questionTitle.add(questionNumber); questionTitle.add(questionContent); document.add(questionTitle); PdfPTable table = new PdfPTable(2); for (int j = 0; j < answerList.size(); j++) { Answer ans = answerList.get(j); Phrase cap = new Phrase(Character.toString((char) (j + 65)) + ". ", timesBold_15); Phrase answerContent = null; if (ans.getYesNo()) { answerContent = new Phrase(ans.getAnswer(), timesBold_15); } else { answerContent = new Phrase(ans.getAnswer(), times_15); } Phrase elem = new Phrase(); elem.add(cap); elem.add(answerContent); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setPhrase(elem); cell.setFixedHeight(25); table.addCell(cell); } document.add(table); } document.close(); } catch (FileNotFoundException | DocumentException ex) { Logger.getLogger(PreviewExam.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:com.thomasmore.service.PdfCreateServiceImpl.java
public void readPdf() { try {//from w w w.j av a2 s .c o m OutputStream file = new FileOutputStream(new File("D:\\SamplePDFje.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); document.add(new Paragraph("First iText PDF")); document.add(new Paragraph(new Date().toString())); document.addAuthor("Krishna Sfsfsfsn"); document.addCreationDate(); document.addCreator("JavaBeat"); document.addTitle("Sample PDF"); //Create Paragraph Paragraph paragraph = new Paragraph("Title 1", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); //New line paragraph.add(new Paragraph(" ")); paragraph.add("Test Paragraph"); paragraph.add(new Paragraph(" ")); document.add(paragraph); //Create a table in PDF PdfPTable pdfTable = new PdfPTable(3); PdfPCell cell1 = new PdfPCell(new Phrase("Table Header 1")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(cell1); cell1 = new PdfPCell(new Phrase("Table Header 2")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(cell1); cell1 = new PdfPCell(new Phrase("Table Header 3")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdfTable.addCell(cell1); pdfTable.setHeaderRows(1); pdfTable.addCell("Row 1 Col 1"); pdfTable.addCell("Row 1 Col 2"); pdfTable.addCell("Row 1 Col 3"); pdfTable.addCell("Row 2 Col 1"); pdfTable.addCell("Row 2 Col 2"); pdfTable.addCell("Row 2 Col 3"); document.add(pdfTable); document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.udec.utilidades.PdfTable.java
public void createPdf(List<Nomina> nomi, Periodo pe) { //Abrimos el documento para edicin //Declaramos un texto como Paragraph //Le podemos dar formado como alineacin, tamao y color a la fuente. Paragraph parrafo = new Paragraph(); parrafo.setAlignment(Paragraph.ALIGN_CENTER); parrafo.setFont(FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)); parrafo.add("CAJA DE PREVISION SOCIAL U. DE C.\n"); parrafo.add(pe.getNombre() + "\n"); parrafo.add(" "); try {/* w w w . ja v a 2 s . c o m*/ //Agregamos el texto al documento documento.add(parrafo); //Agregamos un salto de linea documento.add(new Paragraph(" ")); //Agregamos la tabla al documento haciendo //la llamada al mtodo tabla() //documento.add(tabla()); documento.add(tabla2(nomi)); documento.add(new Paragraph(" ")); documento.add(tabla3(nomi)); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(firma()); } catch (DocumentException ex) { ex.getMessage(); } try { //File file = new File(archivo); //Desktop.getDesktop().open(file); } catch (Exception e) { //e.printStackTrace(); } }