M
[Miren]
Hello with the bellow method i trying to load one PDF file.
my fisrt problem is thaat this method works with one xml file and other xsl
file
Now the xml i havn't into one file, i have into one String.
The xsl file have into one file (i can read and put into one String).
1.- Can you help me for using in this method XML String and not using one
file?
2.- this mehtod return one ByteArrayOutputStream . how can i write one PDF
file into the disk from the ByteArrayOutputStream ?
thanks
public ByteArrayOutputStream getXSL_PDF(String xmlFileName,
String xslFileName) throws IOException, FOPException {
Logger log = null;
Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
log = hierarchy.getLoggerFor("fop");
log.setPriority(Priority.FATAL_ERROR);
File xmlFile = new File(xmlFileName);
File xslFile = new File(xslFileName);
XSLTInputHandler input = new XSLTInputHandler(xmlFile, xslFile);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Driver driver = new Driver();
driver.setLogger(log);
driver.setRenderer(Driver.RENDER_PDF);
driver.setOutputStream(out);
driver.render(input.getParser(), input.getInputSource());
out.flush();
return out;
}
my fisrt problem is thaat this method works with one xml file and other xsl
file
Now the xml i havn't into one file, i have into one String.
The xsl file have into one file (i can read and put into one String).
1.- Can you help me for using in this method XML String and not using one
file?
2.- this mehtod return one ByteArrayOutputStream . how can i write one PDF
file into the disk from the ByteArrayOutputStream ?
thanks
public ByteArrayOutputStream getXSL_PDF(String xmlFileName,
String xslFileName) throws IOException, FOPException {
Logger log = null;
Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
log = hierarchy.getLoggerFor("fop");
log.setPriority(Priority.FATAL_ERROR);
File xmlFile = new File(xmlFileName);
File xslFile = new File(xslFileName);
XSLTInputHandler input = new XSLTInputHandler(xmlFile, xslFile);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Driver driver = new Driver();
driver.setLogger(log);
driver.setRenderer(Driver.RENDER_PDF);
driver.setOutputStream(out);
driver.render(input.getParser(), input.getInputSource());
out.flush();
return out;
}