private Font getFont(FormCell formCell) { Font font = pgInfo.getFontInfo().defaultF(); if (formCell.getFont() != null) { font = formCell.getFont(); } font = new Font(font); if (formCell.isBold()) { font.setStyle(Font.BOLD); } else { font.setStyle(Font.NORMAL); } return font; }
public void encode( PdfContentByte directContent, IGenericCharacter character, IGenericDescription description, Bounds bounds) throws DocumentException { IVirtueFlaw resonance = ((IVirtueFlawModel) character.getAdditionalModel(AbyssalResonanceTemplate.ID)) .getVirtueFlaw(); Bounds textBounds = traitEncoder.encode(directContent, bounds, resonance.getLimitTrait().getCurrentValue()); Font font = createFont(getBaseFont()); Font nameFont = createNameFont(getBaseFont()); Phrase phrase = new Phrase("", font); // $NON-NLS-1$ phrase.add( new Chunk( resources.getString("Sheet.GreatCurse.FlawedVirtue") + ": ", nameFont)); //$NON-NLS-1$ //$NON-NLS-2$ if (resonance.isFlawComplete()) { phrase.add(resonance.getRoot().getId() + ".\n"); } else { Font undefinedFont = new Font(font); undefinedFont.setStyle(Font.UNDERLINE); phrase.add( new Chunk(" ", undefinedFont)); // $NON-NLS-1$ phrase.add(".\n"); } phrase.add(resources.getString("Sheet.GreatCurse.ResonanceReference")); // $NON-NLS-1$ encodeTextWithReducedLineHeight(directContent, textBounds, phrase); }
private void encodeOnlyConditionDefined( SheetGraphics graphics, VirtueFlawContent content, Bounds textBounds) throws DocumentException { Phrase phrase = new Phrase(); Font undefinedFont = new Font(createNameFont(graphics)); undefinedFont.setStyle(Font.UNDERLINE); phrase.add( new Chunk(" : ", undefinedFont)); // $NON-NLS-1$ phrase.add(new Chunk(": ", createNameFont(graphics))); // $NON-NLS-1$ phrase.add(new Chunk(content.getLimitBreakCondition(), createConditionFont(graphics))); graphics .createSimpleColumn(textBounds) .withLeading(REDUCED_LINE_HEIGHT) .andTextPart(phrase) .encode(); }
private int writePowerNotes( SheetGraphics graphics, String power, Bounds bounds, int offsetX, int offsetY) throws DocumentException { Font boldFont = new Font(font); boldFont.setStyle(Font.BOLD); String text = resources.getString(powerBase + power); Phrase phrase = new Phrase(text, boldFont); int index = 0; int totalHeight = 0; while (!text.startsWith("##")) { Bounds newBounds = new Bounds( bounds.x + offsetX, bounds.y, bounds.width - offsetX, bounds.height - offsetY - totalHeight); totalHeight += graphics .createSimpleColumn(newBounds) .withLeading(lineHeight) .andTextPart(phrase) .encode() .getLinesWritten() * lineHeight; text = resources.getString(powerBase + power + (++index)); text = text.replace("TELLMDV", "" + tellMDV); phrase = new Phrase(text, font); } if (!isHorizontal) { Bounds newBounds = new Bounds( bounds.x + offsetX, bounds.y + bounds.height - offsetY - totalHeight, bounds.x - offsetX, lineHeight); totalHeight += graphics .createSimpleColumn(newBounds) .withLeading(lineHeight) .andTextPart(new Phrase(" ", font)) .encode() .getLinesWritten() * lineHeight; } return totalHeight; }
private Font createNameFont(SheetGraphics graphics) { Font newFont = graphics.createTableFont(); newFont.setStyle(Font.BOLD); return newFont; }
private Font createNameFont(BaseFont baseFont) { Font newFont = createFont(baseFont); newFont.setStyle(Font.BOLD); return newFont; }
public void onClick$buttonImprimir() { String nombrepdf = ""; try { Calendar cal = Calendar.getInstance(); // lol Calendar cal2 = new GregorianCalendar(); Document document = new Document(); String nombre = "" + (cal.getTime().getYear() + 1900) + "_" + (cal.getTime().getMonth() + 1) + "_" + cal.getTime().getDate(); String tipo = ""; Font miFuente = new Font(); miFuente.setStyle(Font.BOLD); miFuente.setColor(Color.BLUE); Font miFuente2 = new Font(); miFuente2.setStyle(Font.BOLD); miFuente2.setColor(Color.RED); PdfPTable tabla; PdfPCell celda; PdfPCell c1; ReporteProducto rowlista; String dem = ""; String esp = ""; if (cmb_demanda.getText().equals("Mayor Demanda")) { dem = "mayDemanda"; } else { dem = "menDemanda"; } if (cmb_tipo.getText().equals("General")) { esp = dem + "General"; } else { esp = dem + "PorCat"; } if (cmb_tiempo.getText().equals("Por Año")) { tipo = esp + "PorAño"; tabla = new PdfPTable(4); celda = new PdfPCell(new Phrase("Año", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Producto", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Categoría", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Cantidad de Pedidos", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); for (int i = 0; i < lista.size(); i++) { rowlista = lista.get(i); c1 = new PdfPCell(new Phrase("" + rowlista.getFinicial())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(c1); c1 = new PdfPCell(new Phrase("" + rowlista.getProducto())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(c1); c1 = new PdfPCell(new Phrase("" + rowlista.getCategoria())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(c1); c1 = new PdfPCell(new Phrase("" + rowlista.getCantidad())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(c1); } } else { if (cmb_tiempo.getText().equals("Por Mes")) { tipo = esp + "PorMes"; tabla = new PdfPTable(5); celda = new PdfPCell(new Phrase("Año", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Mes", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Producto", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Categoría", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Cantidad de Pedidos", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } else { tipo = esp + "PorFecha"; tabla = new PdfPTable(5); celda = new PdfPCell(new Phrase("Fecha Inicial", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Fecha Final", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Producto", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Categoría", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Phrase("Cantidad de Pedidos", miFuente2)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } for (int i = 0; i < lista.size(); i++) { rowlista = lista.get(i); c1 = new PdfPCell(new Phrase("" + rowlista.getFinicial())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(c1); c1 = new PdfPCell(new Phrase("" + rowlista.getFfinal())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(c1); c1 = new PdfPCell(new Phrase("" + rowlista.getProducto())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(c1); c1 = new PdfPCell(new Phrase("" + rowlista.getCategoria())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(c1); c1 = new PdfPCell(new Phrase("" + rowlista.getCantidad())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); tabla.addCell(c1); } } nombrepdf = "ReporteProductos" + tipo + "_" + nombre + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(nombrepdf)); document.open(); Paragraph Titulo = new Paragraph( "Reporte " + cmb_tipo.getText() + " de Productos de " + cmb_demanda.getText() + " " + cmb_tiempo.getText(), miFuente); Titulo.setAlignment(Element.ALIGN_CENTER); Paragraph encabezado = new Paragraph("Prueba"); encabezado.setAlignment(Element.ALIGN_CENTER); document.add(Titulo); document.add(encabezado); document.add(new Paragraph(" ")); document.add(tabla); document.close(); } catch (Exception e) { e.printStackTrace(); } Hashtable h = new Hashtable(); h.put("File", nombrepdf); Executions.getCurrent() .createComponents("Modulo_Reportes/Pdf_Viewer.zul", win_reportesproductos, h); File filepdf = new File(nombrepdf); filepdf.delete(); /* try { if ((new File(nombrepdf)).exists()) { Process p = Runtime .getRuntime() .exec("rundll32 url.dll,FileProtocolHandler "+nombrepdf); p.waitFor(); buttonImprimir.setVisible(false); } else { alert("File is not exists!"); } alert("Done!"); } catch (Exception ex) { ex.printStackTrace(); }*/ }