Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
Articles_cn
Articles_de
Articles_pt
Articles_zh




JSPWiki v2.2.33

[RSS]


Hide Menu

POJOToPDF


Difference between version 13 and version 12:

At line 144 added 1 line.
At line 423 changed 1 line.
At line 427 changed 1 line.
import org.appfuse.fop.UserXMLReader;
import org.appfuse.fop.FOPHelper;
At line 434 changed 5 lines.
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.*;
import java.util.Date;
At line 444 changed 1 line.
At line 446 removed 1 line.
import org.springframework.core.io.ClassPathResource;
At line 449 changed 1 line.
import org.springframework.core.io.*;
import org.xml.sax.InputSource;
At line 458 added 1 line.
import javax.xml.transform.sax.SAXSource;
At line 456 changed 1 line.
At line 461 changed 1 line.
* <p><a href="FopServlet.java.html"><i>View Source</i></a></p>
* <p><a href="FOPServlet.java.html"><i>View Source</i></a></p>
At line 467 changed 1 line.
* display-name="Fop Servlet"
* display-name="FOP Servlet"
At line 474 changed 4 lines.
public class FopServlet extends HttpServlet {
private Logger logger = null;
public class FOPServlet extends HttpServlet {
private Logger logger = null;
At line 480 changed 2 lines.
At line 483 changed 3 lines.
this.servletContext = getServletContext();
this.ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
this.servletContext = getServletContext();
this.ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
At line 487 changed 1 line.
At line 501 changed 1 line.
At line 515 changed 1 line.
At line 528 changed 4 lines.
ByteArrayOutputStream out = null;
try {
ByteArrayOutputStream out = null;
try {
At line 533 changed 1 line.
At line 536 changed 30 lines.
Driver driver = new Driver();
Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
driver.setLogger(logger);
MessageHandler.setScreenLogger(logger);
driver.setRenderer(Driver.RENDER_PDF);
// Start with a bigger buffer to avoid too many buffer reallocations
out = new ByteArrayOutputStream(16384);
driver.setOutputStream(out);
ClassPathResource resource = new
ClassPathResource("/org/appfuse/webapp/fop/user2fo.xsl");
File xslFile = resource.getFile();
//Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xslFile));
//Setup input for XSLT transformation
Source src = new UserInputSource(user).getSource();
//Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(driver.getContentHandler());
//Start XSLT transformation and FOP processing
transformer.transform(src, res);
byte[] content = out.toByteArray();
UserInputSource uis = new UserInputSource(user);
ClassPathResource resource =
new ClassPathResource("/org/appfuse/webapp/fop/user2fo.xsl");
byte[] content = FOPHelper.createPDF(uis, resource);
response.setHeader("Content-Disposition",
"attachment; filename=user-" + user.getUsername() + ".pdf");
At line 567 removed 2 lines.
response.setHeader("Content-Disposition", "attachment; filename=user-" +
user.getUserName() + ".pdf");
At line 572 changed 1 line.
At line 576 changed 3 lines.
if (out!=null) {
out.close();
}
if (out!=null) {
out.close();
}
At line 562 added 1 line.
]
At line 583 removed 2 lines.
}]

Back to POJOToPDF, or to the Page History.