亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? abstractpdfview.java

?? spring framework 2.5.4源代碼
?? JAVA
字號:
/*
 * Copyright 2002-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.web.servlet.view.document;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.util.Map;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
import com.lowagie.text.pdf.PdfWriter;

import org.springframework.web.servlet.view.AbstractView;
 
/**
 * Abstract superclass for PDF views, using Bruno Lowagie's
 * <a href="http://www.lowagie.com/iText">iText</a> package.
 * Application-specific view classes will extend this class.
 * The view will be held in the subclass itself, not in a template.
 *
 * <p>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
 */
public abstract class AbstractPdfView extends AbstractView {
	
	private static final int OUTPUT_BYTE_ARRAY_INITIAL_SIZE = 4096;


	/**
	 * 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");
	}


	protected boolean generatesDownloadContent() {
		return true;
	}

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

		// The following simple method doesn't work in IE, which
		// needs to know the content length.

		// PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
		// document.open();
		// buildPdfDocument(model, document, writer, request, response);
		// document.close();

		// See http://www.lowagie.com/iText/faq.html#msie
		// for an explanation of why we can't use the obvious form above.

		// IE workaround: write into byte array first.
		ByteArrayOutputStream baos = new ByteArrayOutputStream(OUTPUT_BYTE_ARRAY_INITIAL_SIZE);
		Document document = newDocument();
		PdfWriter writer = newWriter(document, baos);

		// Apply preferences and build metadata.
		prepareWriter(model, writer, request);
		buildPdfMetadata(model, document, request);

		// Build PDF document.
		document.open();
		buildPdfDocument(model, document, writer, request, response);
		document.close();

		// Write content type and also length (determined via byte array).
		response.setContentType(getContentType());
		response.setContentLength(baos.size());

		// Flush byte array to servlet output stream.
		ServletOutputStream out = response.getOutputStream();
		baos.writeTo(out);
		out.flush();
	}

	/**
	 * Create a new document to hold the PDF contents.
	 * <p>By default returns an A4 document, but the subclass can specify any
	 * Document, possibly parameterized via bean properties defined on the View.
	 * @return the newly created iText Document instance
	 * @see com.lowagie.text.Document#Document(com.lowagie.text.Rectangle)
	 */
	protected Document newDocument() {
		return new Document(PageSize.A4);
	}

	/**
	 * Create a new PdfWriter for the given iText Document.
	 * @param document the iText Document to create a writer for
	 * @param os the OutputStream to write to
	 * @return the PdfWriter instance to use
	 * @throws DocumentException if thrown during writer creation
	 */
	protected PdfWriter newWriter(Document document, OutputStream os) throws DocumentException {
		return PdfWriter.getInstance(document, os);
	}

	/**
	 * Prepare the given PdfWriter. Called before building the PDF document,
	 * that is, before the call to <code>Document.open()</code>.
	 * <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()</code> 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 model, PdfWriter writer, HttpServletRequest request)
			throws DocumentException {

		writer.setViewerPreferences(getViewerPreferences());
	}

	/**
	 * Return the viewer preferences for the PDF file.
	 * <p>By default returns <code>AllowPrinting</code> and
	 * <code>PageLayoutSinglePage</code>, but can be subclassed.
	 * The subclass can either have fixed preferences or retrieve
	 * them from bean properties defined on the View.
	 * @return an int containing the bits information against PdfWriter definitions
	 * @see com.lowagie.text.pdf.PdfWriter#AllowPrinting
	 * @see com.lowagie.text.pdf.PdfWriter#PageLayoutSinglePage
	 */
	protected int getViewerPreferences() {
		return PdfWriter.AllowPrinting | PdfWriter.PageLayoutSinglePage;
	}

	/**
	 * Populate the iText Document's meta fields (author, title, etc.).
	 * <br>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 <code>document.open()</code>.
	 * @param model the model, in case meta information must be populated from it
	 * @param document the iText document being populated
	 * @param request in case we need locale etc. Shouldn't look at attributes.
	 * @see com.lowagie.text.Document#addTitle
	 * @see com.lowagie.text.Document#addSubject
	 * @see com.lowagie.text.Document#addKeywords
	 * @see com.lowagie.text.Document#addAuthor
	 * @see com.lowagie.text.Document#addCreator
	 * @see com.lowagie.text.Document#addProducer
	 * @see com.lowagie.text.Document#addCreationDate
	 * @see com.lowagie.text.Document#addHeader
	*/
	protected void buildPdfMetadata(Map model, Document document, HttpServletRequest request) {
	}

	/**
	 * Subclasses must implement this method to build an iText PDF document,
	 * given the model. Called between <code>Document.open()</code> and
	 * <code>Document.close()</code> calls.
	 * <p>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.
	 * @param model the model Map
	 * @param document the iText Document to add elements to
	 * @param writer the PdfWriter to use
	 * @param request in case we need locale etc. Shouldn't look at attributes.
	 * @param response in case we need to set cookies. Shouldn't write to it.
	 * @throws Exception any exception that occured during document building
	 * @see com.lowagie.text.Document#open()
	 * @see com.lowagie.text.Document#close()
	 */
	protected abstract void buildPdfDocument(
			Map model, Document document, PdfWriter writer,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception;

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品日韩一| 丝袜亚洲精品中文字幕一区| 国产大片一区二区| 中文字幕一区二区日韩精品绯色| 精品一区二区在线观看| 国产日韩欧美一区二区三区综合| 国产精品影视在线| 亚洲www啪成人一区二区麻豆| 国内外精品视频| 欧美一区二区网站| 99精品视频在线播放观看| 欧美高清在线一区二区| 欧美午夜精品免费| 玖玖九九国产精品| 亚洲欧美在线另类| 欧美精品一区二区三| 91福利在线导航| 国产精品亚洲一区二区三区妖精| 亚洲欧美日韩一区二区 | 日韩高清一区在线| 日韩写真欧美这视频| 成人av高清在线| 成人午夜在线免费| 九九在线精品视频| 日本中文在线一区| 亚洲国产精品视频| 一区二区国产盗摄色噜噜| 久久色.com| 久久蜜桃av一区二区天堂 | 在线看不卡av| 日本道色综合久久| 日韩电影网1区2区| 欧美va在线播放| 制服丝袜中文字幕亚洲| 在线观看亚洲精品视频| gogogo免费视频观看亚洲一| 国产成人免费在线视频| 国产一区二区网址| 国产99精品国产| 国产精品一二三四区| 97久久超碰国产精品| 日本精品一级二级| 91麻豆精品国产91久久久久久久久 | 日韩欧美成人一区二区| 国产激情一区二区三区四区 | 欧美日韩一本到| 日韩欧美中文一区| 国产精品久久久久久福利一牛影视| 国产精品欧美一区二区三区| 成人欧美一区二区三区小说| 中文字幕视频一区| 青青草伊人久久| 国产精品1区2区| 欧美婷婷六月丁香综合色| 91精品国产综合久久久蜜臀粉嫩| 久久品道一品道久久精品| 亚洲人成人一区二区在线观看| 五月激情综合网| 972aa.com艺术欧美| 欧美va亚洲va香蕉在线| 一区二区三区自拍| 99久久久无码国产精品| 欧美电影免费观看高清完整版| 中文字幕一区二区三| 久久99九九99精品| 色综合av在线| 日韩理论片在线| 国产精品一区二区在线播放| 欧美一区二区三区啪啪| 亚洲福利一区二区| 色天天综合久久久久综合片| 中文字幕高清不卡| 国产不卡视频在线播放| 久久久久国产精品麻豆| 国精产品一区一区三区mba视频 | 精彩视频一区二区三区| 日韩女优毛片在线| 国产乱码精品一区二区三| 91精品国产综合久久久久久| 美美哒免费高清在线观看视频一区二区 | 成人免费在线视频观看| 成人涩涩免费视频| 亚洲视频免费在线观看| 欧美婷婷六月丁香综合色| 亚洲成av人片一区二区三区| 欧美日韩激情在线| 久久成人av少妇免费| 久久久91精品国产一区二区精品| 国产成人免费在线视频| 亚洲午夜久久久久久久久久久| 69av一区二区三区| 丰满亚洲少妇av| 午夜精品久久久久影视| 久久久亚洲精品一区二区三区| 国产69精品久久777的优势| 亚洲一二三专区| 中文字幕高清不卡| 日韩欧美国产一区二区在线播放| 国产成人超碰人人澡人人澡| 亚洲黄色在线视频| 中文一区二区在线观看| 日韩欧美精品三级| 奇米色一区二区三区四区| 日本电影欧美片| 免费观看久久久4p| 亚洲综合色丁香婷婷六月图片| 91精品国产综合久久精品图片| 国产精品88av| 国产一区二区三区蝌蚪| 日韩国产在线观看一区| 一区二区三区精品| 日韩理论在线观看| 亚洲欧美另类久久久精品| 国产精品色噜噜| 久久99深爱久久99精品| 亚洲国产精品一区二区www在线| 欧美大片国产精品| 亚洲精品在线观看网站| 日韩一区二区三区精品视频| 在线电影一区二区三区| 欧美电影一区二区三区| 欧美一级片在线看| 欧美一级理论片| 久久久综合九色合综国产精品| 精品国产1区二区| 日韩**一区毛片| 亚洲一区二区三区中文字幕| 丝袜诱惑亚洲看片| 久久99久久99| 91丨国产丨九色丨pron| 国产成人av电影在线播放| av成人动漫在线观看| 欧美日韩精品一区二区三区四区 | 亚洲一区二区三区四区在线观看 | 久久这里只有精品首页| 欧美一二三区在线观看| 激情成人综合网| 97精品久久久午夜一区二区三区| 欧美性大战久久久久久久| 精品女同一区二区| 综合在线观看色| 国产一区二区三区综合| 成人动漫av在线| 精品人在线二区三区| 香蕉av福利精品导航| 岛国av在线一区| 精品国产乱码久久久久久蜜臀| 国产精品久久久久久久浪潮网站| 亚洲www啪成人一区二区麻豆| 国产91在线观看| 欧美xxxxx牲另类人与| 日日摸夜夜添夜夜添亚洲女人| av在线不卡观看免费观看| 国产日韩成人精品| 狂野欧美性猛交blacked| 日韩视频123| 日本美女视频一区二区| 欧美一级一区二区| 麻豆国产91在线播放| 3d动漫精品啪啪1区2区免费| 午夜精品123| 欧美美女bb生活片| 久久麻豆一区二区| 国产日韩欧美高清| 欧美a级理论片| 欧美日韩一区二区电影| 一区二区三区四区不卡在线| 日韩精品视频网站| 欧美视频一二三区| 亚洲欧美色一区| 欧美日韩国产一级二级| 亚洲精品国产成人久久av盗摄| 国产美女在线观看一区| 国产亚洲成年网址在线观看| 国产mv日韩mv欧美| 亚洲人一二三区| 欧美视频中文字幕| 日韩影院精彩在线| www国产亚洲精品久久麻豆| 国产成人精品免费视频网站| 久久久影视传媒| 色网站国产精品| 中文字幕在线观看不卡| 欧美在线综合视频| 免费在线视频一区| 国产精品入口麻豆原神| 欧美日韩精品久久久| 天堂资源在线中文精品| 精品国产乱码久久| 91久久香蕉国产日韩欧美9色| 日韩成人av影视| 国产精品久久久久7777按摩| 丰满放荡岳乱妇91ww| 亚洲成av人片在线观看| 国产精品国产三级国产aⅴ无密码| 欧美日韩中文字幕精品| 成人中文字幕电影| 日日夜夜免费精品视频| 一区二区国产视频| 国产精品福利在线播放|