Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Rendering to pdf & html from the same task?
hq4ever
Hello,<br />
<br />
I would like to render from the same rptdesign to pdf and to html.<br />
The idea here is not to lead the database twice.<br />
<br />
Does this code load the DB twice ?<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>task.setRenderOption(pdfOptions);
task.run();
task.setRenderOption(htmlOptions);
task.run();</pre>
Also, would someone mind explaining what <br />
<pre class='_prettyXprint _lang-auto _linenums:0'>task.close</pre> does ?
Find more posts tagged with
Comments
johnw
If you are using the IRunAndRender task, yes it will. However, if you want to render to two different formats and NOT hit the database twice, you can do a Run task, than two seperate Render tasks, something like:
IRunTask runTask = task = engine.createRunTask(engine.openReportDesign(reportPath));
String tempFile = File.createTempFile("brtRun" + id.replace(" ", "_").replace(":", ""), ".tmp").getAbsolutePath();
task.run(tempFile);
task.close();
IRenderOption renderOptionHTML = new HTMLRenderOption();
renderOptionHTML .setOutputFormat("HTML");
IRenderOption renderOptionPDF = new PDFRenderOption();
renderOptionPDF .setOutputFormat("PDF");
IReportDocument document = engine.openReportDocument(tempFile);
IRenderTask htmlTask = engine.createRenderTask(document);
IRenderTask pdfTask = engine.createRenderTask(document);
htmlTask.setRenderOption(renderOptionHTML);
pdfTask.setRenderOption(renderOptionPDF);
htmlTask.run();
pdfTask.run();
htmlTask.close();
pdfTask.close();
Just be sure to set your render options, such as output format or stream, which aren't in the above example.
johnw
Sorry, I didn't answer your second questions. The Task.close() closes the render task and frees up the resources it was using, and prepares objects for garbage collection. You always want to close a task when completed, especially if your a multi-threading your tasks since it may keep the task from getting shut down, which will slow your engine down due to a lack of worker threads.