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 15 and version 14:

At line 146 added 1 line.
At line 362 changed 1 line.
import org.appfuse.utils.FOPHelper;
import org.appfuse.fop.FOPHelper;
At line 365 changed 33 lines.
public void testGeneratePDF() throws Exception {
try {
User testData = new User();
testData.setUsername("tomcat");
testData.getRoles().add(new Role("user"));
// set expected behavior on dao
userDAO.expects(once()).method("getUser")
.with(eq("tomcat")).will(returnValue(testData));
user = userManager.getUser("tomcat");
File baseDir = new File(".");
File xslFile = new File(baseDir, "./src/web/org/appfuse/webapp/fop/user2fo.xsl");
if (xslFile.exists()) {
log.info("xslFile exists");
}
File pdfFile = new File(baseDir, "user.pdf");
File xmlFile = new File(baseDir, "user.xml");
log.debug("Input: a User object");
log.debug("Stylesheet: " + xslFile);
log.debug("Output: PDF (" + pdfFile + ")");
log.debug("Transforming...");
FOPHelper fopHelper = new FOPHelper();
fopHelper.convertUser2PDF(user, xslFile, pdfFile);
fopHelper.convertUser2XML(user, xmlFile);
}
catch (Throwable e) {
log.error("Error [" + e.getMessage() + "]", e);
}
public void testGeneratePDF() throws Exception {
log.info("Inside testGeneratePSF");
User testData = new User();
testData.setUsername("tomcat");
testData.getRoles().add(new Role("user"));
// set expected behavior on dao
userDAO.expects(once()).method("getUser")
.with(eq("tomcat")).will(returnValue(testData));
user = userManager.getUser("tomcat");
UserInputSource uis = new UserInputSource(user);
// Setup directories
File baseDir = new File(".");
File outDir = new File(".");
outDir.mkdirs();
//Setup input and output
File xslFile = new File(baseDir, "./src/web/org/appfuse/webapp/fop/user2fo.xsl");
File pdfFile = new File(outDir, "user.pdf");
File xmlFile = new File(outDir, "user.xml");
File foFile = new File(outDir, "user.fo");
log.debug("Input: a UserInputSource object");
log.debug("Stylesheet: " + xslFile);
log.debug("Output: PDF (" + pdfFile + ")");
log.debug("Output: FO (" + foFile + ")");
log.debug("Transforming...");
FOPHelper fopHelper = new FOPHelper();
fopHelper.convertPOJO2PDF(uis, xslFile, pdfFile, foFile);
fopHelper.convertPOJO2XML(uis, xmlFile);

Back to POJOToPDF, or to the Page History.