Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » web » servlet » view » document » [javadoc | source]
org.springframework.web.servlet.view.document
abstract public class: AbstractPdfView [javadoc | source]
java.lang.Object
   org.springframework.context.support.ApplicationObjectSupport
      org.springframework.web.context.support.WebApplicationObjectSupport
         org.springframework.web.servlet.view.AbstractView
            org.springframework.web.servlet.view.document.AbstractPdfView

All Implemented Interfaces:
    View, BeanNameAware, ServletContextAware, ApplicationContextAware

Abstract superclass for PDF views, using Bruno Lowagie's iText package. Application-specific view classes will extend this class. The view will be held in the subclass itself, not in a template.

Note: Internet Explorer requires a ".pdf" extension, as it doesn't always respect the declared content type.

Fields inherited from org.springframework.web.servlet.view.AbstractView:
DEFAULT_CONTENT_TYPE
Fields inherited from org.springframework.context.support.ApplicationObjectSupport:
logger
Constructor:
 public AbstractPdfView() 
Method from org.springframework.web.servlet.view.document.AbstractPdfView Summary:
buildPdfDocument,   buildPdfMetadata,   generatesDownloadContent,   getViewerPreferences,   newDocument,   newWriter,   prepareWriter,   renderMergedOutputModel
Methods from org.springframework.web.servlet.view.AbstractView:
addStaticAttribute,   createRequestContext,   createTemporaryOutputStream,   exposeModelAsRequestAttributes,   generatesDownloadContent,   getAttributesMap,   getBeanName,   getContentType,   getRequestContextAttribute,   getStaticAttributes,   prepareResponse,   render,   renderMergedOutputModel,   setAttributes,   setAttributesCSV,   setAttributesMap,   setBeanName,   setContentType,   setRequestContextAttribute,   toString,   writeToResponse
Methods from org.springframework.web.context.support.WebApplicationObjectSupport:
getServletContext,   getTempDir,   getWebApplicationContext,   initApplicationContext,   initServletContext,   isContextRequired,   setServletContext
Methods from org.springframework.context.support.ApplicationObjectSupport:
getApplicationContext,   getMessageSourceAccessor,   initApplicationContext,   initApplicationContext,   isContextRequired,   requiredContextClass,   setApplicationContext
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.web.servlet.view.document.AbstractPdfView Detail:
 abstract protected  void buildPdfDocument(Map model,
    Document document,
    PdfWriter writer,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception
    Subclasses must implement this method to build an iText PDF document, given the model. Called between Document.open() and Document.close() calls.

    Note that the passed-in HTTP response is just supposed to be used for setting cookies or other HTTP headers. The built PDF document itself will automatically get written to the response after this method returns.

 protected  void buildPdfMetadata(Map model,
    Document document,
    HttpServletRequest request) 
    Populate the iText Document's meta fields (author, title, etc.).
    Default is an empty implementation. Subclasses may override this method to add meta fields such as title, subject, author, creator, keywords, etc. This method is called after assigning a PdfWriter to the Document and before calling document.open().
 protected boolean generatesDownloadContent() 
 protected int getViewerPreferences() 
    Return the viewer preferences for the PDF file.

    By default returns AllowPrinting and PageLayoutSinglePage, but can be subclassed. The subclass can either have fixed preferences or retrieve them from bean properties defined on the View.

 protected Document newDocument() 
    Create a new document to hold the PDF contents.

    By default returns an A4 document, but the subclass can specify any Document, possibly parameterized via bean properties defined on the View.

 protected PdfWriter newWriter(Document document,
    OutputStream os) throws DocumentException 
    Create a new PdfWriter for the given iText Document.
 protected  void prepareWriter(Map model,
    PdfWriter writer,
    HttpServletRequest request) throws DocumentException 
    Prepare the given PdfWriter. Called before building the PDF document, that is, before the call to Document.open().

    Useful for registering a page event listener, for example. The default implementation sets the viewer preferences as returned by this class's getViewerPreferences() method.

 protected final  void renderMergedOutputModel(Map model,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception