aspose file tools
The moose likes JSF and the fly likes Problem with a4j mediaOutput to render pdf file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Problem with a4j mediaOutput to render pdf file" Watch "Problem with a4j mediaOutput to render pdf file" New topic
Author

Problem with a4j mediaOutput to render pdf file

Kumar Gaurav
Ranch Hand

Joined: Apr 08, 2008
Posts: 108
Hi All,

I am using a4j:mediaoutput to render pdf but it ir throwing error "File does not begin with '%PDF-'".
Please find below the code i am using :

public void generatePdf(OutputStream out, Object object) {

WEBLOGGER.info("inside generatePdf method");

if (null !=out && null != object) {
WEBLOGGER.info("inside generatePdf method for pdf");
byte[] buf = getPdfBytes();
if (null != buf && buf.length > 0) {
try {
out.write(buf);
out.close();
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

<h:panelGroup id="wrapUpPdf">
<a4j:mediaOutput element="object" cacheable="false" session="false"
standby="Loading Pdf..." mimeType="application/pdf"
type="application/pdf" style="width: 711px;height: 985px"
createContent="#{orderProcessingBOCardBean.generatePdf}" />
</h:panelGroup>

Please suggest me as i am stuck.


Regards,
Gaurav
Kumar Gaurav
Ranch Hand

Joined: Apr 08, 2008
Posts: 108
can any one please post any pointer in this regard.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14456
    
    7

I can't say anything for certain, but what I'd do would be put the code in a debugger and see what's being read into the buffer. In other words, see what "getPdfBytes" is actually giving to you.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with a4j mediaOutput to render pdf file
 
Similar Threads
DataTable inside a DataTable
sax parser with cdata
Problem with processing data files of size larger than 350 MB
Wierd problem while using valueChangeListener() during submit of a form
File Download problem using icefaces