public abstract class AbstractPdfStamperView extends AbstractUrlBasedView
このビューの実装では、Bruno Lowagie の iText API を使用します。オリジナルの iText 2.1.7 とそのフォークである OpenPDF で動作することが知られています。OpenPDF は積極的にメンテナンスされており、信頼できない PDF コンテンツに対する重要な脆弱性を修正しているため、強くお勧めします。
提案と元のプロトタイプを提供してくれた Bryant Larsen に感謝します。
AbstractPdfViewDEFAULT_CONTENT_TYPEloggerPATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE| コンストラクターと説明 |
|---|
AbstractPdfStamperView() |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected boolean | generatesDownloadContent() このビューがダウンロードコンテンツ(通常は PDF ファイルや Excel ファイルなどのバイナリコンテンツ)を生成するかどうかを返します。 |
protected abstract void | mergePdfDocument(MapSE<StringSE, ObjectSE> model, com.lowagie.text.pdf.PdfStamper stamper, HttpServletRequestEE request, HttpServletResponseEE response)PDF フォームを特定のモデルデータとマージするには、サブクラスがこのメソッドを実装する必要があります。 |
protected com.lowagie.text.pdf.PdfReader | readPdfResource() 生の PDF リソースを iText PdfReader に読み込みます。 |
protected void | renderMergedOutputModel(MapSE<StringSE, ObjectSE> model, HttpServletRequestEE request, HttpServletResponseEE response) ビューを実際にレンダリングするには、サブクラスでこのメソッドを実装する必要があります。 |
afterPropertiesSet, checkResource, getUrl, isUrlRequired, setUrl, toStringaddStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponsegetServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextgetApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContextcloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSEprotected boolean generatesDownloadContent()
AbstractView デフォルトの実装は false を返します。通常、レスポンス OutputStream を介して、クライアント側で一時キャッシュを必要とするダウンロードコンテンツを生成していることがわかっている場合、サブクラスはここで true を返すことが推奨されます。
protected final void renderMergedOutputModel(MapSE<StringSE,ObjectSE> model, HttpServletRequestEE request, HttpServletResponseEE response) throws ExceptionSE
AbstractView最初のステップは、リクエストの準備です。JSP の場合、これはモデルオブジェクトをリクエスト属性として設定することを意味します。2 番目のステップは、たとえば RequestDispatcher を介した JSP を含む、実際のビューのレンダリングです。
AbstractView の renderMergedOutputModel model - 静的な属性よりも動的な値が優先される、結合された出力マップ(非 null)request - 現在の HTTP リクエスト response - 現在の HTTP レスポンス ExceptionSE - レンダリングに失敗した場合 protected com.lowagie.text.pdf.PdfReader readPdfResource()
throws IOExceptionSEデフォルトの実装では、指定された "url" プロパティを ApplicationContext リソースとして解決します。
IOExceptionSE - リソースへのアクセスに失敗した場合 AbstractUrlBasedView.setUrl(java.lang.String)protected abstract void mergePdfDocument(MapSE<StringSE,ObjectSE> model, com.lowagie.text.pdf.PdfStamper stamper, HttpServletRequestEE request, HttpServletResponseEE response) throws ExceptionSE
これは、AcroForm で値を設定できる場所です。このレベルで実行できることの例は次のとおりです。
// get the form from the document
AcroFields form = stamper.getAcroFields();
// set some values on the form
form.setField("field1", "value1");
form.setField("field2", "Vvlue2");
// set the disposition and filename
response.setHeader("Content-disposition", "attachment; FILENAME=someName.pdf");渡された HTTP レスポンスは、Cookie またはその他の HTTP ヘッダーを設定するために使用されることに注意してください。ビルドされた PDF ドキュメント自体は、このメソッドが返された後、自動的にレスポンスに書き込まれます。
model - モデルマップ stamper - AcroFields を含む PdfStamper インスタンス。この PdfStamper インスタンスを必要に応じてカスタマイズすることもできます (例: "formFlattening" プロパティの設定)。request - ロケールなどが必要な場合に備えて。属性を見てはいけません。response - クッキーを設定する必要がある場合に備えて。書いてはいけません。ExceptionSE - ドキュメントの構築中に発生した例外