Package org.geomajas.plugin.printing.document

Examples of org.geomajas.plugin.printing.document.Document


public class DocumentView extends AbstractView {

  @Override
  protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    Document doc = (Document) model.get(PrintingController.DOCUMENT_KEY);
    String download = (String) model.get(PrintingController.DOWNLOAD_KEY);
    String fileName = (String) model.get(PrintingController.FILENAME_KEY);
    Format format = (Format) model.get(PrintingController.FORMAT_KEY);
       
    // Write content type and also length (determined via byte array).
    response.setContentType(format.getMimetype());
    response.setContentLength(doc.getContentLength());
   
    // check download method
    if (download.equals(PrintingController.DOWNLOAD_METHOD_SAVE)) {
      response.setHeader("Content-Disposition", " attachment; filename=\"" + fileName + "\"");
    } else if (download.equals(PrintingController.DOWNLOAD_METHOD_BROWSER)) {
      response.setHeader("Content-Disposition", " inline; filename=\"" + fileName + "\"");
    } else {
      throw new IllegalArgumentException("invalid download method " + download);
    }

    // Write the docmuent
    ServletOutputStream out = response.getOutputStream();
    doc.render(out, format);
    out.flush();
  }
View Full Code Here

TOP

Related Classes of org.geomajas.plugin.printing.document.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.