List of usage examples for com.itextpdf.text BaseColor WHITE
BaseColor WHITE
To view the source code for com.itextpdf.text BaseColor WHITE.
Click Source Link
From source file:de.domjos.schooltools.helper.ApiHelper.java
License:Open Source License
public PDFBuilder exportTimeTableToPDF(PDFBuilder pdfBuilder, TimeTable timeTable, List<String> headers, SQLite sqLite) throws Exception { pdfBuilder.addTitle(timeTable.getTitle(), "header", Paragraph.ALIGN_CENTER); pdfBuilder.addEmptyLine(3);//from ww w .jav a 2 s.c o m String content = "%s%n%s%n%s"; String classTitle = ""; if (timeTable.getSchoolClass() != null) { classTitle = this.context.getString(R.string.timetable_class) + ": " + timeTable.getSchoolClass().getTitle(); } String yearTitle = ""; if (timeTable.getYear() != null) { yearTitle = this.context.getString(R.string.mark_year) + ": " + timeTable.getYear().getTitle(); } String description = ""; if (!timeTable.getDescription().isEmpty()) { description = this.context.getString(R.string.sys_description) + "\n" + timeTable.getDescription(); } content = String.format(content, yearTitle, classTitle, description); pdfBuilder.addParagraph("", content, "header", "CONTENT_PARAM"); pdfBuilder.addEmptyLine(2); List<List<Map.Entry<String, BaseColor>>> tblCells = new LinkedList<>(); List<Hour> hours = sqLite.getHours(""); for (Hour hour : hours) { if (hour.isBreak()) { List<Map.Entry<String, BaseColor>> tblRows = new LinkedList<>(); tblRows.add(new AbstractMap.SimpleEntry<>(hour.getStart() + " - " + hour.getEnd(), BaseColor.GRAY)); for (int i = 0; i <= 6; i++) { tblRows.add(new AbstractMap.SimpleEntry<>("", BaseColor.GRAY)); } tblCells.add(tblRows); } else { List<Map.Entry<String, BaseColor>> tblRows = new LinkedList<>(); tblRows.add( new AbstractMap.SimpleEntry<>(hour.getStart() + " - " + hour.getEnd(), BaseColor.WHITE)); for (int i = 0; i <= 6; i++) { tblRows.add(new AbstractMap.SimpleEntry<>("", BaseColor.WHITE)); } tblCells.add(tblRows); } } for (int column = 0; column <= timeTable.getDays().length - 1; column++) { Day day = timeTable.getDays()[column]; int tmp = 0; if (day != null) { if (MainActivity.globals.getUserSettings().isTimeTableMode()) { Object[] objArray = day.getTeacherHour().values().toArray(); int row = 0; for (Hour hour : hours) { if (objArray.length < tmp + 1) { break; } if (objArray[tmp] instanceof TeacherHour) { for (Map.Entry<Hour, TeacherHour> entry : day.getTeacherHour().entrySet()) { if (entry.getKey().getID() == hour.getID()) { Subject subject = entry.getValue().getSubject(); String roomNumber = entry.getValue().getRoomNumber(); if (tblCells.get(row).get(0).getValue() != BaseColor.GRAY) { tblCells.get(row).set(column + 1, new AbstractMap.SimpleEntry<>( subject.getAlias() + "\n" + roomNumber, new BaseColor(Integer.parseInt(subject.getBackgroundColor())))); tmp++; } break; } } } row++; } } else { Object[] objArray = day.getPupilHour().values().toArray(); int row = 0; for (Hour hour : hours) { if (objArray.length < tmp + 1) { break; } if (objArray[tmp] instanceof PupilHour) { for (Map.Entry<Hour, PupilHour> entry : day.getPupilHour().entrySet()) { if (entry.getKey().getID() == hour.getID()) { Subject subject = entry.getValue().getSubject(); String roomNumber = entry.getValue().getRoomNumber(); if (tblCells.get(row).get(0).getValue() != BaseColor.GRAY) { tblCells.get(row).set(column + 1, new AbstractMap.SimpleEntry<>( subject.getAlias() + "\n" + roomNumber, new BaseColor(Integer.parseInt(subject.getBackgroundColor())))); tmp++; } break; } } } row++; } } } } pdfBuilder.addTable(headers, new float[] { 20.0f, 15.0f, 15.0f, 15.0f, 15.0f, 15.0f, 15.0f, 15.0f }, tblCells); pdfBuilder.newPage(); return pdfBuilder; }
From source file:de.domjos.schooltools.helper.ApiHelper.java
License:Open Source License
public PDFBuilder exportToDoListToPDF(PDFBuilder pdfBuilder, ToDoList toDoList) throws Exception { pdfBuilder.addTitle(toDoList.getTitle(), "header", Paragraph.ALIGN_CENTER); pdfBuilder.addTitle(Converter.convertDateToString(toDoList.getListDate()), "subHeader", Paragraph.ALIGN_CENTER);//w w w.ja v a 2 s . co m pdfBuilder.addParagraph(this.context.getString(R.string.sys_description), toDoList.getDescription(), "subHeader", "CONTENT_PARAM"); pdfBuilder.addEmptyLine(3); List<String> headerList = Arrays.asList(this.context.getString(R.string.sys_title), this.context.getString(R.string.todo_category), this.context.getString(R.string.sys_memory), this.context.getString(R.string.sys_description), "", this.context.getString(R.string.todo_solved)); List<List<Map.Entry<String, BaseColor>>> ls = new LinkedList<>(); for (ToDo toDo : toDoList.getToDos()) { List<Map.Entry<String, BaseColor>> toDoEntry = new LinkedList<>(); toDoEntry.add(new AbstractMap.SimpleEntry<>(toDo.getTitle(), BaseColor.WHITE)); toDoEntry.add(new AbstractMap.SimpleEntry<>(toDo.getCategory(), BaseColor.WHITE)); toDoEntry.add(new AbstractMap.SimpleEntry<>(Converter.convertDateToString(toDo.getMemoryDate()), BaseColor.WHITE)); toDoEntry.add(new AbstractMap.SimpleEntry<>(toDo.getDescription(), BaseColor.WHITE)); toDoEntry.add(new AbstractMap.SimpleEntry<>(String.valueOf(toDo.getImportance()), BaseColor.WHITE)); toDoEntry.add(new AbstractMap.SimpleEntry<>(String.valueOf(toDo.isSolved()), BaseColor.WHITE)); ls.add(toDoEntry); } pdfBuilder.addTable(headerList, null, ls); pdfBuilder.newPage(); return pdfBuilder; }
From source file:de.jost_net.JVerein.io.Reporter.java
License:Open Source License
/** * Fuegt eine neue Zelle mit einem boolean-Value zur Tabelle hinzu *///from w w w . ja v a 2 s .c o m public void addColumn(boolean value) { addColumn(value ? "X" : "", Element.ALIGN_CENTER, BaseColor.WHITE, true); }
From source file:de.jost_net.JVerein.io.Reporter.java
License:Open Source License
/** * Fuegt eine neue Zelle zur Tabelle hinzu. *//*from w w w . j av a 2 s . co m*/ public void addColumn(String text, int align) { addColumn(getDetailCell(text, align, BaseColor.WHITE, true)); }
From source file:de.jost_net.JVerein.io.Reporter.java
License:Open Source License
/** * Fuegt eine neue Zelle zur Tabelle hinzu. */// ww w. j a v a2s . co m public void addColumn(String text, int align, boolean silbentrennung) { addColumn(getDetailCell(text, align, BaseColor.WHITE, silbentrennung)); }
From source file:de.jost_net.JVerein.io.Reporter.java
License:Open Source License
public void addColumn(String text, int align, int colspan) { addColumn(getDetailCell(text, align, BaseColor.WHITE, colspan)); }
From source file:de.jost_net.JVerein.io.Reporter.java
License:Open Source License
/** * Erzeugt eine Zelle der Tabelle.// ww w . j a v a 2 s .c o m * * @param text * der anzuzeigende Text. * @param align * die Ausrichtung. * @return die erzeugte Zelle. */ private PdfPCell getDetailCell(String text, int align, boolean silbentrennung) { return getDetailCell(text, align, BaseColor.WHITE, silbentrennung); }
From source file:EplanPrinter.PDFPrint.java
License:Open Source License
public String insertStamp(String loc, float x, float y, int width, int height, int set, String date, int pageNum, int masterHeight, int masterWidth, String projNo) throws BadElementException, MalformedURLException, IOException, DocumentException { Image image = Image.getInstance(loc); float[] scalar = scale(x, y, width, height, masterHeight, masterWidth, pageNum); float[] trans = translate(x, y, r[pageNum - 1].getHeight(), r[pageNum - 1].getWidth(), masterHeight, masterWidth, pageNum);//ww w . java2 s . co m float[] f = commentTrans(x, y, masterHeight, masterWidth, pageNum); float shift = 0; /* Addition. ftorres - 7/22/2015 - Added to account for rotated pages * with the origin (0,0) not set to the bottom-left of the page. [1400] */ trans = translateRotation(trans[0], trans[1], pageNum); if (set == 1) { float m = image.getPlainHeight(); float pageChunk = r[pageNum - 1].getHeight() / 10; shift = r[pageNum - 1].getHeight() / 100; scalar[1] = (int) (pageChunk); scalar[0] = (int) (image.getPlainWidth() * pageChunk) / image.getPlainHeight(); trans[0] = (int) (0 + (pageChunk * widthScalar)); trans[1] = (int) (r[pageNum - 1].getHeight() - (pageChunk * heightScalar) - (shift * (heightScalar + 2))); heightScalar = heightScalar + 1; if (heightScalar == 8) { heightScalar = 0; widthScalar = widthScalar + 2; } } if (set == 1) { image.setAbsolutePosition(trans[0] + shift, trans[1] - scalar[1]); image.scaleAbsoluteHeight(scalar[1]); image.scaleAbsoluteWidth(scalar[0]); image.setRotationDegrees(rot); } else { //swap stamp dimensions for rotated drawings if (rot > 0) { image.setAbsolutePosition(trans[0] - 2 * scalar[1], trans[1] - 2 * scalar[0]); } else { image.setAbsolutePosition(trans[0], trans[1] - 2 * scalar[1]); } image.scaleAbsoluteHeight(scalar[1] * 2); image.scaleAbsoluteWidth(scalar[0] * 2); image.setRotationDegrees(rot); } PdfContentByte fg = pds.getOverContent(pageNum); fg.addImage(image); //Added by tmittelstadt on 09/21/2012 for ticket #698 //draws a box around the date fg.setColorFill(BaseColor.WHITE); fg.setLineWidth(0f); //dmoody removed box. ticket 900 /*fg.moveTo(trans[0], trans[1] - scalar[1] * 2); fg.lineTo(trans[0], trans[1] - scalar[1] * 2 - 10); fg.lineTo(trans[0] + scalar[0] * 2, trans[1] - scalar[1] * 2 - 10); fg.lineTo(trans[0] + scalar[0] * 2, trans[1] - scalar[1] * 2); fg.lineTo(trans[0], trans[1] - scalar[1] * 2);*/ fg.closePathFillStroke(); fg.fill(); //adds the date the stamp was added to the document to the pdf Phrase p = new Phrase(date); p.getFont().setColor(BaseColor.BLACK); //Modification zreeve 10/11/2012. set font size to 11. p.getFont().setSize(9f); //p.getChunks().get(0).setAnnotation(PdfAnnotation.createText(pds.getWriter(), new Rectangle(trans[0],trans[1], trans[0]+5f, trans[1]+5f), id, comment, true, id)); ColumnText.showTextAligned(fg, Element.ALIGN_CENTER, p, (float) (trans[0]), (float) (trans[1] - scalar[1] * 2 - 12), 0); Phrase pn = new Phrase("#[" + projNo + "]"); pn.getFont().setColor(BaseColor.BLACK); pn.getFont().setSize(10f); pn.getFont().setStyle("bold"); ColumnText.showTextAligned(fg, Element.ALIGN_CENTER, pn, (float) (trans[0]), (float) (trans[1] - scalar[1] * 2 - 22), 0); return ""; }
From source file:EplanPrinter.PDFPrint.java
License:Open Source License
public String insertComment(String sx, String sy, String id, String deptValue, String userInit, String comment, int pageNum, int masterHeight, int masterWidth, int pinned, int customFontSize) throws DocumentException, IOException { float ratio = getRatio(masterHeight, masterWidth, pageNum); float x = Float.parseFloat(sx); float y = Float.parseFloat(sy); float[] f = commentTrans(x, y, masterHeight, masterWidth, pageNum); PdfGState gs1 = new PdfGState(); gs1.setFillOpacity(1);//from www. j av a 2 s. c o m if (customFontSize > 0) fontSize = customFontSize; PdfContentByte fg = pds.getOverContent(pageNum); fg.setGState(gs1); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); float[] trans = translate(x, y, r[pageNum - 1].getHeight(), r[pageNum - 1].getWidth(), masterHeight, masterWidth, pageNum); // comment tag image (width=35pts, height=8pts) float[] scalar = scale(trans[0], trans[1], 35, 8, masterHeight, masterWidth, pageNum); /* Addition. ftorres - 7/21/2015 - Added to account for rotated pages * with the origin (0,0) not set to the bottom-left of the page. [1400] */ float coords[] = translateRotation(trans[0], trans[1], pageNum); coords = checkBounds(coords[0], coords[1], pageNum); /* Addition. ftorres - 10/20/2015 - If the comment was pinned in EPC, then * render the comment inside a comment box. */ if (pinned == 1) { insertPinnedComment(coords[0], coords[1], id + " - " + deptValue + " (" + userInit + ")", comment, pageNum, masterHeight, masterWidth); // Add the pinned comment text to page annotation -Jon Changkachith 11/24/2015 Rectangle rect = new Rectangle(0, 0, 0, 0); PdfAnnotation annotation = PdfAnnotation.createText(pds.getWriter(), rect, id + " - " + deptValue + " (" + userInit + ")", cleanupComment(comment), true, id); pds.addAnnotation(annotation, pds.getWriter().getCurrentPageNumber()); } else { Image image = Image.getInstance(commentIMGPath); image.setAbsolutePosition(coords[0] + (scalar[0] * (id.length() / 5f)), coords[1]); /* * Commented out by Jon Changkachith 12/09/2015 because it was throwing * DocumentException with the message "The image must have absolute positioning." image.scaleAbsoluteHeight(1); image.scaleAbsoluteWidth(1); */ image.scalePercent(ratio); //Added to fix DocumentException "The image must have absolute positioning." Jon Changkachith 12/09/2015 image.setAnnotation(new Annotation(id + " - " + deptValue + " (" + userInit + ")", cleanupComment(comment), 0, 0, 0, 0)); fg.addImage(image); } fg.setLineWidth(.5f * ratio); fg.setColorStroke(new BaseColor(Color.decode("0x6E2405").getRGB())); fg.setColorFill(new BaseColor(Color.decode("0x6E2405").getRGB())); float tHeight = scalar[1]; float tWidth = 0; if (id.length() > 3) { tWidth = (scalar[0] * (id.length() / 5f)); } else { tWidth = (scalar[0]); } fg.moveTo(coords[0], coords[1]); fg.lineTo(coords[0] + (10f * ratio), coords[1] - (tHeight / 2)); fg.lineTo(coords[0] + tWidth, coords[1] - (tHeight / 2)); fg.lineTo(coords[0] + tWidth, coords[1] + (tHeight / 2)); fg.lineTo(coords[0] + (10f * ratio), coords[1] + (tHeight / 2)); fg.lineTo(coords[0], coords[1]); fg.closePathFillStroke(); fg.fill(); // Comment number that goes on the comment tag image Phrase p = new Phrase(id); p.getFont().setColor(BaseColor.WHITE); p.getFont().setSize(8f * ratio); //comment number font size = 8f //p.getChunks().get(0).setAnnotation(PdfAnnotation.createText(pds.getWriter(), new Rectangle(trans[0],trans[1], trans[0]+5f, trans[1]+5f), id, comment, true, id)); float fs[] = translateRotation(f[0], f[1], pageNum); fs = checkBounds(fs[0], fs[1], pageNum); ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, p, (float) (fs[0] + (9 * ratio)), (float) (fs[1] - (3 * ratio)), 0); return ""; }
From source file:es.clinica.veterinaria.albaranes.AlbaranPdf.java
public PdfPTable createTable() throws DocumentException { // a table with three columns int iva = 0, iva2 = 0; DecimalFormat df = new DecimalFormat("0.00"); PdfPTable table = new PdfPTable(5); table.setTotalWidth(new float[] { 55, 150, 200, 70, 70 }); table.setLockedWidth(true);//w w w . j av a 2 s. com // the cell object // we add a cell with colspan 3 PdfPCell cell = new PdfPCell(new Phrase("CANT.")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("CONCEPTO")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("DESCRIPCIN")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("PRECIO")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("IMPORTE")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); HashSet<VentaLinea> listVenta = getVenta().getVenta_lineas(); for (VentaLinea vlinea : listVenta) { if (vlinea.getTipo() == 1) { if (vlinea.getProducto().getIva() != null) { iva2 = vlinea.getProducto().getIva().getValor(); // System.out.println("IVA: " +iva2); } } else if (vlinea.getTipo() == 2) { if (vlinea.getServicio().getIva() != null) { iva2 = vlinea.getServicio().getIva().getValor(); // System.out.println("IVA: " +iva2); } } //Para hacer el calculo nos vamos a quedar con el IVA mayor if (iva < iva2) { iva = iva2; } cell = new PdfPCell(new Phrase(vlinea.getCantidad() + "", small)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(new PdfPCell(new Phrase(vlinea.getNombre(), small))); String descripcion = vlinea.getDescripcion(); if (descripcion == null || "null".equals(descripcion)) { table.addCell(new PdfPCell(new Phrase(" ", small))); // System.out.println("null:" + descripcion); } else { table.addCell(new PdfPCell(new Phrase(descripcion, small))); // System.out.println("!null:" + descripcion); } cell = new PdfPCell(new Phrase(df.format(vlinea.getPvp()) + " ", small)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(vlinea.getPreciototalNoIVA()) + " ", small)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); } cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorderWidthBottom(0); cell.setBorderWidthLeft(0); cell.setBorder(0); cell.setBorderColorLeft(BaseColor.WHITE); cell.setBorderColorBottom(BaseColor.WHITE); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(cell); table.addCell(cell); cell = new PdfPCell(new Phrase("SUMA")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(venta.getCostesinIva()) + " ")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); /* IVA */ cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorderWidthBottom(0); cell.setBorderWidthLeft(0); cell.setBorder(0); cell.setBorderColorLeft(BaseColor.WHITE); cell.setBorderColorBottom(BaseColor.WHITE); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(cell); table.addCell(cell); // float costetotal = (float) (venta.getCoste() * (1+(iva*0.01))); cell = new PdfPCell(new Phrase("IVA " + iva + "%")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(venta.getIvas()) + " ")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); /* COSTE TOTAL */ cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorderWidthBottom(0); cell.setBorderWidthLeft(0); cell.setBorder(0); cell.setBorderColorLeft(BaseColor.WHITE); cell.setBorderColorBottom(BaseColor.WHITE); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(cell); table.addCell(cell); cell = new PdfPCell(new Phrase("TOTAL")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(venta.getCoste()) + " ")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); return table; }