public void addElement( Element element ) { try { add( element ); } catch ( DocumentException e ) { e.printStackTrace(); } }
public void addElement( Element element ) { try { add( element ); } catch ( DocumentException e ) { e.printStackTrace(); } }
private void addParagraphToDocument() { if(this.iTextParagraph != null) { try { this.rtfParser.getDocument().add(this.iTextParagraph); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.iTextParagraph = null; } } }
private void addParagraphToDocument() { if(this.iTextParagraph != null) { try { this.rtfParser.getDocument().add(this.iTextParagraph); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.iTextParagraph = null; } } }
private void addDocument(Object obj, Node node) { try { if (currentSection_ != null && !(node instanceof WikiHeading)) { if (obj != null) { try { currentSection_.add(obj); } catch (ClassCastException cce) { log_.error("couldn't add " + obj + " to current section caused by " + cce.getMessage()); } } } else { if (obj != null) { try { doc_.add((Element) obj); } catch (ClassCastException cce) { log_.error("couldn't add " + obj + " to document caused by " + cce.getMessage()); } } } } catch (DocumentException de) { de.printStackTrace(); } }
@Override public byte[] convert(String input) throws ConversionException { try { ITextRenderer renderer = new ITextRenderer(); renderer.setDocumentFromString(input); renderer.layout(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); renderer.createPDF(outputStream); byte[] bytes = outputStream.toByteArray(); return bytes; } catch (DocumentException e) { e.printStackTrace(); throw ConversionException.HTML_TO_PDF_EXCEPTION; } } }
public void addElement(Element element) { try { if (!super.isOpen()) { super.open(); } super.add(element); } catch (DocumentException e) { e.printStackTrace(); } }
public static void outputDebug(Object doc, int groupLevel, String str) { System.out.println(str); if(doc == null) return; if(groupLevel<0) groupLevel = 0; char[] a; Arrays.fill(a= new char[groupLevel*2], ' '); String spaces= new String(a); if(doc instanceof RtfDocument) { ((RtfDocument)doc).add(new RtfDirectContent("\n" + spaces + str)); } else if(doc instanceof Document) { try { ((Document)doc).add(new RtfDirectContent("\n" + spaces + str)); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } /**
public static void outputDebug(Object doc, int groupLevel, String str) { System.out.println(str); if(doc == null) return; if(groupLevel<0) groupLevel = 0; char[] a; Arrays.fill(a= new char[groupLevel*2], ' '); String spaces= new String(a); if(doc instanceof RtfDocument) { ((RtfDocument)doc).add(new RtfDirectContent("\n" + spaces + str)); } else if(doc instanceof Document) { try { ((Document)doc).add(new RtfDirectContent("\n" + spaces + str)); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } /**
public void addElement( Element element ) { try { if ( !super.isOpen() ) { super.open(); } super.add( element ); } catch ( DocumentException e ) { e.printStackTrace(); } }
private void serializeToPDF(EntityBean bean, OutputStream stream) { ServletOutputStream servletStream = (ServletOutputStream) stream; DiscrepancyNoteBean discNBean = (DiscrepancyNoteBean) bean; StringBuilder writer = new StringBuilder(); writer.append(serializeToString(discNBean, false, 0)); Document pdfDoc = new Document(); try { PdfWriter.getInstance(pdfDoc, servletStream); pdfDoc.open(); pdfDoc.add(new Paragraph(writer.toString())); } catch (DocumentException e) { e.printStackTrace(); } pdfDoc.close(); }
@Override public void drawImage(Image img, int x, int y, int width, int height) { try { cb.addImage(com.lowagie.text.Image.getInstance(img,null), width/10.0f,0,0,height/10.0f, (xofs+x)/10.0f, document.getPageSize().getHeight()-(y+yofs+height)/10.0f ); } catch (BadElementException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
public void serializeListToPDF(String content, OutputStream stream) { ServletOutputStream servletStream = (ServletOutputStream) stream; Document pdfDoc = new Document(); try { PdfWriter.getInstance(pdfDoc, servletStream); pdfDoc.open(); pdfDoc.add(new Paragraph(content)); } catch (DocumentException e) { e.printStackTrace(); } pdfDoc.close(); }
/** * Sets the RtfDocument this RtfElement belongs to * * @param doc The RtfDocument to use */ public void setRtfDocument(RtfDocument doc) { this.document = doc; if(this.document != null) { for(int i = 0; i < this.content.length; i++) { try { if(this.content[i] instanceof Element) { this.content[i] = this.document.getMapper().mapElement((Element) this.content[i])[0]; ((RtfBasicElement) this.content[i]).setInHeader(true); } else if(this.content[i] instanceof RtfBasicElement){ ((RtfBasicElement) this.content[i]).setRtfDocument(this.document); ((RtfBasicElement) this.content[i]).setInHeader(true); } } catch(DocumentException de) { de.printStackTrace(); } } } }
/** * Sets the RtfDocument this RtfElement belongs to * * @param doc The RtfDocument to use */ public void setRtfDocument(RtfDocument doc) { this.document = doc; if(this.document != null) { for(int i = 0; i < this.content.length; i++) { try { if(this.content[i] instanceof Element) { this.content[i] = this.document.getMapper().mapElement((Element) this.content[i])[0]; ((RtfBasicElement) this.content[i]).setInHeader(true); } else if(this.content[i] instanceof RtfBasicElement){ ((RtfBasicElement) this.content[i]).setRtfDocument(this.document); ((RtfBasicElement) this.content[i]).setInHeader(true); } } catch(DocumentException de) { de.printStackTrace(); } } } }
/** * Constructs a RtfHeaderFooter as a copy of an existing RtfHeaderFooter. * For internal use only. * * @param doc The RtfDocument this RtfHeaderFooter belongs to * @param headerFooter The RtfHeaderFooter to copy * @param displayAt The display location of this RtfHeaderFooter */ protected RtfHeaderFooter(RtfDocument doc, RtfHeaderFooter headerFooter, int displayAt) { super(new Phrase(""), false); this.document = doc; this.content = headerFooter.getContent(); this.displayAt = displayAt; for(int i = 0; i < this.content.length; i++) { if(this.content[i] instanceof Element) { try { this.content[i] = this.document.getMapper().mapElement((Element) this.content[i])[0]; } catch(DocumentException de) { de.printStackTrace(); } } if(this.content[i] instanceof RtfBasicElement) { ((RtfBasicElement) this.content[i]).setInHeader(true); } } }
/** * Constructs a RtfHeaderFooter as a copy of an existing RtfHeaderFooter. * For internal use only. * * @param doc The RtfDocument this RtfHeaderFooter belongs to * @param headerFooter The RtfHeaderFooter to copy * @param displayAt The display location of this RtfHeaderFooter */ protected RtfHeaderFooter(RtfDocument doc, RtfHeaderFooter headerFooter, int displayAt) { super(new Phrase(""), false); this.document = doc; this.content = headerFooter.getContent(); this.displayAt = displayAt; for(int i = 0; i < this.content.length; i++) { if(this.content[i] instanceof Element) { try { this.content[i] = this.document.getMapper().mapElement((Element) this.content[i])[0]; } catch(DocumentException de) { de.printStackTrace(); } } if(this.content[i] instanceof RtfBasicElement) { ((RtfBasicElement) this.content[i]).setInHeader(true); } } }
public void serializeListToPDF(List<DiscrepancyNoteBean> listOfBeans, OutputStream stream, String studyIdentifier) { ServletOutputStream servletStream = (ServletOutputStream) stream; Document pdfDoc = new Document(); try { PdfWriter.getInstance(pdfDoc, servletStream); pdfDoc.open(); //Create header for the study identifier or name if(studyIdentifier != null) { HeaderFooter header = new HeaderFooter( new Phrase("Study Identifier: "+studyIdentifier+" pg."),true); header.setAlignment(Element.ALIGN_CENTER); Paragraph para = new Paragraph("Study Identifier: "+studyIdentifier, new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 0, 0))); para.setAlignment(Element.ALIGN_CENTER); pdfDoc.setHeader(header); pdfDoc.add(para); } for(DiscrepancyNoteBean discNoteBean : listOfBeans){ pdfDoc.add(this.createTableFromBean(discNoteBean)); pdfDoc.add(new Paragraph("\n")); } //pdfDoc.add(new Paragraph(content)); } catch (DocumentException e) { e.printStackTrace(); } pdfDoc.close(); }
/** * Constructs a RtfHeaderFooter for a HeaderFooter. * * @param doc The RtfDocument this RtfHeaderFooter belongs to * @param headerFooter The HeaderFooter to base this RtfHeaderFooter on */ protected RtfHeaderFooter(RtfDocument doc, HeaderFooter headerFooter) { super(new Phrase(""), false); this.document = doc; Paragraph par = new Paragraph(); par.setAlignment(headerFooter.alignment()); if (headerFooter.getBefore() != null) { par.add(headerFooter.getBefore()); } if (headerFooter.isNumbered()) { par.add(new RtfPageNumber(this.document)); } if (headerFooter.getAfter() != null) { par.add(headerFooter.getAfter()); } try { this.content = new Object[1]; this.content[0] = doc.getMapper().mapElement(par)[0]; ((RtfBasicElement) this.content[0]).setInHeader(true); } catch(DocumentException de) { de.printStackTrace(); } }
/** * Constructs a RtfHeaderFooter for a HeaderFooter. * * @param doc The RtfDocument this RtfHeaderFooter belongs to * @param headerFooter The HeaderFooter to base this RtfHeaderFooter on */ protected RtfHeaderFooter(RtfDocument doc, HeaderFooter headerFooter) { super(new Phrase(""), false); this.document = doc; Paragraph par = new Paragraph(); par.setAlignment(headerFooter.alignment()); if (headerFooter.getBefore() != null) { par.add(headerFooter.getBefore()); } if (headerFooter.isNumbered()) { par.add(new RtfPageNumber(this.document)); } if (headerFooter.getAfter() != null) { par.add(headerFooter.getAfter()); } try { this.content = new Object[1]; this.content[0] = doc.getMapper().mapElement(par)[0]; ((RtfBasicElement) this.content[0]).setInHeader(true); } catch(DocumentException de) { de.printStackTrace(); } }