• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with a4j mediaOutput to render pdf file  RSS feed

 
Kumar Gaurav
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kumar Gaurav
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one please post any pointer in this regard.
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!