List of usage examples for com.itextpdf.text Paragraph setFont
public void setFont(final Font font)
From source file:gov.nih.nci.firebird.service.registration.AbstractPdfWriterGenerator.java
License:Open Source License
private void addGenerationDate() throws DocumentException { Paragraph generationDateParagraph = new Paragraph(); generationDateParagraph.setFont(VALUE_FONT); generationDateParagraph.setAlignment(Paragraph.ALIGN_LEFT); generationDateParagraph.add(getFromResources("pdf.generation.date")); generationDateParagraph.add(SPACE_CHARACTER); generationDateParagraph.add(formatFullDate(new Date())); generationDateParagraph.add(Chunk.NEWLINE); generationDateParagraph.add(Chunk.NEWLINE); document.add(generationDateParagraph); }
From source file:Model.Emprestimo.java
private void resultado() { Document documento = new Document(); Livro l;//from w w w . ja va 2 s . c o m try { PdfWriter.getInstance(documento, new FileOutputStream("Emprestimo" + id() + ".pdf")); } catch (DocumentException ex) { Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex); } documento.open(); try { Paragraph pa = new Paragraph(); Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 28, Font.BOLD, new BaseColor(0, 0, 225)); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_CENTER); pa.setSpacingAfter(50); pa.add("Emprestimo"); documento.add(pa); fonte = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("id: " + Integer.toString(id())); documento.add(pa); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("ra: " + Integer.toString(this.getRa())); documento.add(pa); String lin = ""; String[] h = this.Livros.split("/"); for (int c = 0; c < h.length; c++) { l = new Livro(); l.consultar(Integer.parseInt(h[c])); lin = lin + l.getNome() + "\n"; } pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("Livros: " + lin); documento.add(pa); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("Data de Realizao: " + this.dataR); documento.add(pa); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("Data de Devoluo: " + this.dataD); documento.add(pa); } catch (DocumentException ex) { Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex); } documento.close(); }
From source file:org.fossa.rolp.util.PdfStreamSource.java
License:Open Source License
private void addFacheinschaetzungen(Chapter chapterLEB, PdfWriter writer) throws DocumentException, PdfFormatierungsException { for (LebFacheinschaetzungData facheinschaetzungsdaten : lebData.getFacheinschaetzungsdaten()) { sectionCount += 1;/*w ww .j a v a2 s . c o m*/ breakHurenkind(writer); breakSchusterjunge(writer); Paragraph paragraphFacheinschaetzung = new Paragraph(); Section facheinschaetzungsTextSection = chapterLEB.addSection(paragraphFacheinschaetzung); facheinschaetzungsTextSection.setNumberDepth(0); Collection<String> fachbezeichnungen = facheinschaetzungsdaten.getFachbezeichnungen(); fachbezeichnungen.add(facheinschaetzungsdaten.getFachname()); String facheinschaetzung = facheinschaetzungsdaten.getFacheinschaetzung(); Integer firstIndex = null; String boldedWord = ""; for (String fachbezeichnung : fachbezeichnungen) { int index = facheinschaetzung.toLowerCase().indexOf(fachbezeichnung.toLowerCase()); if (index != -1 && (firstIndex == null || firstIndex > index)) { firstIndex = index; boldedWord = fachbezeichnung; } } Paragraph facheinschaetzungParapgraph = new Paragraph(); facheinschaetzungParapgraph.setAlignment(Element.ALIGN_JUSTIFIED); facheinschaetzungParapgraph.setLeading(FIXED_LEADING_TEXT, zeilenabstandsfaktor); if (firstIndex == null) { facheinschaetzungParapgraph.add(new Phrase( facheinschaetzungsdaten.getFacheinschaetzung().replace('\t', '\0'), standardTextFont)); } else { String beforeBoldWord = facheinschaetzung.substring(0, firstIndex); facheinschaetzungParapgraph.add(new Phrase(beforeBoldWord.replace('\t', '\0'), standardTextFont)); String boldWord = facheinschaetzung.substring(firstIndex, firstIndex + boldedWord.length()); facheinschaetzungParapgraph.add(new Phrase(boldWord, standardTextBoldFont)); String afterBoldWord = facheinschaetzung.substring(firstIndex + boldedWord.length()); facheinschaetzungParapgraph.add(new Phrase(afterBoldWord.replace('\t', '\0'), standardTextFont)); } facheinschaetzungParapgraph.setFont(standardTextFont); facheinschaetzungsTextSection.add(facheinschaetzungParapgraph); Paragraph unterschriftParagraph = new Paragraph(); document.add(facheinschaetzungsTextSection); Section facheinschaetzungsUnterschriftSection = chapterLEB.addSection(unterschriftParagraph); facheinschaetzungsUnterschriftSection.setNumberDepth(0); unterschriftParagraph.add( new Phrase(facheinschaetzungsdaten.getUnterschrift().replace('\t', '\0'), standardTextFont)); unterschriftParagraph.setAlignment(Element.ALIGN_RIGHT); unterschriftParagraph.add(Chunk.NEWLINE); unterschriftParagraph.add(Chunk.NEWLINE); document.add(facheinschaetzungsUnterschriftSection); alertHurenkind(writer); insertDummyLineIfNecessary(writer); } }
From source file:org.openmrs.module.tracpatienttransfer.util.FileExporter.java
License:Open Source License
/** * @param request/* w w w . j a v a 2s .co m*/ * @param response * @param res * @param filename * @param title * @throws Exception */ public void exportToPDF(HttpServletRequest request, HttpServletResponse response, List<Integer> res, String filename, String title) throws Exception { SimpleDateFormat sdf = Context.getDateFormat(); Document document = new Document(); response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); // file name PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); writer.setBoxSize("art", new Rectangle(36, 54, 559, 788)); float[] colsWidth = { 1.6f, 2.7f, 2.7f, 8f, 10.5f, 4f, 5f, 7.5f };//, 9.3f }; PdfPTable table = new PdfPTable(colsWidth); // column number HeaderFooter event = new HeaderFooter(table); writer.setPageEvent(event); document.setPageSize(PageSize.A4.rotate()); document.open(); document.addAuthor(Context.getAuthenticatedUser().getPersonName().getFamilyName() + " " + Context.getAuthenticatedUser().getPersonName().getGivenName());// the name of the author ObsService os = Context.getObsService(); FontSelector fontTitle = new FontSelector(); fontTitle.addFont(new Font(FontFamily.HELVETICA, 8.0f, Font.BOLD)); document.add( fontTitle.process(MohTracUtil.getMessage("tracpatienttransfer.report", null) + " : " + title));// Report title document.add(fontTitle.process("\n" + MohTracUtil.getMessage("tracpatienttransfer.report.createdon", null) + " : " + sdf.format(new Date())));// Report date document.add(fontTitle.process("\n" + MohTracUtil.getMessage("tracpatienttransfer.report.createdby", null) + " : " + Context.getAuthenticatedUser().getPersonName()));// Report // author document.add(new Paragraph("\n")); Paragraph para = new Paragraph("" + title.toUpperCase()); para.setAlignment(Element.ALIGN_CENTER); para.setFont(new Font(FontFamily.HELVETICA, 8.0f, Font.BOLD)); document.add(para); table.setWidthPercentage(100.0f); // title row FontSelector fontTitleSelector = new FontSelector(); fontTitleSelector.addFont(new Font(FontFamily.HELVETICA, 8, Font.BOLD)); // top line of table for (int i = 0; i < 8; i++) { PdfPCell pdfPCell = new PdfPCell(fontTitleSelector.process(" ")); pdfPCell.setBorder(PdfPCell.BOTTOM); table.addCell(pdfPCell); } boolean hasRoleToViewPatientsNames = Context.getAuthenticatedUser().hasPrivilege("View Patient Names"); // table Header PdfPCell cell = new PdfPCell( fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.general.number"))); cell.setBorder(Rectangle.LEFT); table.addCell(cell); cell = new PdfPCell(fontTitleSelector.process(Context.getPatientService() .getPatientIdentifierType(TracPatientTransferConfigurationUtil.getTracNetIdentifierTypeId()) .getName())); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell( fontTitleSelector.process(Context.getPatientService() .getPatientIdentifierType( TracPatientTransferConfigurationUtil.getLocalHealthCenterIdentifierTypeId()) .getName())); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); if (hasRoleToViewPatientsNames) { cell = new PdfPCell( fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.general.names"))); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } cell = new PdfPCell( fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.general.reasonofexit"))); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell( fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.general.exitwhen"))); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(fontTitleSelector.process(ContextProvider.getMessage("Encounter.provider"))); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell( fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.report.location"))); cell.setBorder(Rectangle.RIGHT); table.addCell(cell); // cell = new PdfPCell(fontTitleSelector // .process("Resumed? (reason - by who?)")); // cell.setBorder(Rectangle.RIGHT); // table.addCell(cell); // normal row FontSelector fontselector = new FontSelector(); fontselector.addFont(new Font(FontFamily.HELVETICA, 7, Font.NORMAL)); // empty row FontSelector fontEmptyCell = new FontSelector(); fontEmptyCell.addFont(new Font(FontFamily.HELVETICA, 7, Font.NORMAL)); int ids = 0; for (Integer obsId : res) { Obs obs = os.getObs(obsId); Integer patientId = obs.getPersonId(); ids += 1; cell = new PdfPCell(fontselector.process(ids + ".")); if (ids == 1) cell.setBorder(Rectangle.TOP); else cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); String tracnetId = TransferOutInPatientTag.personIdentifierByPatientIdAndIdentifierTypeId(patientId, TracPatientTransferConfigurationUtil.getTracNetIdentifierTypeId()); cell = new PdfPCell(fontselector.process(tracnetId + "")); if (ids == 1) cell.setBorder(Rectangle.TOP); else cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); String localIdentifierTypeId = TransferOutInPatientTag.personIdentifierByPatientIdAndIdentifierTypeId( patientId, TracPatientTransferConfigurationUtil.getLocalHealthCenterIdentifierTypeId()); cell = new PdfPCell(fontselector.process(localIdentifierTypeId + "")); if (ids == 1) cell.setBorder(Rectangle.TOP); else cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); if (hasRoleToViewPatientsNames) { String names = TransferOutInPatientTag.getPersonNames(patientId); cell = new PdfPCell(fontselector.process(names + "")); if (ids == 1) cell.setBorder(Rectangle.TOP); else cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } String conceptValue = TransferOutInPatientTag.conceptValueByObs(obs); conceptValue += ((obs.getValueCoded().getConceptId() .intValue() == TransferOutInPatientConstant.PATIENT_TRANSFERED_OUT) ? " (" + TransferOutInPatientTag.getObservationValueFromEncounter(obs, TransferOutInPatientConstant.TRANSFER_OUT_TO_A_LOCATION) + ")" : (obs.getValueCoded().getConceptId() .intValue() == TransferOutInPatientConstant.PATIENT_DEAD) ? " (" + TransferOutInPatientTag.getObservationValueFromEncounter(obs, TransferOutInPatientConstant.CAUSE_OF_DEATH) + ")" : ""); cell = new PdfPCell(fontselector.process(conceptValue)); if (ids == 1) cell.setBorder(Rectangle.TOP); else cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(fontselector.process(sdf.format(obs.getObsDatetime()))); if (ids == 1) cell.setBorder(Rectangle.TOP); else cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); /* * cell=newPdfPCell(fontselector.process(TransferOutInPatientTag. * getProviderByObs(obs))); if(ids==1) * cell.setBorder(Rectangle.TOP); else * cell.setBorder(Rectangle.NO_BORDER); */table.addCell(cell); cell = new PdfPCell(fontselector.process(obs.getLocation().getName())); if (ids == 1) cell.setBorder(Rectangle.TOP); else cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); // cell = new PdfPCell(fontselector.process(TransferOutInPatientTag // .obsVoidedReason(obs))); // if (ids == 1) // cell.setBorder(Rectangle.TOP); // else // cell.setBorder(Rectangle.NO_BORDER); // table.addCell(cell); } document.add(table); document.close(); log.info("pdf file created"); }
From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java
License:Open Source License
/** * Writes an annotation into the pdf file. * //from www . j av a 2s.c om * @param annotation * @param document * @throws DocumentException */ private void addAnnotationToPDF(String annotation, Document document) throws DocumentException { Paragraph para = new Paragraph(); Font font = FontFactory.getFont(FontFactory.HELVETICA, 12); para.setFont(font); para.setLeading(14F); para.add(annotation); document.add(para); }
From source file:org.openscience.cdk.applications.taverna.renderer.DrawPDF.java
License:Open Source License
public static void drawMoleculesAsPDF(List<IAtomContainer> molecules, File file) throws Exception { Document pdf = new Document(); PdfWriter writer = PdfWriter.getInstance(pdf, new FileOutputStream(file)); pdf.open();/*from w w w . ja v a2 s . co m*/ Paragraph para = new Paragraph(); Font font = FontFactory.getFont(FontFactory.HELVETICA, 24); para.setFont(font); para.setAlignment(Element.ALIGN_CENTER); para.add("CDK-Taverna 2.0"); pdf.add(para); para = new Paragraph(); font = FontFactory.getFont(FontFactory.HELVETICA, 12); para.setFont(font); para.setAlignment(Element.ALIGN_CENTER); para.add("The open-source chemo-/bioinformatics workflow solution\n\n\n"); pdf.add(para); PdfPTable table = new PdfPTable(ncol); for (IAtomContainer molecule : molecules) { PdfPCell cell = new PdfPCell(); cell.disableBorderSide(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT | PdfPCell.TOP); BufferedImage image = Draw2DStructure.drawMolecule(molecule, (int) pdf.getPageSize().getWidth(), height, 0.95); java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage(image.getSource()); cell.addElement(Image.getInstance(awtImage, null)); table.addCell(cell); cell = new PdfPCell(); cell.disableBorderSide(PdfPCell.LEFT | PdfPCell.RIGHT | PdfPCell.TOP); para = new Paragraph(); font = FontFactory.getFont(FontFactory.HELVETICA, 12); para.setFont(font); para.add("\n"); for (Entry<Object, Object> entry : molecule.getProperties().entrySet()) { try { String key = String.valueOf(entry.getKey()); String value = String.valueOf(entry.getValue()); para.add(key + ":\n" + value + "\n\n"); } catch (Exception e) { // Not a String entry --> skip } } cell.addElement(para); table.addCell(cell); } pdf.add(table); pdf.close(); }
From source file:org.sistemafinanciero.rest.impl.CuentaBancariaRESTService.java
License:Apache License
@Override public Response getCertificado(BigInteger id) { OutputStream file;/*from ww w . j a v a 2s. c om*/ CuentaBancariaView cuentaBancaria = cuentaBancariaServiceNT.findById(id); String codigoAgencia = ProduceObject.getCodigoAgenciaFromNumeroCuenta(cuentaBancaria.getNumeroCuenta()); Agencia agencia = agenciaServiceNT.findByCodigo(codigoAgencia); if (agencia == null) { JsonObject model = Json.createObjectBuilder().add("message", "Agencia no encontrado").build(); return Response.status(Response.Status.NOT_FOUND).entity(model).build(); } try { file = new FileOutputStream(new File(certificadoURL + "\\" + id + ".pdf")); //Document document = new Document(PageSize.A5.rotate()); Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, file); document.open(); //recuperando moneda, redondeando y dando formato Moneda moneda = monedaServiceNT.findById(cuentaBancaria.getIdMoneda()); BigDecimal saldo = cuentaBancaria.getSaldo(); BigDecimal decimalValue = saldo.subtract(saldo.setScale(0, RoundingMode.FLOOR)) .movePointRight(saldo.scale()); Long integerValue = saldo.longValue(); String decimalString = decimalValue.toString(); if (decimalString.length() < 2) decimalString = "0" + decimalString; NumberFormat df1 = NumberFormat.getCurrencyInstance(); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setCurrencySymbol(""); dfs.setGroupingSeparator(','); dfs.setMonetaryDecimalSeparator('.'); ((DecimalFormat) df1).setDecimalFormatSymbols(dfs); //recuperando el plazo en dias Date fechaApertura = cuentaBancaria.getFechaApertura(); Date fechaCierre = cuentaBancaria.getFechaCierre(); LocalDate localDateApertura = new LocalDate(fechaApertura); LocalDate localDateCierre = new LocalDate(fechaCierre); Days days = Days.daysBetween(localDateApertura, localDateCierre); //fuentes Font fontTitulo = FontFactory.getFont("Times New Roman", 14, Font.BOLD); Font fontSubTitulo = FontFactory.getFont("Times New Roman", 8); Font fontContenidoNegrita = FontFactory.getFont("Times New Roman", 10, Font.BOLD); Font fontContenidoNormal = FontFactory.getFont("Times New Roman", 10); //dando formato a las fechas DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); String fechaAperturaString = df.format(cuentaBancaria.getFechaApertura()); String fechaVencimientoString = df.format(cuentaBancaria.getFechaCierre()); //ingresando datos al documento document.add(new Paragraph("\n")); document.add(new Paragraph("\n")); //parrafo titulo Paragraph parrafoTitulo = new Paragraph(); parrafoTitulo.setFont(fontTitulo); parrafoTitulo.setSpacingBefore(30); parrafoTitulo.setAlignment(Element.ALIGN_CENTER); //parrafo subtitulo Paragraph parrafoSubTitulo = new Paragraph(); parrafoSubTitulo.setFont(fontSubTitulo); parrafoSubTitulo.setSpacingAfter(30); parrafoSubTitulo.setAlignment(Element.ALIGN_CENTER); //parrafo contenido Paragraph parrafoContenido = new Paragraph(); parrafoContenido.setIndentationLeft(50); parrafoContenido.setAlignment(Element.ALIGN_LEFT); //parrafo firmas Paragraph parrafoFirmas = new Paragraph(); parrafoFirmas.setAlignment(Element.ALIGN_CENTER); //agregar titulo al documento Chunk titulo = new Chunk("CERTIFICADO DE PLAZO FIJO"); parrafoTitulo.add(titulo); //agregar titulo al documento Chunk subTitulo; if (cuentaBancaria.getIdMoneda().compareTo(BigInteger.ZERO) == 0) { subTitulo = new Chunk("DEPSITO A PLAZO FIJO - DOLARES AMERICANOS"); } else if (cuentaBancaria.getIdMoneda().compareTo(BigInteger.ONE) == 0) { subTitulo = new Chunk("DEPSITO A PLAZO FIJO - NUEVOS SOLES"); } else { subTitulo = new Chunk("DEPSITO A PLAZO FIJO - EUROS"); } parrafoSubTitulo.add(subTitulo); //agregando contenido al documento //Agencia Chunk agencia1 = new Chunk("AGENCIA", fontContenidoNegrita); Chunk agencia2 = new Chunk(": " + agencia.getCodigo() + " - " + agencia.getDenominacion().toUpperCase(), fontContenidoNormal); parrafoContenido.add(agencia1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(agencia2); parrafoContenido.add("\n"); //cuenta Chunk numeroCuenta1 = new Chunk("N CUENTA", fontContenidoNegrita); Chunk numeroCuenta2 = new Chunk(": " + cuentaBancaria.getNumeroCuenta(), fontContenidoNormal); parrafoContenido.add(numeroCuenta1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(numeroCuenta2); parrafoContenido.add("\n"); //codigo cliente Chunk codigoSocio1 = new Chunk("CODIGO CLIENTE", fontContenidoNegrita); Chunk codigoSocio2 = new Chunk(": " + cuentaBancaria.getIdSocio().toString(), fontContenidoNormal); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(codigoSocio1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(codigoSocio2); parrafoContenido.add("\n"); //cliente Chunk socio1 = new Chunk("CLIENTE", fontContenidoNegrita); Chunk socio2 = new Chunk(": " + cuentaBancaria.getSocio(), fontContenidoNormal); parrafoContenido.add(socio1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(socio2); parrafoContenido.add("\n"); //tipo cuenta Chunk tipoCuenta1 = new Chunk("TIPO CUENTA", fontContenidoNegrita); Chunk tipoCuenta2 = new Chunk(": " + "INDIVIDUAL", fontContenidoNormal); parrafoContenido.add(tipoCuenta1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(tipoCuenta2); parrafoContenido.add("\n"); //tipo moneda Chunk tipoMoneda1 = new Chunk("TIPO MONEDA", fontContenidoNegrita); Chunk tipoMoneda2; if (cuentaBancaria.getIdMoneda().compareTo(BigInteger.ZERO) == 0) { tipoMoneda2 = new Chunk(": " + "DOLARES AMERICANOS", fontContenidoNormal); } else if (cuentaBancaria.getIdMoneda().compareTo(BigInteger.ONE) == 0) { tipoMoneda2 = new Chunk(": " + "NUEVOS SOLES", fontContenidoNormal); } else { tipoMoneda2 = new Chunk(": " + "EUROS", fontContenidoNormal); } parrafoContenido.add(tipoMoneda1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(tipoMoneda2); parrafoContenido.add("\n"); //Monto Chunk monto1 = new Chunk("MONTO", fontContenidoNegrita); Chunk monto2 = new Chunk(": " + moneda.getSimbolo() + df1.format(saldo) + " - " + NumLetrasJ.Convierte(integerValue.toString() + "", Tipo.Pronombre).toUpperCase() + " Y " + decimalString + "/100 " + moneda.getDenominacion(), fontContenidoNormal); parrafoContenido.add(monto1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(monto2); parrafoContenido.add("\n"); //Plazo Chunk plazo1 = new Chunk("PLAZO", fontContenidoNegrita); Chunk plazo2 = new Chunk(": " + days.getDays() + " D?AS", fontContenidoNormal); parrafoContenido.add(plazo1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(plazo2); parrafoContenido.add("\n"); //Fecha Apertura Chunk fechaApertura1 = new Chunk("FEC. APERTURA", fontContenidoNegrita); Chunk fechaApertura2 = new Chunk(": " + fechaAperturaString, fontContenidoNormal); parrafoContenido.add(fechaApertura1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(fechaApertura2); parrafoContenido.add("\n"); //Fecha Vencimiento Chunk fechaVencimiento1 = new Chunk("FEC. VENCIMIENTO", fontContenidoNegrita); Chunk fechaVencimiento2 = new Chunk(": " + fechaVencimientoString, fontContenidoNormal); parrafoContenido.add(fechaVencimiento1); parrafoContenido.add(Chunk.SPACETABBING); parrafoContenido.add(fechaVencimiento2); parrafoContenido.add("\n"); //tasa efectiva anual Chunk tasaEfectivaAnual1 = new Chunk("TASA EFECTIVA ANUAL", fontContenidoNegrita); Chunk tasaEfectivaAnual2 = new Chunk( ": " + cuentaBancaria.getTasaInteres().multiply(new BigDecimal(100)).toString() + "%", fontContenidoNormal); parrafoContenido.add(tasaEfectivaAnual1); parrafoContenido.add(tasaEfectivaAnual2); parrafoContenido.add("\n"); //frecuencia de capitalizacion Chunk frecuenciaCapitalizacion1 = new Chunk("FREC. CAPITALIZACION", fontContenidoNegrita); Chunk frecuenciaCapitalizacion2 = new Chunk(": " + "DIARIA", fontContenidoNormal); parrafoContenido.add(frecuenciaCapitalizacion1); parrafoContenido.add(frecuenciaCapitalizacion2); parrafoContenido.add("\n"); parrafoContenido.add("\n"); parrafoContenido.add("\n"); //importante Chunk importante = new Chunk("IMPORTANTE: ", fontContenidoNegrita); Chunk importanteDetalle1 = new Chunk( "DEPSITO CUBIERTO POR EL FONDO DE SEGURO DE DEPOSITOS ESTABLECIDO POR EL BANCO CENTRAL DE RESERVA DEL PER HASTA S/.82,073.00.", fontSubTitulo); Chunk importanteDetalle2 = new Chunk( "LAS PERSONAS JUR?DICAS SIN FINES DE LUCRO SON CUBIERTAS POR EL FONDO DE SEGURO DE DEPSITOS.", fontSubTitulo); parrafoContenido.add(importante); parrafoContenido.add(importanteDetalle1); parrafoContenido.add("\n"); parrafoContenido.add(importanteDetalle2); parrafoContenido.add("\n"); parrafoContenido.add("\n"); parrafoContenido.add("\n"); //certificado intranferible Chunk certificadoIntransferible = new Chunk("CERTIFICADO INTRANSFERIBLE.", fontContenidoNegrita); parrafoContenido.add(certificadoIntransferible); parrafoContenido.add("\n"); parrafoContenido.add("\n"); parrafoContenido.add("\n"); parrafoContenido.add("\n"); parrafoContenido.add("\n"); parrafoContenido.add("\n"); parrafoContenido.add("\n"); parrafoContenido.add("\n"); parrafoContenido.add("\n"); //Firmas Chunk subGion = new Chunk("___________________", fontContenidoNormal); Chunk firmaCajero = new Chunk("CAJERO", fontContenidoNormal); Chunk firmaCliente = new Chunk("CLIENTE", fontContenidoNormal); parrafoFirmas.add(subGion); parrafoFirmas.add(Chunk.SPACETABBING); parrafoFirmas.add(Chunk.SPACETABBING); parrafoFirmas.add(subGion); parrafoFirmas.add("\n"); parrafoFirmas.add(firmaCajero); parrafoFirmas.add(Chunk.SPACETABBING); parrafoFirmas.add(Chunk.SPACETABBING); parrafoFirmas.add(Chunk.SPACETABBING); parrafoFirmas.add(firmaCliente); //agregando los parrafos al documento document.add(parrafoTitulo); document.add(parrafoSubTitulo); document.add(parrafoContenido); document.add(parrafoFirmas); document.close(); file.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } PdfReader reader; try { reader = new PdfReader(certificadoURL + "\\" + id + ".pdf"); ByteArrayOutputStream out = new ByteArrayOutputStream(); PdfStamper pdfStamper = new PdfStamper(reader, out); AcroFields acroFields = pdfStamper.getAcroFields(); acroFields.setField("field_title", "test"); pdfStamper.close(); reader.close(); return Response.ok(out.toByteArray()).type("application/pdf").build(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Jsend.getErrorJSend("No encontrado")) .build(); }
From source file:org.smap.sdal.managers.PDFSurveyManager.java
License:Open Source License
private Paragraph getPara(String value, DisplayItem di, GlobalVariables gv, ArrayList<String> deps, Anchor anchor) {// w w w .j ava 2 s. c om boolean hasContent = false; Font f = null; boolean isRtl = false; String lang = ""; Paragraph para = new Paragraph("", defaultFont); if (value != null && value.trim().length() > 0) { lang = GeneralUtilityMethods.getLanguage(value); f = getFont(lang); isRtl = isRtl(lang); para.add(new Chunk(GeneralUtilityMethods.unesc(value), f)); hasContent = true; } // Add dependencies if (deps != null) { for (String n : deps) { if (n != null && n.trim().length() > 0) { if (hasContent) { para.add(new Chunk(",", defaultFont)); } lang = GeneralUtilityMethods.getLanguage(n); f = getFont(lang); if (!isRtl) { // Don't override RTL if it has already been set isRtl = isRtl(lang); } para.add(new Chunk(n, f)); } } } if (anchor != null) { para.setFont(defaultFontLink); para.add(anchor); para.setFont(defaultFontLink); } return para; }
From source file:org.tvd.thptty.management.util.Report.java
private void addTitlePage(Document document) throws DocumentException { Paragraph preface = new Paragraph(); preface.setFont(smallBold); // We add one empty line addEmptyLine(preface, 1);/* www . j a v a 2 s.co m*/ // Lets write a big header preface.add(new Paragraph("Title of Dng 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-2$ //$NON-NLS-3$ //$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:org.tvd.thptty.management.util.Report.java
private void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("First Chapter", catFont); anchor.setName("First Chapter"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategory 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategory 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragraph 1")); subCatPart.add(new Paragraph("Paragraph 2")); subCatPart.add(new Paragraph("Paragraph 3")); // Add a list createList(subCatPart);/*from w ww. j a v a 2 s . co m*/ Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); paragraph.setFont(smallBold); // Add a table paragraph.add(createTable(subCatPart)); subCatPart.add(paragraph); // Now add all this to the document document.add(catPart); // Next section anchor = new Anchor("Second Chapter", catFont); anchor.setName("Second Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph("Subcategory", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("This is a very important message")); // Now add all this to the document document.add(catPart); }