• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Returning a PDF Document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Returning a PDF Document


  • Subject: Re: Returning a PDF Document
  • From: Greg <email@hidden>
  • Date: Fri, 22 Apr 2005 10:23:21 +1000

This is my superclass for xsl:fo reports that generate to pdf.

HTH,
Greg

public class ShoeBoxFOPComponent extends ShoeBoxComponent
{
private static ERXLogger log = ERXLogger.getERXLogger(ShoeBoxFOPComponent.class);

private String filename = "Report.pdf";

public ShoeBoxFOPComponent(WOContext context) {
super(context);
}

public void appendToResponse(WOResponse response, WOContext context) {
super.appendToResponse(response, context);

ByteArrayOutputStream pdfOut = new ByteArrayOutputStream();

try
{
ByteArrayInputStream foIn = new ByteArrayInputStream(response.content().bytes());
org.xml.sax.InputSource foIs = new org.xml.sax.InputSource(new InputStreamReader(foIn));

Driver driver = new Driver(foIs, pdfOut);
/* try {
Logger theLog = new Log4JLogger(log);
driver.setLogger(theLog);
} catch(Exception e)
{ log.error("Error Setting FOP logger: " + e); }
*/


driver.setRenderer(Driver.RENDER_PDF);
driver.run();
}
catch(IOException ioe)
{ log.error("Error creating PDF: " + ioe); }
catch(FOPException fe)
{ log.error("Error creating PDF: " + fe); }

response.setContentEncoding("UTF8");
response.setHeader("application/pdf", "content-type");
response.setHeader("filename=" + filename,"Content-Disposition");
response.setContent(new NSData(pdfOut.toByteArray()));
response.setStatus(WOMessage.HTTP_STATUS_OK);
}

public void setFilename(String name)
{
filename = name;
}

public String filename()
{
return filename;
}
}
On 22/04/2005, at 10:05 AM, Deirdre Saoirse Moen wrote:


So, normally a WOHyperlink's action returns a WOComponent; for the same
page, it's null.

However, I'm clicking on a WOHyperlink which is linked to an action. The
action's code will generate an XML file, transform it via xsl-fo to PDF,
and I want to return the PDF. I'm not using ReportMill or anything fancy
here, just vanilla WO, plus the Java tools to do the transformation.


So, my questions:

1) Do I need to wrap the PDF into a WOComponent? If so, can someone point
me at an example?


2) I'd rather return a streamed PDF. Yes, I'll write a temp file, but I
don't want it to persist. I can't seem to find out how to do that, either.


-- _Deirdre web: http://deirdre.net blog: http://deirdre.org/blog/
yarn: http://fuzzyorange.com cat's blog: http://fuzzyorange.com/vsd/
"Memes are a hoax! Pass it on!"


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Returning a PDF Document (From: Deirdre Saoirse Moen <email@hidden>)

  • Prev by Date: Logging in a Deployed environment.
  • Next by Date: Re: Returning a PDF Document
  • Previous by thread: Returning a PDF Document
  • Next by thread: Re: Returning a PDF Document
  • Index(es):
    • Date
    • Thread