/** * Default Constructor. * <p>Sets the content type of the view to * {@code "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}. */ public AbstractXlsxView() { setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); }
/** * Default Constructor. * Sets the content type of the view to "application/vnd.ms-excel". */ public AbstractXlsView() { setContentType("application/vnd.ms-excel"); }
/** * This constructor sets the appropriate content type "application/pdf". * Note that IE won't take much notice of this, but there's not a lot we * can do about this. Generated documents should have a ".pdf" extension. */ public AbstractPdfView() { setContentType("application/pdf"); }
@Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // IE workaround: write into byte array first. ByteArrayOutputStream baos = createTemporaryOutputStream(); // Apply preferences and build metadata. Document document = newDocument(); PdfWriter writer = newWriter(document, baos); prepareWriter(model, writer, request); buildPdfMetadata(model, document, request); // Build PDF document. document.open(); buildPdfDocument(model, document, writer, request, response); document.close(); // Flush to HTTP response. writeToResponse(response, baos); }
@Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // IE workaround: write into byte array first. ByteArrayOutputStream baos = createTemporaryOutputStream(); PdfReader reader = readPdfResource(); PdfStamper stamper = new PdfStamper(reader, baos); mergePdfDocument(model, stamper, request, response); stamper.close(); // Flush to HTTP response. writeToResponse(response, baos); }
/** * Renders the Excel view, given the specified model. */ @Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Create a fresh workbook instance for this render step. Workbook workbook = createWorkbook(model, request); // Delegate to application-provided document code. buildExcelDocument(model, workbook, request, response); // Set the content type. response.setContentType(getContentType()); // Flush byte array to servlet output stream. renderWorkbook(workbook, response); }
/** * Read the raw PDF resource into an iText PdfReader. * <p>The default implementation resolve the specified "url" property * as ApplicationContext resource. * @return the PdfReader instance * @throws IOException if resource access failed * @see #setUrl */ protected PdfReader readPdfResource() throws IOException { String url = getUrl(); Assert.state(url != null, "'url' not set"); return new PdfReader(obtainApplicationContext().getResource(url).getInputStream()); }
public AbstractPdfStamperView(){ setContentType("application/pdf"); }
/** * This implementation disposes of the {@link SXSSFWorkbook} when done with rendering. * @see org.apache.poi.xssf.streaming.SXSSFWorkbook#dispose() */ @Override protected void renderWorkbook(Workbook workbook, HttpServletResponse response) throws IOException { super.renderWorkbook(workbook, response); // Dispose of temporary files in case of streaming variant... ((SXSSFWorkbook) workbook).dispose(); }
/** * Prepare the given PdfWriter. Called before building the PDF document, * that is, before the call to {@code Document.open()}. * <p>Useful for registering a page event listener, for example. * The default implementation sets the viewer preferences as returned * by this class's {@code getViewerPreferences()} method. * @param model the model, in case meta information must be populated from it * @param writer the PdfWriter to prepare * @param request in case we need locale etc. Shouldn't look at attributes. * @throws DocumentException if thrown during writer preparation * @see com.lowagie.text.Document#open() * @see com.lowagie.text.pdf.PdfWriter#setPageEvent * @see com.lowagie.text.pdf.PdfWriter#setViewerPreferences * @see #getViewerPreferences() */ protected void prepareWriter(Map<String, Object> model, PdfWriter writer, HttpServletRequest request) throws DocumentException { writer.setViewerPreferences(getViewerPreferences()); }
@Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // IE workaround: write into byte array first. ByteArrayOutputStream baos = createTemporaryOutputStream(); // Apply preferences and build metadata. Document document = newDocument(); PdfWriter writer = newWriter(document, baos); prepareWriter(model, writer, request); buildPdfMetadata(model, document, request); // Build PDF document. document.open(); buildPdfDocument(model, document, writer, request, response); document.close(); // Flush to HTTP response. writeToResponse(response, baos); }
@Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // IE workaround: write into byte array first. ByteArrayOutputStream baos = createTemporaryOutputStream(); PdfReader reader = readPdfResource(); PdfStamper stamper = new PdfStamper(reader, baos); mergePdfDocument(model, stamper, request, response); stamper.close(); // Flush to HTTP response. writeToResponse(response, baos); }
/** * Renders the Excel view, given the specified model. */ @Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Create a fresh workbook instance for this render step. Workbook workbook = createWorkbook(model, request); // Delegate to application-provided document code. buildExcelDocument(model, workbook, request, response); // Set the content type. response.setContentType(getContentType()); // Flush byte array to servlet output stream. renderWorkbook(workbook, response); }
/** * Read the raw PDF resource into an iText PdfReader. * <p>The default implementation resolve the specified "url" property * as ApplicationContext resource. * @return the PdfReader instance * @throws IOException if resource access failed * @see #setUrl */ protected PdfReader readPdfResource() throws IOException { String url = getUrl(); Assert.state(url != null, "'url' not set"); return new PdfReader(obtainApplicationContext().getResource(url).getInputStream()); }
/** * Default Constructor. * <p>Sets the content type of the view to * {@code "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}. */ public AbstractXlsxView() { setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); }
/** * Default Constructor. * Sets the content type of the view to "application/vnd.ms-excel". */ public AbstractXlsView() { setContentType("application/vnd.ms-excel"); }
/** * This constructor sets the appropriate content type "application/pdf". * Note that IE won't take much notice of this, but there's not a lot we * can do about this. Generated documents should have a ".pdf" extension. */ public AbstractPdfView() { setContentType("application/pdf"); }
public AbstractPdfStamperView(){ setContentType("application/pdf"); }
/** * This implementation disposes of the {@link SXSSFWorkbook} when done with rendering. * @see org.apache.poi.xssf.streaming.SXSSFWorkbook#dispose() */ @Override protected void renderWorkbook(Workbook workbook, HttpServletResponse response) throws IOException { super.renderWorkbook(workbook, response); // Dispose of temporary files in case of streaming variant... ((SXSSFWorkbook) workbook).dispose(); }
/** * Prepare the given PdfWriter. Called before building the PDF document, * that is, before the call to {@code Document.open()}. * <p>Useful for registering a page event listener, for example. * The default implementation sets the viewer preferences as returned * by this class's {@code getViewerPreferences()} method. * @param model the model, in case meta information must be populated from it * @param writer the PdfWriter to prepare * @param request in case we need locale etc. Shouldn't look at attributes. * @throws DocumentException if thrown during writer preparation * @see com.lowagie.text.Document#open() * @see com.lowagie.text.pdf.PdfWriter#setPageEvent * @see com.lowagie.text.pdf.PdfWriter#setViewerPreferences * @see #getViewerPreferences() */ protected void prepareWriter(Map<String, Object> model, PdfWriter writer, HttpServletRequest request) throws DocumentException { writer.setViewerPreferences(getViewerPreferences()); }