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); }
throw new IOException(e.getMessage());
@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; }
@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()); } }
throw new IOException(e.getMessage());
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); }
private void pushObject(Element e) { if (pushedMap_ == null) pushedMap_ = new HashMap(); if (currentSection_ == null) { try { doc_.add(e); } catch (DocumentException de) { log_.error("failed to add element " + de.getMessage()); } } else { List list; Integer n = new Integer(chapterList.size() - 1); if ((list = (List) pushedMap_.get(n)) == null) { list = new ArrayList(); pushedMap_.put(n, list); } list.add(e); } }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doGet"); HttpSession httpSession = request.getSession(); EIdData eIdData = (EIdData) httpSession.getAttribute("eid"); byte[] document; try { document = this.pdfGenerator.generatePdf(eIdData); } catch (DocumentException e) { throw new ServletException("PDF generator error: " + e.getMessage(), e); } response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setContentType("application/pdf"); response.setContentLength(document.length); ServletOutputStream out = response.getOutputStream(); out.write(document); out.flush(); } }
public PDFWikiVisitor(CmsRequest request, CmsResponse response, WikiConfiguration config) { this.request_ = request; this.response_ = response; this.config_ = config; this.ctx = config.getWikiContext(); try { init(); } catch (DocumentException de) { log_ .error("failed to initialize the document : " + de.getMessage()); throw new RuntimeException(de); } }
private static Map createInitialFontMap() { HashMap result = new HashMap(); try { addCourier(result); addTimes(result); addHelvetica(result); } catch (DocumentException e) { throw new RuntimeException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } return result; }
public void loadFonts(File fontDir) { @SuppressWarnings("unchecked") final Collection<File> files = FileUtils.listFiles(fontDir, new String[] { "afm"}, true); // Read all afm files recursively. if (CollectionUtils.isNotEmpty(files) == true) { for (File file : files) { BaseFont font = null; try { font = BaseFont.createFont(file.getAbsolutePath(), BaseFont.CP1252, BaseFont.EMBEDDED); } catch (DocumentException ex) { log.error("Error while loading font '" + file.getAbsolutePath() + "': " + ex.getMessage(), ex); continue; } catch (IOException ex) { log.error("Error while loading font '" + file.getAbsolutePath() + "': " + ex.getMessage(), ex); continue; } final String fontName = font.getPostscriptFontName(); fontMap.put(fontName, font); } } } }
private static Map createInitialFontMap() { HashMap result = new HashMap(); try { addCourier(result); addTimes(result); addHelvetica(result); } catch (DocumentException e) { throw new RuntimeException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } return result; }
private static Map createInitialFontMap() { HashMap result = new HashMap(); try { addCourier(result); addTimes(result); addHelvetica(result); } catch (DocumentException e) { throw new RuntimeException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } return result; }
private static Map createInitialFontMap() { HashMap result = new HashMap(); try { addCourier(result); addTimes(result); addHelvetica(result); } catch (DocumentException e) { throw new RuntimeException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } return result; }
/** * Generates the purchase order quote request list pdf document based on the data in the given input parameters * by creating a pdf writer using the given byteArrayOutputStream then calls the createPOQuoteRequestsListPdf to * write the pdf document into the writer. * * @param po The PurchaseOrderDocument to be used to generate the pdf. * @param byteArrayOutputStream The ByteArrayOutputStream to print the pdf to. * @param institutionName The purchasing institution name. * @return Collection of errors which are made of the messages from DocumentException. */ public Collection generatePOQuoteRequestsListPdf(PurchaseOrderDocument po, ByteArrayOutputStream byteArrayOutputStream, String institutionName) { LOG.debug("generatePOQuoteRequestsListPDF() started for po number " + po.getPurapDocumentIdentifier()); Collection errors = new ArrayList(); try { Document doc = this.getDocument(); PdfWriter writer = PdfWriter.getInstance(doc, byteArrayOutputStream); this.createPOQuoteRequestsListPdf(po, doc, writer, institutionName); } catch (DocumentException de) { LOG.error(de.getMessage(), de); errors.add(de.getMessage()); } return errors; }
public void printMaterialRequirementForOrder(final ViewDefinitionState view, final ComponentState state, final String[] args) { Entity materialRequirement = printMaterialReqForOrder(state); if (materialRequirement == null) { return; } try { materialRequirementService.generateMaterialRequirementDocuments(state, materialRequirement); view.redirectTo( "/generateSavedReport/" + MaterialRequirementsConstants.PLUGIN_IDENTIFIER + "/" + MaterialRequirementsConstants.MODEL_MATERIAL_REQUIREMENT + "." + args[0] + "?id=" + materialRequirement.getId(), true, false); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } catch (DocumentException e) { throw new IllegalStateException(e.getMessage(), e); } }
private static Map createInitialFontMap() { HashMap result = new HashMap(); try { addCourier(result); addTimes(result); addHelvetica(result); addSymbol(result); addZapfDingbats(result); // Try and load the iTextAsian fonts if(ITextFontResolver.class.getClassLoader().getResource("com/lowagie/text/pdf/fonts/cjkfonts.properties") != null) { addCJKFonts(result); } } catch (DocumentException e) { throw new RuntimeException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } return result; }
private static Map createInitialFontMap() { HashMap result = new HashMap(); try { addCourier(result); addTimes(result); addHelvetica(result); addSymbol(result); addZapfDingbats(result); // Try and load the iTextAsian fonts if(ITextFontResolver.class.getClassLoader().getResource("com/lowagie/text/pdf/fonts/cjkfonts.properties") != null) { addCJKFonts(result); } } catch (DocumentException e) { throw new RuntimeException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } return result; }
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; }
public final void saveMaterialRequirementCoverageForOrder(final ViewDefinitionState view, final ComponentState state, final String[] args) throws IOException, DocumentException { state.performEvent(view, "save", args); if (!state.isHasError()) { FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(L_FORM); Long materialRequirementCoverageId = materialRequirementCoverageForm.getEntityId(); if (materialRequirementCoverageId != null) { Entity materialRequirementCoverage = mRCForOrderService.getMRCForOrder(materialRequirementCoverageId); materialRequirementCoverage.setField(CoverageForOrderFields.SAVED, true); materialRequirementCoverage = materialRequirementCoverage.getDataDefinition().save(materialRequirementCoverage); try { generateMaterialRequirementCoverageReport(materialRequirementCoverage, state.getLocale()); state.performEvent(view, "clear", new String[0]); state.addMessage("materialRequirementCoverageForOrder.coverageForOrder.report.savedMessage", MessageType.SUCCESS, materialRequirementCoverage.getStringField(CoverageForOrderFields.NUMBER)); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } catch (DocumentException e) { throw new IllegalStateException(e.getMessage(), e); } } } }