public void xdoPdf(
oracle.apps.fnd.common.AppsContext appsContext,
String datatemplateName,
String templateName,
java.util.Properties params,
{
java.sql.Connection conn;
conn = appsContext.getJDBCConnection();
java.io.InputStream datatemplate = null;
java.sql.Blob blob = null;
java.sql.CallableStatement stmt =
conn.prepareCall(
"select file_data from xdo_lobs where lob_code = :1 and lob_type = :2");
stmt.setString(1, datatemplateName);
stmt.setString(2, "DATA_TEMPLATE");
stmt.execute();
java.sql.ResultSet rs = stmt.getResultSet();
rs.next();
blob = rs.getBlob(1);
datatemplate = blob.getBinaryStream();
stmt.close();
oracle.apps.xdo.dataengine.DataProcessor dataProcessor = new DataProcessor();
dataProcessor.setDataTemplate(datatemplate);
ArrayList parameters;
parameters = dataProcessor.getParameters();
for (Iterator it = parameters.iterator(); it.hasNext();)
{
Parameter p = (Parameter) it.next();
if (params.get(p.getName()) != null)
{
p.setValue(params.get(p.getName()));
}
}
dataProcessor.setParameters(parameters);
ByteArrayOutputStream dataOut = new ByteArrayOutputStream();
ByteArrayInputStream dataIn;
dataProcessor.setConnection(conn);
dataProcessor.setOutput(dataOut);
dataProcessor.processData();
dataIn = new ByteArrayInputStream(dataOut.toByteArray());
blob = null;
java.io.InputStream template = null;
CallableStatement stmt =
conn.prepareCall(
"select file_data from xdo_lobs where lob_code = :1 and lob_type = :2");
stmt.setString(1, templateName);
stmt.setString(2, "TEMPLATE");
stmt.execute();
ResultSet rs = stmt.getResultSet();
rs.next();
blob = rs.getBlob(1);
template = blob.getBinaryStream();
stmt.close();
ByteArrayOutputStream pdfOut = new ByteArrayOutputStream();
ByteArrayInputStream pdfIn;
oracle.apps.xdo.template.FOProcessor processor = new FOProcessor();
processor.setTemplate(template);
processor.setConfig(new Properties());
processor.setData(dataIn);
processor.setOutput(pdfOut);
processor.setOutputFormat(FOProcessor.FORMAT_PDF);
processor.generate();
pdfIn = new ByteArrayInputStream(pdfOut.toByteArray());
}
This entry was posted
on Tuesday, May 6th, 2008 at 4.23 pm and is filed under Oracle.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.