private static IOException createIOException(DocumentException e) { // Rq: le constructeur de IOException avec message et cause n'existe qu'en jdk 1.6 return new IOException(e.getMessage(), e); }
/** * Sets the explicit masking. * * @param mask * the mask to be applied * @throws DocumentException * on error */ public void setImageMask(Image mask) throws DocumentException { if (this.mask) throw new DocumentException( "An image mask cannot contain another image mask."); if (!mask.mask) throw new DocumentException( "The image mask is not a mask. Did you do makeMask()?"); imageMask = mask; smask = (mask.bpc > 1 && mask.bpc <= 8); }
public void addElement( Element element ) { try { add( element ); } catch ( DocumentException e ) { e.printStackTrace(); } }
/** * Sets the initial leading for the PDF document. * This has to be done before the document is opened. * @param leading the initial leading * @since 2.1.6 * @throws DocumentException if you try setting the leading after the document was opened. */ public void setInitialLeading(float leading) throws DocumentException { if (open) throw new DocumentException("You can't set the initial leading if the document is already open."); pdf.setLeading(leading); }
public void addElement( Element element ) { try { add( element ); } catch ( DocumentException e ) { e.printStackTrace(); } }
@Override public VisitResult visit(VisitContext context, UIComponent target) { DataTable dt = (DataTable) target; try { document.add(exporter.exportPDFTable(context.getFacesContext(), dt, pageOnly, selectionOnly, encoding)); Paragraph preface = new Paragraph(); exporter.addEmptyLine(preface, 3); document.add(preface); } catch (DocumentException e) { throw new FaceletException(e.getMessage()); } return VisitResult.ACCEPT; }
/** * Make this <CODE>Image</CODE> a mask. * * @throws DocumentException * if this <CODE>Image</CODE> can not be a mask */ public void makeMask() throws DocumentException { if (!isMaskCandidate()) throw new DocumentException("This image can not be an image mask."); mask = true; }
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; } } }
throw new IOException(e.getMessage());
/** * Use this method to set the user unit. * A UserUnit is a value that defines the default user space unit. * The minimum UserUnit is 1 (1 unit = 1/72 inch). * The maximum UserUnit is 75,000. * Note that this userunit only works starting with PDF1.6! * @param userunit The userunit to set. * @throws DocumentException on error */ public void setUserunit(float userunit) throws DocumentException { if (userunit < 1f || userunit > 75000f) throw new DocumentException("UserUnit should be a value between 1 and 75000."); this.userunit = userunit; setAtLeastPdfVersion(VERSION_1_6); }
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; } } }
@Override public void export(FacesContext context, DataTable table, String filename, boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor, MethodExpression postProcessor, ExporterOptions options, MethodExpression onTableRender) throws IOException { try { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); this.onTableRender = onTableRender; if (preProcessor != null) { preProcessor.invoke(context.getELContext(), new Object[]{document}); } if (!document.isOpen()) { document.open(); } if (options != null) { expOptions = options; } document.add(exportPDFTable(context, table, pageOnly, selectionOnly, encodingType)); if (postProcessor != null) { postProcessor.invoke(context.getELContext(), new Object[]{document}); } document.close(); writePDFToResponse(context.getExternalContext(), baos, filename); } catch (DocumentException e) { throw new IOException(e.getMessage()); } }
/** * Sets the explicit masking. * * @param mask * the mask to be applied * @throws DocumentException * on error */ public void setImageMask(Image mask) throws DocumentException { if (this.mask) throw new DocumentException(MessageLocalization.getComposedMessage("an.image.mask.cannot.contain.another.image.mask")); if (!mask.mask) throw new DocumentException(MessageLocalization.getComposedMessage("the.image.mask.is.not.a.mask.did.you.do.makemask")); imageMask = mask; smask = (mask.bpc > 1 && mask.bpc <= 8); }
public void addElement(Element element) { try { if (!super.isOpen()) { super.open(); } super.add(element); } catch (DocumentException e) { e.printStackTrace(); } }
throw new IOException(e.getMessage());
/** * Sets the explicit masking. * * @param mask * the mask to be applied * @throws DocumentException * on error */ public void setImageMask(Image mask) throws DocumentException { if (this.mask) throw new DocumentException(MessageLocalization.getComposedMessage("an.image.mask.cannot.contain.another.image.mask")); if (!mask.mask) throw new DocumentException(MessageLocalization.getComposedMessage("the.image.mask.is.not.a.mask.did.you.do.makemask")); imageMask = mask; smask = (mask.bpc > 1 && mask.bpc <= 8); }
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(); } } } /**
private static IOException createIOException(DocumentException e) { // Rq: le constructeur de IOException avec message et cause n'existe qu'en jdk 1.6 return new IOException(e.getMessage(), e); }
/** * Adds a <CODE>PdfWriter</CODE> to the <CODE>PdfDocument</CODE>. * * @param writer the <CODE>PdfWriter</CODE> that writes everything * what is added to this document to an outputstream. * @throws DocumentException on error */ public void addWriter(PdfWriter writer) throws DocumentException { if (this.writer == null) { this.writer = writer; annotationsImp = new PdfAnnotationsImp(writer); return; } throw new DocumentException("You can only add a writer to a PdfDocument once."); }
@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; } } }