List of usage examples for com.itextpdf.text Document add
public boolean add(Element element) throws DocumentException
Element
to the Document
. From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseExercitoPDF.java
/** * Incluso de Atividades//from w ww . jav a 2s. c om * * @param doc * @param license * @param listCharterType * @throws DocumentException */ private void createCharter(Document doc, LicenseEXEntity license, List<CharterTypeEntity> listCharterType) throws DocumentException { if (listCharterType == null || listCharterType.isEmpty()) { return; } StringBuilder sb = new StringBuilder().append(numLine++).append("-) ") .append("APOSTILAMENTO em seu CERTIFICADO DE REGISTRO n: ").append(license.getNumRegister()) .append(" para a incluso das atividades:"); for (CharterTypeEntity charterType : listCharterType) { sb.append(charterType.getName()).append(", "); } sb.append( " em todos os produtos produtos j listados no Certificado de Registro, de acordo com o artigo 96 do Regulamento") .append(" aprovado pelo Decreto nmero 3.665, de 20 de novembro de 2000, para fiscalizao de produtos controlados (R-105) ") .append(" e legislao complementar"); Paragraph paragraph = new Paragraph(sb.toString()); paragraph.setFont(FONT_PARAGRAPH); doc.add(Chunk.NEWLINE); doc.add(paragraph); doc.add(Chunk.NEWLINE); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseExercitoPDF.java
/** * Incluso de Produtos/*from ww w. ja v a 2 s .c o m*/ * * @param doc * @param license * @param listProducts * @throws DocumentException */ private void createIncludeProduct(Document doc, LicenseEXEntity license, List<LicenseExCharterProductEntity> listProducts) throws DocumentException { if (listProducts == null || listProducts.isEmpty()) { return; } StringBuilder sb = new StringBuilder().append(numLine++).append("-) ") .append("APOSTILAMENTO em seu CERTIFICADO DE REGISTRO n: ").append(license.getNumRegister()) .append(" para a incluso dos seguintes produtos:").append(WINDOWS_LINE_SEPARATOR); for (LicenseExCharterProductEntity productCharter : listProducts) { sb.append(productCharter.getProduct().getOrder()).append(" - ") .append(productCharter.getProduct().getName()).append(" - ") .append(productCharter.getQtdProduct()).append(" - ").append(productCharter.getTypeQtdProduct()) .append(WINDOWS_LINE_SEPARATOR); } sb.append( "Para todas as atividades j cadastradas no Certificado de Registro, de acordo com o Artigo 96 do Regulamento ") .append("aprovado pelo Decreto No. 3.665, de 20 de Novembro de 2000, para a fiscalizao de Produtos Controlados (R-105) ") .append("e legislao complementar."); Paragraph paragraph = new Paragraph(sb.toString()); paragraph.setFont(FONT_PARAGRAPH); doc.add(Chunk.NEWLINE); doc.add(paragraph); doc.add(Chunk.NEWLINE); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseExercitoPDF.java
/** * Alteraes Cadastrais//from w w w. j a v a 2 s. c o m * * @param doc * @param license * @param listProducts * @throws DocumentException */ private void createAlterLicense(Document doc, LicenseEXEntity license, String text, String type) throws DocumentException { if (StringUtils.isEmpty(text)) { return; } StringBuilder sb = new StringBuilder().append(numLine++).append("-) ").append("CORREO de ").append(type) .append(" em seu CERTIFICADO DE REGISTRO n:").append(license.getNumRegister()).append(" para: ") .append(text).append(" conforme cadastrado junto a Prefeitura da Cidade de ") .append(license.getCompany().getCity()).append("/").append(license.getCompany().getState()) .append(" e Receita Federal."); Paragraph paragraph = new Paragraph(sb.toString()); paragraph.setFont(FONT_PARAGRAPH); doc.add(Chunk.NEWLINE); doc.add(paragraph); doc.add(Chunk.NEWLINE); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseExercitoPDF.java
private void createSignature(Document doc, LicenseEXEntity license) throws DocumentException { StringBuilder sbTerms = new StringBuilder().append("Nestes termos").append(WINDOWS_LINE_SEPARATOR) .append(" Pede deferimento."); StringBuilder sbDate = new StringBuilder().append(license.getCompany().getCity()).append("/") .append(license.getCompany().getState()).append(", ") .append(DateUtils.format(Calendar.getInstance())); StringBuilder sbSignature = new StringBuilder().append("____________________________________________") .append(WINDOWS_LINE_SEPARATOR).append(license.getCompany().getName()) .append(WINDOWS_LINE_SEPARATOR).append(license.getCompany().getUserResponsable().getName()) .append(" - ").append(license.getCompany().getUserResponsable().getOffice()); Paragraph paragraphTerms = new Paragraph(sbTerms.toString()); paragraphTerms.setFont(FONT_PARAGRAPH); paragraphTerms.setAlignment(Element.ALIGN_CENTER); Paragraph paragraphDate = new Paragraph(sbDate.toString()); paragraphDate.setFont(FONT_PARAGRAPH); Paragraph paragraphSignature = new Paragraph(sbSignature.toString()); paragraphSignature.setFont(FONT_PARAGRAPH); paragraphSignature.setAlignment(Element.ALIGN_CENTER); doc.add(Chunk.NEWLINE); doc.add(paragraphTerms);//from w w w. j a va 2s .c o m doc.add(Chunk.NEWLINE); doc.add(paragraphDate); doc.add(Chunk.NEWLINE); doc.add(Chunk.NEWLINE); doc.add(paragraphSignature); doc.add(Chunk.NEWLINE); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private void createTable(Document doc, RequerimentFederalEnum type, LicensePFEntity license, List<ProductOfficialEntity> listProducts) throws DocumentException { // create PDF table with the given widths PdfPTable table = new PdfPTable(4); // set table width a percentage of the page width table.setWidthPercentage(100f);// w w w . j a v a 2 s .co m this.createCompany(table, license); // Alterao Cadastral this.createAlteracaoCadastral(table, type); // Descrio this.insertHeaderCell(table, "3 - DESCREVER AS PRINCIPAIS ALTERAES OCORRIDAS", 4); this.insertCell(table, this.createProductsText(listProducts, type), 4); // Uso Oficial this.insertCellProtocol(table, license); // Footer this.createFooter(table); // Table pai PdfPTable tableFather = new PdfPTable(1); tableFather.setWidthPercentage(100f); PdfPCell cellFather = new PdfPCell(table); cellFather.setBorderWidth(2); tableFather.addCell(cellFather); doc.add(this.createHeader()); doc.add(tableFather); }
From source file:com.sparksoftsolutions.com.pdfcreator.MainActivity.java
private File generatePDFFromImages(ArrayList<ImageItem> images) { Document document = new Document(); File sdcard = Environment.getExternalStorageDirectory(); File file = new File(sdcard, generateFileName()); try {/*from ww w .ja v a 2s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); } catch (Exception ex) { return null; } // document = new PdfDocument(); Boolean opened = false; for (ImageItem img : images) { Bitmap bitmap = BitmapFactory.decodeFile(img.path); try { Image image = Image.getInstance(img.path); document.setPageSize(new Rectangle(image.getWidth(), image.getHeight())); if (!opened) { document.open(); opened = true; } else document.newPage(); document.add(image); } catch (Exception e) { e.printStackTrace(); return null; } } document.close(); return file; }
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);// w ww. j a v a2s . 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 void makePDFPage(HTMLDocModel htmlDoc, String fileName) throws DocGenerationException { Rectangle pageSize = PageSize.A4; if (pageDim.height > pageSize.getHeight()) { pageSize = new Rectangle(pageDim.width, pageDim.height); }// www . j av a2 s . co m Document pdfDoc = new Document(pageSize, MARGINS, MARGINS, MARGINS, MARGINS); FileOutputStream pdfStream = null; try { pdfStream = new FileOutputStream(fileName); PdfWriter.getInstance(pdfDoc, pdfStream); pdfDoc.addAuthor("Bhasha PDF Generator (Powered by IText)"); pdfDoc.open(); List<Para> paraList = htmlDoc.getParaList(); for (Para para : paraList) { pdfDoc.add(getParagraph(para)); } pdfDoc.close(); } catch (Exception e) { throw new DocGenerationException(e); } finally { if (pdfStream != null) { try { pdfStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:com.systemevent.jsfclass.util.FormatoPDF.java
/** * Manejador del evento onEndPage, usado para generar el encabezado *///from www .j a v a2 s . c om @Override public void onEndPage(PdfWriter writer, Document document) { try { document.add(imagen); table.writeSelectedRows(0, -1, 140f, 760f, writer.getDirectContent()); } catch (Exception doc) { doc.printStackTrace(); } }
From source file:com.systemevent.jsfclass.util.PdfEvento.java
public void imprimirPdf(Evento events) { Evento event = events;/*w ww . j a v a 2 s . co m*/ //buscarPDF(n); try { //Generamos el archivo PDF String directorioArchivos; ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); directorioArchivos = ctx.getRealPath("\'") + "reports"; String name = directorioArchivos + "\'document-report.pdf"; //String name="C:\\Users\\Jose_Gascon\\Documents\\NetBeansProjects\\SystemEvent\\target\\SystemEvent-1.0-SNAPSHOT\\reports\\document-report.pdf"; Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(name)); FormatoPDF encabezado = new FormatoPDF(""); Paragraph parrafo, datos, datos1; int i; // indicamos que objecto manejara los eventos al escribir el Pdf writer.setPageEvent(encabezado); document.open(); document.addAuthor("Erick Ramirez"); document.addTitle("Reporte"); //Creamos una cantidad significativa de paginas para probar el encabezado //for (i = 0; i < 4; i++) { parrafo = new Paragraph("Presupuesto de Evento"); parrafo.setAlignment(Element.ALIGN_CENTER); document.add(parrafo); // document.newPage(); //} datos = new Paragraph("Ubicacion: " + event.getUbicacion()); datos1 = new Paragraph("Pais: " + event.getCodigoPais().getNombre()); datos.setAlignment(Element.ALIGN_RIGHT); datos1.setAlignment(Element.ALIGN_RIGHT); document.add(datos1); document.add(datos); document.add(new Paragraph("")); document.add(new Paragraph("")); document.add(new Paragraph("")); document.add(new Paragraph("")); // PdfPTable table = new PdfPTable(2); // // table.addCell("Cliente: "); // table.addCell(event.getIdCliente().getNombre()); // // table.addCell("Descripcion del Evento: "); // table.addCell(event.getDescripcion()); // // document.add(table); document.add(Tabla_compleja()); document.close(); //---------------------------- //Abrimos el archivo PDF FacesContext context = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); response.setContentType("application/pdf"); response.setHeader("Content-disposition", "inline=filename=" + name); try { response.getOutputStream().write(Util.getBytesFromFile(new File(name))); response.getOutputStream().flush(); response.getOutputStream().close(); context.responseComplete(); } catch (IOException e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } }