| org.springframework.web.servlet.view.AbstractView org.springframework.web.servlet.view.document.AbstractPdfView
AbstractPdfView | abstract public class AbstractPdfView extends AbstractView (Code) | | 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.
author: Rod Johnson author: Jean-Pierre Pawlak author: Juergen Hoeller |
Constructor Summary | |
public | AbstractPdfView() 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. |
Method Summary | |
abstract protected void | buildPdfDocument(Map model, Document document, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) Subclasses must implement this method to build an iText PDF document,
given the model. | protected void | buildPdfMetadata(Map model, Document document, HttpServletRequest request) Populate the iText Document's meta fields (author, title, etc.).
Default is an empty implementation. | protected int | getViewerPreferences() Return the viewer preferences for the PDF file. | protected Document | newDocument() Create a new document to hold the PDF contents. | protected PdfWriter | newWriter(Document document, OutputStream os) Create a new PdfWriter for the given iText Document. | protected void | prepareWriter(Map model, PdfWriter writer, HttpServletRequest request) Prepare the given PdfWriter. | final protected void | renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) |
AbstractPdfView | public AbstractPdfView()(Code) | | 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.
|
buildPdfDocument | abstract protected void buildPdfDocument(Map model, Document document, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws Exception(Code) | | 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.
Parameters: model - the model Map Parameters: document - the iText Document to add elements to Parameters: writer - the PdfWriter to use Parameters: request - in case we need locale etc. Shouldn't look at attributes. Parameters: response - in case we need to set cookies. Shouldn't write to it. throws: Exception - any exception that occured during document building See Also: com.lowagie.text.Document.open See Also: com.lowagie.text.Document.close |
buildPdfMetadata | protected void buildPdfMetadata(Map model, Document document, HttpServletRequest request)(Code) | | 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() .
Parameters: model - the model, in case meta information must be populated from it Parameters: document - the iText document being populated Parameters: request - in case we need locale etc. Shouldn't look at attributes. See Also: com.lowagie.text.Document.addTitle See Also: com.lowagie.text.Document.addSubject See Also: com.lowagie.text.Document.addKeywords See Also: com.lowagie.text.Document.addAuthor See Also: com.lowagie.text.Document.addCreator See Also: com.lowagie.text.Document.addProducer See Also: com.lowagie.text.Document.addCreationDate See Also: com.lowagie.text.Document.addHeader |
getViewerPreferences | protected int getViewerPreferences()(Code) | | 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.
an int containing the bits information against PdfWriter definitions See Also: com.lowagie.text.pdf.PdfWriter.AllowPrinting See Also: com.lowagie.text.pdf.PdfWriter.PageLayoutSinglePage |
newDocument | protected Document newDocument()(Code) | | 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.
the newly created iText Document instance See Also: com.lowagie.text.Document.Document(com.lowagie.text.Rectangle) |
newWriter | protected PdfWriter newWriter(Document document, OutputStream os) throws DocumentException(Code) | | Create a new PdfWriter for the given iText Document.
Parameters: document - the iText Document to create a writer for Parameters: os - the OutputStream to write to the PdfWriter instance to use throws: DocumentException - if thrown during writer creation |
prepareWriter | protected void prepareWriter(Map model, PdfWriter writer, HttpServletRequest request) throws DocumentException(Code) | | 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.
Parameters: model - the model, in case meta information must be populated from it Parameters: writer - the PdfWriter to prepare Parameters: request - in case we need locale etc. Shouldn't look at attributes. throws: DocumentException - if thrown during writer preparation See Also: com.lowagie.text.Document.open See Also: com.lowagie.text.pdf.PdfWriter.setPageEvent See Also: com.lowagie.text.pdf.PdfWriter.setViewerPreferences See Also: AbstractPdfView.getViewerPreferences() |
Fields inherited from org.springframework.web.servlet.view.AbstractView | final public static String DEFAULT_CONTENT_TYPE(Code)(Java Doc)
|
|
|