List of usage examples for com.itextpdf.text BaseColor BLACK
BaseColor BLACK
To view the source code for com.itextpdf.text BaseColor BLACK.
Click Source Link
From source file:numerical.CramersRule.java
private void btn_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_saveActionPerformed JFileChooser jfc = new JFileChooser(); jfc.setCurrentDirectory(new File("/My Documents")); int return_val = jfc.showSaveDialog(rootPane); if (return_val == JFileChooser.APPROVE_OPTION) { Document doc = new Document(); try {/*from www . j av a 2 s .co m*/ jfc.getSelectedFile(); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(jfc.getSelectedFile() + ".pdf")); doc.open(); Font f = new Font(Font.FontFamily.TIMES_ROMAN, 12.0f, Font.NORMAL, BaseColor.BLACK); Font f1 = new Font(Font.FontFamily.TIMES_ROMAN, 18.0f, Font.BOLD, BaseColor.BLACK); Paragraph paragraph = new Paragraph(null, f); Paragraph title = new Paragraph(null, f1); title.add("Cramers Rule\n"); paragraph.add(txt_result.getText()); doc.add(title); doc.add(paragraph); doc.close(); writer.close(); JOptionPane.showMessageDialog(rootPane, "Successfully saved!"); } catch (FileNotFoundException | DocumentException | HeadlessException e) { System.err.println(e); } } }
From source file:numerical.Determinants.java
private void btn_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_saveActionPerformed JFileChooser jfc = new JFileChooser(); jfc.setCurrentDirectory(new File("/My Documents")); int return_val = jfc.showSaveDialog(rootPane); if (return_val == JFileChooser.APPROVE_OPTION) { Document doc = new Document(); try {//from w ww . ja va 2 s . c om jfc.getSelectedFile(); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(jfc.getSelectedFile() + ".pdf")); doc.open(); Font f = new Font(Font.FontFamily.TIMES_ROMAN, 12.0f, Font.NORMAL, BaseColor.BLACK); Font f1 = new Font(Font.FontFamily.TIMES_ROMAN, 18.0f, Font.BOLD, BaseColor.BLACK); Paragraph paragraph = new Paragraph(null, f); Paragraph title = new Paragraph(null, f1); title.add("Determinants \n"); paragraph.add(txt_result.getText()); doc.add(title); doc.add(paragraph); doc.close(); writer.close(); JOptionPane.showMessageDialog(rootPane, "Successfully saved!"); } catch (FileNotFoundException | DocumentException | HeadlessException e) { System.err.println(e); } } }
From source file:numerical.Fibonnaci.java
private void btn_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_saveActionPerformed JFileChooser jfc = new JFileChooser(); jfc.setCurrentDirectory(new File("/My Documents")); int return_val = jfc.showSaveDialog(rootPane); if (return_val == JFileChooser.APPROVE_OPTION) { Document doc = new Document(); try {/* www . ja v a 2s. c o m*/ jfc.getSelectedFile(); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(jfc.getSelectedFile() + ".pdf")); doc.open(); Font f = new Font(Font.FontFamily.TIMES_ROMAN, 12.0f, Font.NORMAL, BaseColor.BLACK); Font f1 = new Font(Font.FontFamily.TIMES_ROMAN, 18.0f, Font.BOLD, BaseColor.BLACK); Paragraph paragraph = new Paragraph(null, f); Paragraph title = new Paragraph(null, f1); title.add("Fibonnaci\n"); paragraph.add("Sequence number: " + count + "\n"); paragraph.add("Result: "); paragraph.add(txt_result.getText()); doc.add(title); doc.add(paragraph); doc.close(); writer.close(); JOptionPane.showMessageDialog(rootPane, "Successfully saved!"); } catch (FileNotFoundException | DocumentException | HeadlessException e) { System.err.println(e); } } }
From source file:om.edu.squ.squportal.portlet.tsurvey.dao.pdf.TeachingSurveyPdfImpl.java
License:Open Source License
/** * // w ww . j ava2s.c o m * method name : getPdfSurveyAnalysis * @param object * @param semesterYear * @param questionByYear * @param questionSetNo * @param byos * @param inputStream * @param res * @return * @throws DocumentException * @throws IOException * TeachingSurveyPdfImpl * return type : OutputStream * * purpose : Generate PDF content * * Date : Mar 28, 2016 7:21:04 PM */ public OutputStream getPdfSurveyAnalysis(Object object, String semesterYear, String questionByYear, int questionSetNo, ByteArrayOutputStream byos, InputStream inputStream, ResourceResponse res) throws DocumentException, IOException { Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK); PdfReader pdfTemplate = new PdfReader(inputStream); PdfStamper pdfStamper = new PdfStamper(pdfTemplate, byos); Survey survey = (Survey) object; String sectionNos = ""; String seatsTaken = ""; DecimalFormat formatter = new DecimalFormat("###.##"); String RIGHT = Constants.RIGHT; String CENTER = Constants.CENTER; String LEFT = Constants.LEFT; pdfStamper.getAcroFields().setField("txtCourse", survey.getCourseCode() + " / " + survey.getCourseName()); pdfStamper.getAcroFields().setField("txtCollegeName", survey.getCollegeName()); for (SurveyResponse resp : survey.getSurveyResponses()) { sectionNos = sectionNos + resp.getSectionNo() + " "; seatsTaken = String.valueOf(resp.getSeatsTaken()); } pdfStamper.getAcroFields().setField("txtSectionNo", sectionNos); pdfStamper.getAcroFields().setField("txtDepartmentName", survey.getDepartmentName()); pdfStamper.getAcroFields().setField("txtEmpName", survey.getEmpName()); pdfStamper.getAcroFields().setField("txtStudentRegistered", seatsTaken); pdfStamper.getAcroFields().setField("txtSemesterYear", semesterYear); pdfStamper.getAcroFields().setGenerateAppearances(true); /* ****************** */ PdfPTable table = new PdfPTable(13); table.addCell(getPdfCell("", 2, 0, font, LEFT)); table.addCell(getPdfCell( UtilProperty.getMessage("prop.course.teaching.survey.analysis.course.teaching.items", null), 2, 0, font, CENTER)); table.addCell( getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.response.number", null), 0, 6, font, CENTER)); table.addCell(getPdfCell( UtilProperty.getMessage("prop.course.teaching.survey.analysis.response.percentage", null), 2, 0, font, CENTER)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.mean", null), 0, 4, font, CENTER)); table.addCell( getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.disagree.strong", null), 0, 0, font, CENTER)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.disagree", null), 0, 0, font, CENTER)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.agree", null), 0, 0, font, CENTER)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.agree.strong", null), 0, 0, font, CENTER)); table.addCell( getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.applicable.not", null), 0, 0, font, CENTER)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.total", null), 0, 0, font, CENTER)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.sect", null), 0, 0, font, CENTER)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.crs", null), 0, 0, font, CENTER)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.dept", null), 0, 0, font, CENTER)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.col", null), 0, 0, font, CENTER)); /* ---------------------------------------------------------------------------- */ table.addCell(getPdfCell("", 0, 0, font)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.course.items", null), 0, 12, font, CENTER)); int cTotal = 0; float cPctVal = 0f; float cSectionMean = 0f; float cCourseMean = 0f; float cDepart = 0f; float cCollege = 0f; int rowCount = 0; for (SurveyResponse sures : survey.getSurveyResponses()) { for (Analysis analysis : sures.getAnalysisList()) { if (analysis.getQuestion().equals("Q2") || analysis.getQuestion().equals("Q14") || analysis.getQuestion().equals(questionByYear)) { /*** First part ***/ table.addCell(getPdfCell(analysis.getQuestion(), 0, 0, font)); table.addCell( getPdfCell( UtilProperty.getMessage("prop.course.teaching.survey.analysis.set" + questionSetNo + ".question" + analysis.getQuestionLabel(), null), 0, 0, font, LEFT)); table.addCell(getPdfCell(String.valueOf(analysis.getStrongDisagree()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getDisAgree()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getAgree()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getStrongAgree()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getNotApplicable()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getTotal()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getPercentageResponse()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getSectionMean()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getCourseMean()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getDepartmentMean()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getCollegeMean()), 0, 0, font, RIGHT)); cTotal = cTotal + analysis.getTotal(); cPctVal = cPctVal + analysis.getPercentageResponse(); cSectionMean = cSectionMean + analysis.getSectionMean(); cCourseMean = cCourseMean + analysis.getCollegeMean(); cDepart = cDepart + analysis.getDepartmentMean(); cCollege = cCollege + analysis.getCollegeMean(); rowCount = rowCount + 1; } } } /*** First part - Summary ***/ table.addCell(getPdfCell(String.valueOf(""), 0, 0, font)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.summary", null), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(""), 0, 5, font)); table.addCell(getPdfCell(String.valueOf(cTotal), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cPctVal / rowCount)), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cSectionMean / rowCount)), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cCourseMean / rowCount)), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cDepart / rowCount)), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cCollege / rowCount)), 0, 0, font, RIGHT)); table.addCell(getPdfCell("", 0, 13, font)); table.addCell(getPdfCell("", 0, 0, font)); table.addCell( getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.teaching.items", null), 0, 12, font, LEFT)); cTotal = 0; cPctVal = 0f; cSectionMean = 0f; cCourseMean = 0f; cDepart = 0f; cCollege = 0f; rowCount = 0; for (SurveyResponse sures : survey.getSurveyResponses()) { for (Analysis analysis : sures.getAnalysisList()) { if (!(analysis.getQuestion().equals("Q2") || analysis.getQuestion().equals("Q14") || analysis.getQuestion().equals(questionByYear))) { table.addCell(getPdfCell(analysis.getQuestion(), 0, 0, font)); table.addCell( getPdfCell( UtilProperty.getMessage("prop.course.teaching.survey.analysis.set" + questionSetNo + ".question" + analysis.getQuestionLabel(), null), 0, 0, font, LEFT)); table.addCell(getPdfCell(String.valueOf(analysis.getStrongDisagree()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getDisAgree()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getAgree()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getStrongAgree()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getNotApplicable()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getTotal()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getPercentageResponse()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getSectionMean()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getCourseMean()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getDepartmentMean()), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(analysis.getCollegeMean()), 0, 0, font, RIGHT)); cTotal = cTotal + analysis.getTotal(); cPctVal = cPctVal + analysis.getPercentageResponse(); cSectionMean = cSectionMean + analysis.getSectionMean(); cCourseMean = cCourseMean + analysis.getCollegeMean(); cDepart = cDepart + analysis.getDepartmentMean(); cCollege = cCollege + analysis.getCollegeMean(); rowCount = rowCount + 1; } } } /*** Second part - Summary ***/ table.addCell(getPdfCell(String.valueOf(""), 0, 0, font)); table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.summary", null), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(""), 0, 5, font)); table.addCell(getPdfCell(String.valueOf(cTotal), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cPctVal / rowCount)), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cSectionMean / rowCount)), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cCourseMean / rowCount)), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cDepart / rowCount)), 0, 0, font, RIGHT)); table.addCell(getPdfCell(String.valueOf(formatter.format(cCollege / rowCount)), 0, 0, font, RIGHT)); if (!survey.getMessage().equals("")) { table.addCell(getPdfCell("", 0, 13, font)); table.addCell(getPdfCell("", 0, 0, font)); table.addCell(getPdfCell(survey.getMessage(), 0, 12, font, CENTER)); } table.setTotalWidth(750); table.setLockedWidth(true); table.setWidths(new float[] { 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); ColumnText column = new ColumnText(pdfStamper.getOverContent(1)); Rectangle rectPage1 = new Rectangle(120, 20, 659, 480); column.setSimpleColumn(rectPage1); column.addElement(table); int status = column.go(); pdfStamper.setFormFlattening(true); pdfStamper.close(); pdfTemplate.close(); res.setContentType("application/pdf"); return res.getPortletOutputStream(); }
From source file:Operaciones.Destajo.java
public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla) { Session session = HibernateUtil.getSessionFactory().openSession(); try {/*from w w w. jav a 2 s . co m*/ reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorStroke(new GrayColor(0.2f)); reporte.contenido.setColorFill(new GrayColor(0.9f)); reporte.contenido.roundRectangle(160, 515, 210, 45, 5); reporte.contenido.roundRectangle(380, 515, 375, 45, 5); reporte.contenido.roundRectangle(35, 480, 720, 30, 5); reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 14); reporte.contenido.setColorFill(BaseColor.BLACK); Configuracion con = (Configuracion) session.get(Configuracion.class, 1); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 160, 580, 0); reporte.contenido.setFontAndSize(bf, 8); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Hoja de Avance", 160, 570, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 760, 580, 0); Orden dato = (Orden) session.get(Orden.class, Integer.parseInt(ord)); Foto foto = (Foto) session.createCriteria(Foto.class) .add(Restrictions.eq("orden.idOrden", Integer.parseInt(ord))).addOrder(Order.desc("fecha")) .setMaxResults(1).uniqueResult(); if (foto != null) { reporte.agregaObjeto(reporte.crearImagen( "ordenes/" + dato.getIdOrden() + "/" + foto.getDescripcion(), 0, -60, 120, 80, 0)); } else { } //************************datos de la orden**************************** reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Orden:" + dato.getIdOrden(), 164, 550, 0); if (dato.getFecha() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:" + dato.getFecha(), 285, 550, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:", 285, 550, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Compaia:" + dato.getCompania().getIdCompania() + " " + dato.getCompania().getNombre(), 164, 540, 0); if (dato.getSiniestro() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:" + dato.getSiniestro(), 164, 530, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:", 164, 530, 0); if (dato.getFechaSiniestro() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "F. Siniestro:" + dato.getFechaSiniestro(), 285, 530, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "F.Siniestro:", 285, 530, 0); if (dato.getPoliza() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:" + dato.getPoliza(), 164, 520, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:", 164, 520, 0); if (dato.getInciso() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Inciso:" + dato.getInciso(), 285, 520, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Inciso:", 285, 520, 0); //********************************************************** //************datos de la unidad reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Unidad:" + dato.getTipo().getTipoNombre(), 385, 550, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Modelo:" + dato.getModelo(), 664, 550, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Marca:" + dato.getMarca().getMarcaNombre(), 385, 540, 0); if (dato.getNoEconomico() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:" + dato.getNoEconomico(), 664, 540, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:", 664, 540, 0); if (dato.getNoMotor() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:" + dato.getNoMotor(), 385, 530, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:", 385, 530, 0); if (dato.getNoSerie() != null) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:" + dato.getNoSerie(), 385, 520, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:", 385, 520, 0); //************************************************************* switch (this.global) { case "h": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Hojalateria", 40, 495, 0); break; case "m": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Mecanica", 40, 495, 0); break; case "s": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Suspension", 40, 495, 0); break; case "e": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: electrico", 40, 495, 0); break; case "p": reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Pintura", 40, 495, 0); break; } reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Empleado:" + t_responsable.getText(), 165, 495, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Fecha Asignacin:" + t_asignacion.getText(), 430, 495, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Fecha Limite:" + t_limite.getText(), 600, 495, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Monto x Hora: $" + t_monto.getText(), 40, 485, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Horas Totales: " + t_horas.getText(), 165, 485, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Importe a Pagar: $" + t_importe.getText(), 600, 485, 0); reporte.finTexto(); //agregamos renglones vacios para dejar un espacio reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; tabla.addCell(reporte.celda("Fecha Avance", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("% de Avance", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Importe Pagado", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Notas", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); } catch (Exception e) { System.out.println(e); } if (session != null) if (session.isOpen()) { session.flush(); session.clear(); session.close(); } }
From source file:org.dspace.disseminate.CitationDocument.java
/** * Takes a DSpace {@link Bitstream} and uses its associated METADATA to * create a cover page./*from w w w .j a v a 2s. c o m*/ * * @param cDoc The cover page document to add cited information to. * @param writer * @param cMeta * METADATA retrieved from the parent collection. * @throws IOException * @throws DocumentException */ private void generateCoverPage(Document cDoc, PdfWriter writer, CitationMeta cMeta) throws DocumentException { cDoc.open(); writer.setCompressionLevel(0); Item item = cMeta.getItem(); //Set up some fonts Font helv26 = FontFactory.getFont(FontFactory.HELVETICA, 26f, BaseColor.BLACK); Font helv16 = FontFactory.getFont(FontFactory.HELVETICA, 16f, BaseColor.BLACK); Font helv12 = FontFactory.getFont(FontFactory.HELVETICA, 12f, BaseColor.BLACK); Font helv12_italic = FontFactory.getFont(FontFactory.HELVETICA_OBLIQUE, 12f, BaseColor.BLACK); Font helv11_bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11f, BaseColor.BLACK); Font helv9 = FontFactory.getFont(FontFactory.HELVETICA, 9f, BaseColor.BLACK); // 1 - Header: // University Name // Repository Name repository.url Paragraph university = new Paragraph("The Ohio State University", helv11_bold); cDoc.add(university); PdfPTable repositoryTable = new PdfPTable(2); repositoryTable.setWidthPercentage(100); Chunk repositoryName = new Chunk("Knowledge Bank", helv11_bold); PdfPCell nameCell = new PdfPCell(); nameCell.setBorderWidth(0); nameCell.addElement(repositoryName); Chunk repositoryURL = new Chunk("kb.osu.edu", helv11_bold); repositoryURL.setAnchor("http://kb.osu.edu"); PdfPCell urlCell = new PdfPCell(); urlCell.setHorizontalAlignment(Element.ALIGN_RIGHT); urlCell.setBorderWidth(0); urlCell.addElement(repositoryURL); repositoryTable.addCell(nameCell); repositoryTable.addCell(urlCell); repositoryTable.setSpacingAfter(5); cDoc.add(repositoryTable); // Line Separator LineSeparator lineSeparator = new LineSeparator(); cDoc.add(lineSeparator); // 2 - Bread Crumbs // Community Name Collection Name PdfPTable breadcrumbTable = new PdfPTable(2); breadcrumbTable.setWidthPercentage(100); Chunk communityName = new Chunk(getOwningCommunity(item), helv9); PdfPCell commCell = new PdfPCell(); commCell.setBorderWidth(0); commCell.addElement(communityName); Chunk collectionName = new Chunk(getOwningCollection(item), helv9); PdfPCell collCell = new PdfPCell(); collCell.setHorizontalAlignment(Element.ALIGN_RIGHT); collCell.setBorderWidth(0); collCell.addElement(collectionName); breadcrumbTable.addCell(commCell); breadcrumbTable.addCell(collCell); breadcrumbTable.setSpacingBefore(5); breadcrumbTable.setSpacingAfter(5); cDoc.add(breadcrumbTable); // Line Separator cDoc.add(lineSeparator); // 3 - Metadata // date.issued // dc.title // dc.creator; dc.creator Paragraph dateIssued = new Paragraph(getFirstMetadata(item, "dc.date.issued"), helv12); dateIssued.setSpacingBefore(20); cDoc.add(dateIssued); Paragraph title = new Paragraph(item.getName(), helv26); title.setSpacingBefore(15); cDoc.add(title); Paragraph creators = new Paragraph(getAllMetadataSeperated(item, "dc.creator"), helv16); creators.setSpacingBefore(30); creators.setSpacingAfter(20); cDoc.add(creators); // Line Separator cDoc.add(lineSeparator); // 4 - Citation // dc.identifier.citation // dc.identifier.uri Paragraph citation = new Paragraph(getFirstMetadata(item, "dc.identifier.citation"), helv12); Chunk identifierChunk = new Chunk(getFirstMetadata(item, "dc.identifier.uri"), helv12); identifierChunk.setAnchor(getFirstMetadata(item, "dc.identifier.uri")); Paragraph identifier = new Paragraph(); identifier.add(identifierChunk); cDoc.add(citation); cDoc.add(identifier); // 5 - License // Downloaded from the Knowledge Bank, The Ohio State University's institutional repository Paragraph license = new Paragraph( "Downloaded from the Knowledge Bank, The Ohio State University's institutional repository", helv12_italic); license.setSpacingBefore(10); cDoc.add(license); cDoc.close(); }
From source file:org.durel.mydooble.PDF.java
License:Open Source License
public void newCard() { col++;//from w w w .j a v a2 s. c o m if (col > (COL_NUM - 1)) { col = 0; row++; if (row > (ROW_NUM - 1)) newPage(); } float x1 = col * (WIDTH + MARGIN) + MARGIN; float x2 = (col + 1) * (WIDTH + MARGIN); float y2 = (row + 1) * (HEIGHT + MARGIN); float y1 = row * (HEIGHT + MARGIN) + MARGIN; cardBox = new Rectangle(x1, y1, x2, y2); try { PdfContentByte cb = writer.getDirectContent(); cb.saveState(); cardBox.setBorderWidth(1.2f); cardBox.setBorderColor(BaseColor.BLACK); cardBox.setBorder(Rectangle.BOX); cb.rectangle(cardBox); cb.stroke(); cb.restoreState(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.javad.pdf.PageTitle.java
License:Apache License
@Override public OutputBounds generate(PdfContentByte content) { int maxWidth = 0; content.setColorStroke(BaseColor.BLACK); Font f = FontRegistry.getInstance().getFont(PdfFontDefinition.Title); content.setFontAndSize(f.getBaseFont(), f.getSize()); float top = getY(); content.setHorizontalScaling(110.0f); if (getTitle() != null && !getTitle().isEmpty()) { maxWidth = (int) f.getBaseFont().getWidthPoint(getTitle().toUpperCase(), f.getSize()); PdfUtil.renderConstrainedText(content, getTitle().toUpperCase(), f, getX(), top, (int) (maxWidth * 1.1)); }/*from w w w.j ava2 s . c o m*/ if (getSubTitle() != null && !getSubTitle().isEmpty()) { Font subFont = FontRegistry.getInstance().getFont(PdfFontDefinition.Subtitle); top -= subFont.getCalculatedSize() + PdfUtil.convertFromMillimeters(3.0f); content.setFontAndSize(subFont.getBaseFont(), subFont.getSize()); maxWidth = Math.max(maxWidth, (int) subFont.getBaseFont().getWidthPoint(getSubTitle().toUpperCase(), subFont.getSize())); PdfUtil.renderConstrainedText(content, getSubTitle().toUpperCase(), subFont, getX(), top, (int) (maxWidth * 1.10)); } content.setHorizontalScaling(100.0f); if (getClassifier() != null && !getClassifier().isEmpty()) { Font classFont = FontRegistry.getInstance().getFont(PdfFontDefinition.Classifier); content.setFontAndSize(classFont.getBaseFont(), classFont.getSize()); top -= classFont.getCalculatedSize() + PdfUtil.convertFromMillimeters(3.0f); float width = classFont.getBaseFont().getWidthPoint(getClassifier(), classFont.getCalculatedSize()) + 4; maxWidth = Math.max(maxWidth, (int) width + (2 * DASH_LENGTH)); content.setLineWidth(0.8f); float lineTop = top + ((int) classFont.getSize() / 2 - 1); content.moveTo(getX() - (width / 2) - DASH_LENGTH, lineTop); content.lineTo(getX() - (width / 2), lineTop); content.moveTo(getX() + (width / 2), lineTop); content.lineTo(getX() + (width / 2) + DASH_LENGTH, lineTop); content.stroke(); PdfUtil.renderConstrainedText(content, getClassifier(), classFont, getX(), top, (int) (maxWidth * 1.10)); } OutputBounds rect = new OutputBounds(getX() - maxWidth / 2, getY(), maxWidth, getY() - top); return rect; }
From source file:org.javad.pdf.TitlePageContent.java
License:Apache License
@Override public OutputBounds generate(PdfContentByte content) { if (isSkipped()) { return new OutputBounds(getX(), getY(), 0, 0); }//from w ww. j a v a 2 s . c o m int maxWidth = 0; float top = getY() - PdfUtil.convertFromMillimeters( (configuration.getHeight() - configuration.getMarginBottom() - configuration.getMarginTop()) / 2); if (getImage() != null) { try { com.itextpdf.text.Image img = determineScaledImage(getImage()); if (img != null) { content.addImage(img); top = img.getAbsoluteY() - PdfUtil.convertFromMillimeters(25.0f); } } catch (Exception e) { logger.log(Level.FINER, "An error occured scaling the image. ", e); } } content.setColorStroke(BaseColor.BLACK); Font f = FontRegistry.getInstance().getFont(PdfFontDefinition.AlbumTitle); content.setFontAndSize(f.getBaseFont(), f.getSize()); content.setHorizontalScaling(110.0f); if (getTitle() != null && !getTitle().isEmpty()) { maxWidth = (int) f.getBaseFont().getWidthPoint(getTitle().toUpperCase(), f.getSize()); PdfUtil.renderConstrainedText(content, getTitle().toUpperCase(), f, getX(), top, maxWidth); } if (getSubTitle() != null && !getSubTitle().isEmpty()) { Font subFont = FontRegistry.getInstance().getFont(PdfFontDefinition.AlbumSubtitle); top -= subFont.getCalculatedSize() + PdfUtil.convertFromMillimeters(3.0f); content.setFontAndSize(subFont.getBaseFont(), subFont.getSize()); maxWidth = Math.max(maxWidth, (int) content.getEffectiveStringWidth(getSubTitle().toUpperCase(), false)); PdfUtil.renderConstrainedText(content, getSubTitle().toUpperCase(), subFont, getX(), top, maxWidth); } if (getDescription() != null && !getDescription().isEmpty()) { Font subFont = FontRegistry.getInstance().getFont(PdfFontDefinition.AlbumDescription); top -= PdfUtil.convertFromMillimeters(15.0f); float width = PdfUtil.convertFromMillimeters( (configuration.getWidth() - configuration.getMarginLeft() - configuration.getMarginRight()) / 2); content.setFontAndSize(subFont.getBaseFont(), subFont.getSize()); top += PdfUtil.renderConstrainedText(content, getDescription(), subFont, width + PdfUtil.convertFromMillimeters(configuration.getMarginLeft()), top, (int) (width * 0.7f)); } if (!getItems().isEmpty()) { Font subFont = FontRegistry.getInstance().getFont(PdfFontDefinition.AlbumContents); top -= subFont.getCalculatedSize() + PdfUtil.convertFromMillimeters(6.0f); content.setFontAndSize(subFont.getBaseFont(), subFont.getSize()); for (String s : getItems()) { maxWidth = Math.max(maxWidth, (int) subFont.getBaseFont().getWidthPoint(s, subFont.getSize())); PdfUtil.renderConstrainedText(content, s, subFont, getX(), top, maxWidth); top -= PdfUtil.convertFromMillimeters(3.0f); } } content.setHorizontalScaling(100.0f); OutputBounds rect = new OutputBounds(getX() - maxWidth / 2, getY(), maxWidth, getY() - top); return rect; }
From source file:org.javad.stamp.pdf.CompositeRow.java
License:Apache License
@Override public OutputBounds generate(PdfContentByte content) { if (isSkipped()) { return new OutputBounds(getX(), getY(), 0, 0); }/*from w w w. j av a 2 s . co m*/ float maxHeight = 0.0f; float maxWidth = 0.0f; float top = getY(); if (getDescription() != null && !getDescription().isEmpty()) { content.setColorStroke(BaseColor.BLACK); Font descFont = FontRegistry.getInstance().getFont(PdfFontDefinition.CompositeSetDescription); content.setFontAndSize(descFont.getBaseFont(), descFont.getSize()); top -= descFont.getCalculatedSize(); int count = 0; int tc = getDescription().split("\n").length; for (String desc : getDescription().split("\n")) { maxWidth = Math.max(maxWidth, content.getEffectiveStringWidth(desc, false)); PdfUtil.renderConstrainedText(content, desc, descFont, getX(), top, (int) maxWidth); count++; top -= descFont.getCalculatedSize() + ((count < tc) ? 2 : 4); } } float totalWidth = 0.0f; float totalHeight = getY() - top; float spacing = PdfUtil.convertFromMillimeters(getSpacingMode().getSpacing(box_spacing)); int count = 0; for (int i = 0; i < rows.size(); i++) { StampRow set = rows.get(i); if (set.isSkipped()) { continue; } totalWidth += PdfUtil.findMaximumWidth(set, content) + ((count > 0) ? spacing : 0.0f); count++; } float cur_x = getX() - totalWidth / 2.0f; count = 0; for (StampRow set : rows) { if (set.isSkipped()) { continue; } set.setX(cur_x + PdfUtil.findMaximumWidth(set, content) / 2.0f); set.setY(top); OutputBounds rect = set.generate(content); count++; cur_x += rect.width + ((count > 0) ? spacing : 0); maxHeight = Math.max(maxHeight, rect.height); } maxWidth = Math.max(maxWidth, totalWidth); totalHeight += maxHeight; return new OutputBounds(getX() - (maxWidth / 2.0f), getY(), maxWidth, totalHeight); }