List of usage examples for com.lowagie.text.pdf PdfPTable setWidthPercentage
public void setWidthPercentage(float widthPercentage)
From source file:Cotizacion.ExportarPDF.java
private static void acomodarDatosTablaProductos(Paragraph subCatPart) throws BadElementException { numeroFilas = LogicaCotizacion.numero; cantidadTabla = new String[numeroFilas]; productoTabla = new String[numeroFilas]; precioTabla = new String[numeroFilas]; totalTabla = new String[numeroFilas]; descripcionTabla = new String[numeroFilas]; PdfPTable tabla = new PdfPTable(5); tabla.setWidthPercentage(100); PdfPCell celda = new PdfPCell(new Paragraph("Producto")); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBackgroundColor(new Color(0, 175, 239)); tabla.addCell(celda);/*from ww w. ja va 2 s. co m*/ celda = new PdfPCell(new Paragraph("Descripcin")); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBackgroundColor(new Color(0, 175, 239)); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("P/U")); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBackgroundColor(new Color(0, 175, 239)); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Cantidad")); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBackgroundColor(new Color(0, 175, 239)); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Total")); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBackgroundColor(new Color(0, 175, 239)); tabla.addCell(celda); for (int i = 0; i < numeroFilas; i++) { productoTabla[i] = "" + Cotizacion.PanelCotizacion.tablaProductos.getValueAt(i, 0); tabla.addCell(" " + productoTabla[i]); descripcionTabla[i] = "" + Cotizacion.PanelCotizacion.tablaProductos.getValueAt(i, 1); tabla.addCell("" + descripcionTabla[i]); precioTabla[i] = "" + Cotizacion.PanelCotizacion.tablaProductos.getValueAt(i, 2); tabla.addCell("$ " + precioTabla[i]); cantidadTabla[i] = "" + Cotizacion.PanelCotizacion.tablaProductos.getValueAt(i, 3); tabla.addCell(" " + cantidadTabla[i]); totalTabla[i] = "" + Cotizacion.PanelCotizacion.tablaProductos.getValueAt(i, 4); tabla.addCell("$ " + totalTabla[i]); } agregarLineasEnBlanco(subCatPart, 1); subCatPart.add(tabla); }
From source file:Cotizacion.ExportarPDF.java
private static void acomodarDatosPreciosTotales(Paragraph datosDerecha2) throws BadElementException { subtotal = PanelCotizacion.cajaSubtotal.getText(); iva = PanelCotizacion.cajaIVA.getText(); descuento = PanelCotizacion.cajaDescuento.getText(); total = PanelCotizacion.cajaTotal.getText(); PdfPTable table2 = new PdfPTable(2); table2.getDefaultCell().setBorder(PdfPCell.NO_BORDER); table2.addCell("Subtotal"); table2.addCell("$ " + subtotal); table2.addCell("IVA"); table2.addCell(iva);/*from w ww. j a v a2s. c o m*/ table2.addCell("Descuento"); table2.addCell(descuento); table2.addCell("Total"); table2.addCell("$ " + total); table2.setWidthPercentage(30); table2.setHorizontalAlignment(350); table2.setHorizontalAlignment(Element.ALIGN_RIGHT); agregarLineasEnBlanco(datosDerecha2, 1); datosDerecha2.add(table2); }
From source file:CPS.Core.TODOLists.PDFExporter.java
License:Open Source License
public void addTable(JTable jtable, String tableTitle) { try {//from w ww . ja v a 2 s. com if (tableTitle != null) { tempDoc.add(new Paragraph(tableTitle, fontPageHeader)); } tempDoc.add(new Paragraph(Chunk.NEWLINE)); // TODO halve the height of this PdfPTable t = convertJTable(jtable); t.setWidthPercentage(100); // 100% page width tempDoc.add(t); } catch (Exception e) { e.printStackTrace(); } }
From source file:de.jdufner.sudoku.generator.pdf.PdfPrinterImpl.java
License:Open Source License
private PdfPTable writePdfMetaTable(List<SudokuData> sudokus) throws DocumentException { // Tabelle fr Formatierung von 2 Sudokus nebeneinander PdfPTable metaTable = new PdfPTable(2); metaTable.getDefaultCell().setBorder(0); metaTable.getDefaultCell().setPadding(5); metaTable.setWidthPercentage(100); metaTable.setHorizontalAlignment(Element.ALIGN_CENTER); int cells = 0; for (SudokuData sudoku : sudokus) { metaTable.addCell(writePdfTable(sudoku)); cells++;/*ww w .ja va 2s . co m*/ } final int rest = cells % 2; for (int i = 0; i < rest; i++) { metaTable.addCell(""); } metaTable.setComplete(true); return metaTable; }
From source file:de.jdufner.sudoku.generator.pdf.PdfPrinterImpl.java
License:Open Source License
private void writeFrontpage(String name, Document document, List<PdfSolution> solutions) throws DocumentException { document.open();// w w w. j a v a 2 s. c o m Paragraph p = new Paragraph(name); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingBefore(20f); p.setSpacingAfter(20f); document.add(p); PdfPTable table = new PdfPTable(17); table.setWidthPercentage(100); int[] width = { 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; table.setWidths(width); PdfPCell cell; table.addCell(buildHeaderCell("Name", 90, true, false)); table.addCell(buildHeaderCell("Schwierigkeitsgrad", 90, false, false)); table.addCell(buildHeaderCell("Besetzte Zellen", 90, false, false)); table.addCell(buildHeaderCell("Simple", 90, false, false)); table.addCell(buildHeaderCell("Hidden Single", 90, false, false)); table.addCell(buildHeaderCell("Naked Pair", 90, false, false)); table.addCell(buildHeaderCell("Naked Triple", 90, false, false)); table.addCell(buildHeaderCell("Naked Quad", 90, false, false)); table.addCell(buildHeaderCell("Hidden Pair", 90, false, false)); table.addCell(buildHeaderCell("Hidden Triple", 90, false, false)); table.addCell(buildHeaderCell("Hidden Quad", 90, false, false)); table.addCell(buildHeaderCell("Intersection Removal", 90, false, false)); table.addCell(buildHeaderCell("Y-Wing", 90, false, false)); table.addCell(buildHeaderCell("X-Wing", 90, false, false)); table.addCell(buildHeaderCell("Jellyfish", 90, false, false)); table.addCell(buildHeaderCell("Swordfish", 90, false, false)); table.addCell(buildHeaderCell("Backtracking", 90, false, true)); boolean even = false; for (PdfSolution solution : solutions) { table.addCell(buildBodyNumberCell(solution.getId(), even, true, false)); table.addCell(buildBodyTextCell(solution.getLevel().toString(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getFixed(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategySimple(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyHiddenSingle(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyNakedPair(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyNakedTriple(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyNakedQuad(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyHiddenPair(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyHiddenTriple(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyHiddenQuad(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyIntersectionRemoval(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyYwing(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyXwing(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyJellyfish(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategySwordfish(), even, false, false)); table.addCell(buildBodyNumberCell(solution.getStrategyBacktracking(), even, false, true)); even = (even ? false : true); } document.add(table); document.close(); }
From source file:domain.reports.menu.PDFReportMenu.java
License:LGPL
/** * Return a report section formatted as a table * @param data/*from w w w .j a v a 2s. c om*/ * @return */ PdfPTable getGroupDetail(Recordset master, Recordset detail) throws Throwable { //cols PdfPTable datatable = new PdfPTable(2); //header datatable.getDefaultCell().setPadding(1); int headerwidths[] = { 50, 50 }; // percentage datatable.setWidths(headerwidths); datatable.setWidthPercentage(70); // percentage datatable.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell c = null; String v = ""; //encabezados de columnas c = new PdfPCell(new Phrase("ITEMS DEL MEN", tblHeaderFont)); c.setGrayFill(0.95f); c.setColspan(2); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); c = new PdfPCell(new Phrase("Item del men", tblHeaderFont)); c.setGrayFill(0.95f); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); c = new PdfPCell(new Phrase("Servicio", tblHeaderFont)); c.setGrayFill(0.95f); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); while (detail.next()) { v = detail.getString("description"); c = new PdfPCell(new Phrase(v, tblBodyFont)); c.setHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell(c); v = detail.getString("path"); c = new PdfPCell(new Phrase(v, tblBodyFont)); c.setHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell(c); } datatable.setSpacingBefore(20); return datatable; }
From source file:domain.reports.role.PDFReportRole.java
License:LGPL
/** * Return a report section formatted as a table * @param data/*from w w w . j a v a 2 s . com*/ * @return */ PdfPTable getGroupDetail(Recordset master, Recordset detail) throws Throwable { //cols PdfPTable datatable = new PdfPTable(4); //header datatable.getDefaultCell().setPadding(1); int headerwidths[] = { 20, 20, 20, 20 }; // percentage datatable.setWidths(headerwidths); datatable.setWidthPercentage(100); // percentage datatable.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell c = null; String v = ""; //encabezados de columnas c = new PdfPCell(new Phrase("USUARIOS DEL ROL", tblHeaderFont)); c.setGrayFill(0.95f); c.setColspan(4); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); c = new PdfPCell(new Phrase("Login de Usuario", tblHeaderFont)); c.setGrayFill(0.95f); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); c = new PdfPCell(new Phrase("Apellido", tblHeaderFont)); c.setGrayFill(0.95f); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); c = new PdfPCell(new Phrase("Nombre", tblHeaderFont)); c.setGrayFill(0.95f); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); c = new PdfPCell(new Phrase("Email", tblHeaderFont)); c.setGrayFill(0.95f); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); while (detail.next()) { v = detail.getString("userlogin"); c = new PdfPCell(new Phrase(v, tblBodyFont)); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); v = detail.getString("lname"); c = new PdfPCell(new Phrase(v, tblBodyFont)); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); v = detail.getString("fname"); c = new PdfPCell(new Phrase(v, tblBodyFont)); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); v = detail.getString("email"); c = new PdfPCell(new Phrase(v, tblBodyFont)); c.setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(c); } datatable.setSpacingBefore(20); return datatable; }
From source file:edu.harvard.mcz.imagecapture.encoder.LabelEncoder.java
License:Open Source License
@SuppressWarnings("hiding") public static boolean printList(List<UnitTrayLabel> taxa) throws PrintFailedException { boolean result = false; UnitTrayLabel label = new UnitTrayLabel(); LabelEncoder encoder = new LabelEncoder(label); Image image = encoder.getImage(); int counter = 0; try {/* w w w. j a v a 2s . c o m*/ Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("labels.pdf")); document.setPageSize(PageSize.LETTER); document.open(); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100f); //table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT); float[] cellWidths = { 30f, 20f, 30f, 20f }; table.setWidths(cellWidths); UnitTrayLabelLifeCycle uls = new UnitTrayLabelLifeCycle(); if (taxa == null) { taxa = uls.findAll(); } Iterator<UnitTrayLabel> i = taxa.iterator(); PdfPCell cell = null; PdfPCell cell_barcode = null; // Create two lists of 12 cells, the first 6 of each representing // the left hand column of 6 labels, the second 6 of each // representing the right hand column. // cells holds the text for each label, cells_barcode the barcode. ArrayList<PdfPCell> cells = new ArrayList<PdfPCell>(12); ArrayList<PdfPCell> cells_barcode = new ArrayList<PdfPCell>(12); for (int x = 0; x < 12; x++) { cells.add(null); cells_barcode.add(null); } int cellCounter = 0; while (i.hasNext()) { // Loop through all of the taxa (unit tray labels) found to print label = i.next(); for (int toPrint = 0; toPrint < label.getNumberToPrint(); toPrint++) { // For each taxon, loop through the number of requested copies // Generate a text and a barcode cell for each, and add to array for page log.debug("Label " + toPrint + " of " + label.getNumberToPrint()); cell = new PdfPCell(); cell.setBorderColor(Color.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); cell.disableBorderSide(PdfPCell.RIGHT); cell.setPaddingLeft(3); String higherNames = ""; if (label.getTribe().trim().length() > 0) { higherNames = label.getFamily() + ": " + label.getSubfamily() + ": " + label.getTribe(); } else { higherNames = label.getFamily() + ": " + label.getSubfamily(); } Paragraph higher = new Paragraph(); higher.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL)); higher.add(new Chunk(higherNames)); cell.addElement(higher); Paragraph name = new Paragraph(); Chunk genus = new Chunk(label.getGenus().trim() + " "); genus.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC)); Chunk species = new Chunk(label.getSpecificEpithet().trim()); Chunk normal = null; // normal font prefix to preceed specific epithet (nr. <i>epithet</i>) if (label.getSpecificEpithet().contains(".") || label.getSpecificEpithet().contains("[")) { if (label.getSpecificEpithet().startsWith("nr. ")) { normal = new Chunk("nr. "); normal.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL)); species = new Chunk(label.getSpecificEpithet().trim().substring(4)); species.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC)); } else { species.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL)); } } else { species.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC)); } String s = ""; if (label.getSubspecificEpithet().trim().length() > 0) { s = " "; } else { s = ""; } Chunk subspecies = new Chunk(s + label.getSubspecificEpithet().trim()); if (label.getSubspecificEpithet().contains(".") || label.getSubspecificEpithet().contains("[")) { subspecies.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL)); } else { subspecies.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC)); } if (label.getInfraspecificRank().trim().length() > 0) { s = " "; } else { s = ""; } Chunk infraRank = new Chunk(s + label.getInfraspecificRank().trim()); infraRank.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL)); if (label.getInfraspecificEpithet().trim().length() > 0) { s = " "; } else { s = ""; } Chunk infra = new Chunk(s + label.getInfraspecificEpithet().trim()); infra.setFont(new Font(Font.TIMES_ROMAN, 11, Font.ITALIC)); if (label.getUnNamedForm().trim().length() > 0) { s = " "; } else { s = ""; } Chunk unNamed = new Chunk(s + label.getUnNamedForm().trim()); unNamed.setFont(new Font(Font.TIMES_ROMAN, 11, Font.NORMAL)); name.add(genus); if (normal != null) { name.add(normal); } name.add(species); name.add(subspecies); name.add(infraRank); name.add(infra); name.add(unNamed); cell.addElement(name); Paragraph authorship = new Paragraph(); authorship.setFont(new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); if (label.getAuthorship() != null && label.getAuthorship().length() > 0) { Chunk c_authorship = new Chunk(label.getAuthorship()); authorship.add(c_authorship); } cell.addElement(authorship); //cell.addElement(new Paragraph(" ")); if (label.getDrawerNumber() != null && label.getDrawerNumber().length() > 0) { Paragraph drawerNumber = new Paragraph(); drawerNumber.setFont(new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); Chunk c_drawerNumber = new Chunk(label.getDrawerNumber()); drawerNumber.add(c_drawerNumber); cell.addElement(drawerNumber); } else { if (label.getCollection() != null && label.getCollection().length() > 0) { Paragraph collection = new Paragraph(); collection.setFont(new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); Chunk c_collection = new Chunk(label.getCollection()); collection.add(c_collection); cell.addElement(collection); } } cell_barcode = new PdfPCell(); cell_barcode.setBorderColor(Color.LIGHT_GRAY); cell_barcode.disableBorderSide(PdfPCell.LEFT); cell_barcode.setVerticalAlignment(PdfPCell.ALIGN_TOP); encoder = new LabelEncoder(label); image = encoder.getImage(); image.setAlignment(Image.ALIGN_TOP); cell_barcode.addElement(image); cells.add(cellCounter, cell); cells_barcode.add(cellCounter, cell_barcode); cellCounter++; // If we have hit a full set of 12 labels, add them to the document // in two columns, filling left column first, then right if (cellCounter == 12) { // add a page of 12 cells in columns of two. for (int x = 0; x < 6; x++) { if (cells.get(x) == null) { PdfPCell c = new PdfPCell(); c.setBorder(0); table.addCell(c); table.addCell(c); } else { table.addCell(cells.get(x)); table.addCell(cells_barcode.get(x)); } if (cells.get(x + 6) == null) { PdfPCell c = new PdfPCell(); c.setBorder(0); table.addCell(c); table.addCell(c); } else { table.addCell(cells.get(x + 6)); table.addCell(cells_barcode.get(x + 6)); } } // Reset to begin next page cellCounter = 0; document.add(table); table = new PdfPTable(4); table.setWidthPercentage(100f); table.setWidths(cellWidths); for (int x = 0; x < 12; x++) { cells.set(x, null); cells_barcode.set(x, null); } } } // end loop through toPrint (for a taxon) counter++; } // end while results has next (for all taxa requested) // get any remaining cells in pairs for (int x = 0; x < 6; x++) { if (cells.get(x) == null) { PdfPCell c = new PdfPCell(); c.setBorder(0); table.addCell(c); table.addCell(c); } else { table.addCell(cells.get(x)); table.addCell(cells_barcode.get(x)); } if (cells.get(x + 6) == null) { PdfPCell c = new PdfPCell(); c.setBorder(0); table.addCell(c); table.addCell(c); } else { table.addCell(cells.get(x + 6)); table.addCell(cells_barcode.get(x + 6)); } } // add any remaining cells document.add(table); try { document.close(); } catch (Exception e) { throw new PrintFailedException("No labels to print." + e.getMessage()); } // Check to see if there was content in the document. if (counter == 0) { result = false; } else { // Printed to pdf ok. result = true; // Increment number printed. i = taxa.iterator(); while (i.hasNext()) { label = i.next(); for (int toPrint = 0; toPrint < label.getNumberToPrint(); toPrint++) { label.setPrinted(label.getPrinted() + 1); } label.setNumberToPrint(0); try { uls.attachDirty(label); } catch (SaveFailedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new PrintFailedException("File not found."); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new PrintFailedException("Error buiding PDF document."); } catch (OutOfMemoryError e) { System.out.println("Out of memory error. " + e.getMessage()); System.out.println("Failed. Too many labels."); throw new PrintFailedException("Ran out of memory, too many labels at once."); } return result; }
From source file:etc.Exporter.java
License:Open Source License
public static void saveAsPDF(File file, Task task) { try {/*from ww w. ja v a2 s.com*/ Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); Paragraph taskid = new Paragraph("ID e Detyres: " + task.getIdentifier(), FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)); document.add(taskid); Paragraph creator = new Paragraph("Krijuar nga " + task.getCreator().toString() + "[" + task.getCreationTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy - HH.mm")) + "]", FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)); document.add(creator); Paragraph executor = new Paragraph("Per zbatim prej: " + task.getExecutor().toString(), FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)); document.add(executor); Paragraph title = new Paragraph(task.getTitle().toUpperCase(), FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD)); document.add(title); Paragraph description = new Paragraph(task.getDescription(), FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL)); document.add(description); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.BOTTOM); PdfPTable table = new PdfPTable(1); table.addCell(cell); table.setWidthPercentage(100f); document.add(table); if (task instanceof dc.CompletedTask) { document.add(new Paragraph( "Gjendja: Perfunduar [" + ((dc.CompletedTask) task).getCompletitionTime() .format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH.mm")) + "]", FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC))); document.add(new Paragraph("Shenimet e Zbatuesit".toUpperCase(), FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD))); document.add(new Paragraph(((dc.CompletedTask) task).getAnnotations(), FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL))); } else if (task instanceof dc.RejectedTask) { document.add(new Paragraph( "Gjendja: Refuzuar [" + ((dc.RejectedTask) task).getRejectionTime() .format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH.mm")) + "]", FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC))); document.add(new Paragraph("Shenimet e Zbatuesit".toUpperCase(), FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD))); document.add(new Paragraph(((dc.RejectedTask) task).getAnnotations(), FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL))); } else { document.add(new Paragraph("Gjendja: Ne Pritje", FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC))); } document.close(); Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file.getAbsolutePath()); p.waitFor(); } catch (DocumentException | InterruptedException | IOException ex) { Logger.getLogger(Exporter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableDocumentSection.java
License:Open Source License
private List<ColumnText> fillTable(float height) { // copy text for simulation List<ColumnText> tt = null; if (breakHandlingParent == null && colIdx >= layoutTable.getNumberOfColumns()) { // more column breaks than available column // we try not to lose content // but results may be different than in open office // anyway it is logical error made by document creator tt = new ArrayList<ColumnText>(); ColumnText t = createColumnText(); tt.add(t);// w ww .j a v a 2 s . c om for (int i = 0; i < texts.size(); i++) { PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100.0f); PdfPCell cell = new PdfPCell(); cell.setBorder(Table.NO_BORDER); cell.setPadding(0.0f); cell.setColumn(ColumnText.duplicate(texts.get(i))); table.addCell(cell); t.addElement(table); } } else { tt = new ArrayList<ColumnText>(texts); for (int i = 0; i < tt.size(); i++) { tt.set(i, ColumnText.duplicate(tt.get(i))); } } // clear layout table clearTable(layoutTable, true); setWidthIfNecessary(); // try to fill cells with text ColumnText t = tt.get(0); for (PdfPCell cell : layoutTable.getRow(0).getCells()) { cell.setFixedHeight(height >= 0.0f ? height : -1.0f); cell.setColumn(ColumnText.duplicate(t)); // t.setSimpleColumn(cell.getLeft() + cell.getPaddingLeft(), height >= 0.0f ? -height : PdfPRow.BOTTOM_LIMIT, cell.getRight() - cell.getPaddingRight(), 0); int res = 0; try { res = t.go(true); } catch (DocumentException e) { throw new ODFConverterException(e); } if (!ColumnText.hasMoreText(res)) { // no overflow in current column if (tt.size() == 1) { // no more text return null; } else { // some text waiting for new column tt.remove(0); t = tt.get(0); } } } return tt; }