Skip to Content
0
Former Member
May 23, 2008 at 03:41 PM

Display pdf from bapi line table in jspdynapage

18 Views

Hi Gurus,

I am trying to fetch the data from R/3 and display in PDF format in portal. I am developing jspdynpage component and jca to connect and execute RFC's in R/3.

I am getting the data in bytestream,in MIMETABLE and column is LINE. when I am running the programe , a blank pdf document opens and i am getting the "...File does not begin with '%PDF-" . please help me to overcome this issue. following is my jsp code:

Thanks

Kindest Regards

Srinivas

<%

IRecordSet ReportData = myBean.getMaterialCertificateTable();

HttpServletResponse res = componentRequest.getServletResponse(true);

res.setContentType("application/pdf");

res.setHeader(

"ContentDisposition",

"inline;filename=MaterialCertificate.pdf");

res.setHeader("Accept-Ranges", "bytes");

OutputStream os = res.getOutputStream();

byte mytextarr[] = null;

int filesize = 0;

try {

ReportData.beforeFirst();

while (ReportData.next()) {

mytextarr = ReportData.getBytes("LINE");

filesize = filesize + mytextarr.length;

}

} catch (Exception E) {

}

res.setContentLength(filesize);

try {

ReportData.beforeFirst();

while (ReportData.next()) {

mytextarr = ReportData.getBytes("LINE");

os.write(mytextarr);

}

} catch (Exception E) {

}

os.flush();

os.close();

%>