List of usage examples for com.lowagie.text.html HtmlWriter getInstance
public static HtmlWriter getInstance(Document document, OutputStream os)
HtmlWriter
. From source file:binky.reportrunner.engine.renderers.exporters.HTMLExporter.java
License:Open Source License
@Override public void export(ResultSet resultSet, String label, OutputStream outputStream) throws ExportException { try {/*from ww w. j a v a2 s.c o m*/ Document document = new Document(); HtmlWriter.getInstance(document, outputStream); // open the document object document.open(); ResultSetMetaData metaData = resultSet.getMetaData(); Table table = new Table(metaData.getColumnCount()); for (int i = 1; i <= metaData.getColumnCount(); i++) { Paragraph para = new Paragraph(metaData.getColumnName(i), new Font(Font.HELVETICA, 10, Font.BOLD)); Cell cell = new Cell(para); table.addCell(cell); } while (resultSet.next()) { for (int i = 1; i <= metaData.getColumnCount(); i++) { Paragraph para = new Paragraph("" + resultSet.getObject(i), new Font(Font.HELVETICA, 10, Font.NORMAL)); Cell cell = new Cell(para); table.addCell(cell); } } document.add(table); document.close(); } catch (DocumentException e) { throw new ExportException(e.getMessage(), e); } catch (SQLException e) { throw new ExportException(e.getMessage(), e); } }
From source file:com.centurylink.mdw.designer.pages.ExportHelper.java
License:Apache License
/** * Export multiple processes/*from www. j a va 2 s .co m*/ * @param filename the file name (including path) where the document will be generated * @param type can be pdf, rtf and html * @param flowchart the designer page (for using its canvas and report errors) * @param graphs the list of processes to be printed. * @param options options for printing, from the print dialog. */ public void exportProcesses(String filename, String type, FlowchartPage flowchart, List<Graph> graphs) throws Exception { initialize(false); options.add(SECTION_NUMBER); // step 1: creation of a document-object Document document = new Document(); try { // step 2: create PDF or RTF writer DocWriter writer; if (type.equals(RTF)) { writer = RtfWriter2.getInstance(document, new FileOutputStream(filename)); } else if (type.equals(PDF)) { writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { boolean directHtml = true; if (directHtml) { StringBuffer sb = printPrologHtml("Processes"); Graph process; for (int i = 0; i < graphs.size(); i++) { process = graphs.get(i); flowchart.setProcess(process); this.printProcessHtml(sb, flowchart.canvas, i + 1, process, filename); } printEpilogHtml(sb, filename); return; } writer = HtmlWriter.getInstance(document, new FileOutputStream(filename)); } // step 3: we open the document document.open(); // step 4: we add contents to the document document.setPageSize(PageSize.LETTER); Graph process; Chapter chapter; Rectangle page_size = document.getPageSize(); for (int i = 0; i < graphs.size(); i++) { process = graphs.get(i); process.setNodeIdType(nodeIdType); flowchart.setProcess(process); chapter = printOneProcessPdf(writer, flowchart.canvas, type, i + 1, process, filename, page_size); document.add(chapter); } } finally { // step 5: we close the document document.close(); } }
From source file:org.activityinfo.server.report.renderer.itext.HtmlReportRenderer.java
License:Open Source License
@Override protected DocWriter createWriter(Document document, OutputStream os) throws DocumentException { return HtmlWriter.getInstance(document, os); }
From source file:org.eclipse.osee.ats.rest.internal.build.report.table.BuildTraceTable.java
License:Open Source License
public void initializeTraceReportTable(String program, String build) throws OseeCoreException { String header = String.format("%s: [%s - %s]", AtsElementData.BUILD_TRACE_REPORT, program, build); document = new Document(); document.addTitle(header);// w w w . j a va 2 s .c om HtmlWriter.getInstance(document, output); document.open(); createTables(); Cell headerCell = new RtfCell(header); headerCell.setColspan(1); headerCell.setHeader(true); headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); reportTable.addCell(headerCell); reportTable.endHeaders(); reportTable.setTableFitsPage(true); Cell rpcrCell = new RtfCell(AtsElementData.RPCR); rpcrCell.setHeader(true); rpcrCell.setHorizontalAlignment(Element.ALIGN_CENTER); traceReportTable.addCell(rpcrCell); Cell req = new Cell(AtsElementData.REQUIREMENT); req.setHeader(true); req.setHorizontalAlignment(Element.ALIGN_CENTER); nestedHeaderTable.addCell(req); Cell script = new Cell(AtsElementData.TEST_SCRIPT); script.setHeader(true); script.setHorizontalAlignment(Element.ALIGN_CENTER); nestedHeaderTable.addCell(script); traceReportTable.insertTable(nestedHeaderTable); sortedRpcr = new TreeSet<Pair<String, Table>>(PairCompare); }
From source file:org.eclipse.osee.ats.rest.internal.build.report.table.UrlListTable.java
License:Open Source License
public void initializeTable(String title, String lastRun, String... headers) throws OseeCoreException { document = new Document(); lastRunDate = lastRun;/* w ww. j a v a 2 s. c o m*/ sortedList = new TreeSet<List<Anchor>>(new Comparator<List<Anchor>>() { @Override public int compare(List<Anchor> anchor1, List<Anchor> anchor2) { String name1 = anchor1.get(0).toString(); String name2 = anchor2.get(0).toString(); return name1.compareTo(name2); } }); HtmlWriter.getInstance(document, output); document.addTitle(title); document.open(); try { table = new Table(headers.length); } catch (BadElementException ex) { OseeExceptions.wrapAndThrow(ex); } for (String header : headers) { Cell headerCell = new Cell(header); headerCell.setHeader(true); headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(headerCell); } table.setWidth(10f * headers.length); table.setAlignment(Element.ALIGN_BOTTOM); }
From source file:org.eclipse.osee.framework.ui.skynet.util.TableWriterAdaptor.java
License:Open Source License
private void setDocWriter(String value) throws Exception { if (value.equalsIgnoreCase(PDF)) { this.writer = PdfWriter.getInstance(document, outputStream); // ((PdfWriter) writer).setPDFXConformance(PdfWriter.PDFX32002); ((PdfWriter) writer).setPdfVersion(PdfWriter.VERSION_1_6); } else if (value.equalsIgnoreCase(HTML)) { this.writer = HtmlWriter.getInstance(document, outputStream); } else if (value.equalsIgnoreCase(RTF)) { this.writer = RtfWriter2.getInstance(document, outputStream); }//from ww w.j a v a 2 s. c om }
From source file:org.sigmah.server.report.renderer.itext.HtmlReportRenderer.java
License:Open Source License
@Override protected DocWriter createWriter(Document document, OutputStream os) throws DocumentException { HtmlWriter writer = HtmlWriter.getInstance(document, os); writer.setImagepath(System.getProperty("java.io.tmpdir")); return writer; }