ปลั๊กอินสตรีม PDF อนุญาตให้แปลงมุมมองเป็นสตรีม PDF และส่งคืนเป็นผลมาจากการกระทำ
มุมมองที่รองรับเริ่มต้น:
เริ่มต้นจาก 2.0.0, HTML ในการแสดงผล PDF ทำได้โดยไลบรารี OpenHTMLTopDF ซึ่งใช้ Apache PDFBox 2 เพื่อสร้างเอกสาร PDF Apache PDFBox 2 เป็นเครื่องมือโอเพ่นซอร์ส Java สำหรับการทำงานกับเอกสาร PDF และเผยแพร่ภายใต้ใบอนุญาต Apache v2.0
อัพเกรดให้เข้ากันได้กับ apache struts 2.5
เปลี่ยนเป็น Java 7
แอปพลิเคชัน Showcase สามารถดาวน์โหลดได้จากที่เก็บ Maven Central
ดาวน์โหลด struts2-pdfstream-showcase
พบข้อผิดพลาดหรือมีคำขอคุณสมบัติ? สร้างปัญหาใหม่หรือส่งคำขอดึง
หากคุณมีคำถามเกี่ยวกับวิธีการใช้ struts2-pdfstream-plugin สร้างปัญหาใหม่หรือถามคำถามเกี่ยวกับสแต็กล้น
คัดลอกขวดต่อไปนี้ลงใน ClassPath ของคุณ (Web-inf/lib):
หากคุณใช้ Maven ให้เพิ่มสิ่งนี้ลงในโครงการ POM ของคุณ:
<dependencies>
...
<dependency>
<groupId>com.amashchenko.struts2.pdfstream</groupId>
<artifactId>struts2-pdfstream-plugin</artifactId>
<version>2.0.0</version>
</dependency>
...
</dependencies>
หากคุณตั้งใจจะแปลงคำจำกัดความของ Apache Tiles Jar เพิ่มเติม
สำหรับรองรับ Apache Tiles เพิ่ม struts2-pdfstream-tiles
<dependency>
<groupId>com.amashchenko.struts2.pdfstream</groupId>
<artifactId>struts2-pdfstream-tiles</artifactId>
<version>2.0.0</version>
</dependency>
pdfstream-default หรือเพิ่มประเภทผลลัพธ์ pdfstreampdfstream <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 ด้วย type="com.amashchenko.struts2.pdfstream.ViewRenderer" และชื่อที่กำหนดเอง
<bean type="com.amashchenko.struts2.pdfstream.ViewRenderer"
class="some.package.CustomRenderer" name="customrenderer" />
ใช้ผลลัพธ์ pdfstream ด้วยพารามิเตอร์เร renderer ที่ตั้งค่าเป็นชื่อของถั่วที่คุณกำหนดไว้
<action name="customToPdf">
<result type="pdfstream">
<param name="location">example</param>
<param name="renderer">customrenderer</param>
</result>
</action>