PDF 스트림 플러그인을 사용하면보기를 PDF 스트림으로 변환하고 결과적으로 동작으로 반환 할 수 있습니다.
기본 지원 뷰 :
2.0.0에서 PDF 렌더링으로의 HTML에서 Apache PDFBox 2를 사용하여 PDF 문서를 작성하는 OpenHTMLTOPDF 라이브러리에 의해 수행됩니다. Apache PDFBox 2는 PDF 문서로 작업하기위한 오픈 소스 Java 도구이며 Apache 라이센스 v2.0에 따라 게시됩니다.
Apache Struts 2.5와 호환되도록 업그레이드되었습니다
Java 7으로 전환
쇼케이스 응용 프로그램은 Maven Central 저장소에서 다운로드 할 수 있습니다.
struts2-pdfstream-showcase를 다운로드하십시오
버그를 찾았거나 기능 요청이 있습니까? 새 문제를 만들거나 풀 요청을 제출하십시오.
struts2-pdfstream-plugin 사용 방법에 대한 질문이있는 경우 새 문제를 만들거나 스택 오버플로에 대한 질문을하십시오.
ClassPath (Web-inf/lib)에 jars를 다음에 복사하십시오.
Maven을 사용하는 경우 프로젝트 POM에 추가하십시오.
<dependencies>
...
<dependency>
<groupId>com.amashchenko.struts2.pdfstream</groupId>
<artifactId>struts2-pdfstream-plugin</artifactId>
<version>2.0.0</version>
</dependency>
...
</dependencies>
Apache Tiles 정의를 변환하려는 경우 추가 항아리가 포함되어야합니다.
Apache 타일 지지대의 경우 struts2-pdfstream-tiles 추가하십시오.
<dependency>
<groupId>com.amashchenko.struts2.pdfstream</groupId>
<artifactId>struts2-pdfstream-tiles</artifactId>
<version>2.0.0</version>
</dependency>
pdfstream-default 패키지를 확장하거나 pdfstream 결과 유형을 추가하십시오.pdfstream 결과 유형을 사용하십시오. <action name="jspToPdf">
<result type="pdfstream">
<param name="location">/WEB-INF/pages/example.jsp</param>
<param name="cssPaths">css/bootstrap.min.css, css/style.css</param>
<param name="contentDisposition">attachment;filename=jsppdf.pdf</param>
</result>
</action>
<action name="htmlToPdf">
<result type="pdfstream">
<param name="location">/WEB-INF/pages/example.html</param>
<param name="cssPaths">css/bootstrap.min.css, css/style.css</param>
<param name="contentDisposition">attachment;filename=htmlpdf.pdf</param>
</result>
</action>
<action name="tilesToPdf">
<result type="pdfstream">
<param name="location">example</param>
<param name="renderer">tiles</param>
<param name="contentDisposition">attachment;filename=tilespdf.pdf</param>
</result>
</action>
<action name="freemarkerToPdf">
<result type="pdfstream">
<param name="location">/WEB-INF/ftl/example.ftl</param>
<param name="renderer">freemarker</param>
<param name="cssPaths">css/bootstrap.min.css, css/style.css</param>
<param name="contentDisposition">attachment;filename=ftlpdf.pdf</param>
</result>
</action>
이 플러그인은 다른 뷰 (예 : 속도)를 PDF로 변환하는 지원을 추가하기 위해 쉽게 확장 할 수 있습니다.
com.amashchenko.struts2.pdfstream.ViewRenderer 인터페이스를 구현하십시오.
struts.xml 또는 struts-plugin.xml에서 bean 정의를 생성하십시오 type="com.amashchenko.struts2.pdfstream.ViewRenderer" 및 사용자 정의 이름.
<bean type="com.amashchenko.struts2.pdfstream.ViewRenderer"
class="some.package.CustomRenderer" name="customrenderer" />
renderer 매개 변수를 정의한 Bean의 이름으로 설정 한 pdfstream 결과를 사용하십시오.
<action name="customToPdf">
<result type="pdfstream">
<param name="location">example</param>
<param name="renderer">customrenderer</param>
</result>
</action>