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)
save pdf on server after Report Rendering / Factory
birtprofi
<p>Hi everbody,</p><p> </p><p>I use an interactive Report with a lot of html text fields, so the user could make some changes. After the user has finished I put the text fields (= parameters of the second Report) into a href link and render a Second-Report.</p><p> </p><p>After the second report is rendered it should save a pdf file on server side automatically. For this purpose I use the ReportEngine with this script:</p><pre class="_prettyXprint _lang-js">importPackage(Packages.org.eclipse.birt.report.engine.api);var re = reportContext.getReportRunnable().getReportEngine();var des = re.openReportDesign("C:/personal1.rptdesign"); var ntask = re.createRunAndRenderTask(des);ntask.setParameterValue("createPDF", false);ntask.setParameterValue("Vorname", params["Vorname"].value);ntask.setParameterValue("Nachname", params["Nachname"].value);var options = new PDFRenderOption();var outputfile = "C:/birt43/ReportEngine/samples/test.pdf";options.setOutputFileName(outputfile);options.setOutputFormat("pdf");ntask.setRenderOption(options);ntask.run();ntask.close(); </pre><p>Because I have a lot of parameters and after rendering all parameters are known, my question is:</p><p> </p><p>Is it necessary to initialize every parameter in this script with "ntask.setParameterValue", or is there an easier method to call all parameters? Also this script run and render the report again. Maybe there is an other way to solve my issue.</p><p> </p><p>The purpose is after render save a pdf file on server side automatically.</p><p> </p><p>I´am looking for your answers.</p><p> </p><p>best regards</p><p>rjf</p>
Find more posts tagged with
Comments
birtprofi
<p>I found a solution from Jason Weathersby that works quite good. So if you want to render a report and save as pdf on the server. You could take this script:</p><p> </p><p>beforeFactory:</p><pre class="_prettyXprint _lang-js">mmap = reportContext.getHttpServletRequest().getAttribute("attributeBean").getModuleOptions()</pre><p>beforeRender:</p><pre class="_prettyXprint _lang-js">mmap = reportContext.getHttpServletRequest().getAttribute("attributeBean").getModuleOptions();rptdoc = reportContext.getHttpServletRequest().getAttribute("attributeBean").getReportDocumentName();importPackage(Packages.org.eclipse.birt.report.engine.api);importPackage(Packages.java.io)var re = reportContext.getReportRunnable().getReportEngine();var mdocument = re.openReportDocument(null,rptdoc, mmap); var options = new PDFRenderOption();baos = new ByteArrayOutputStream(); options.setOutputFormat("pdf");options.setOutputStream(baos);var ntask = re.createRenderTask(mdocument); ntask.setRenderOption(options);ntask.render();ntask.close();mdocument.close();unique = params["ID"].valuefout = new FileOutputStream("c:/Consens/myreport" + unique + ".pdf"); fout.write(baos.toByteArray());fout.flush()fout.close(); </pre><p>I use the unique variable, so every generated report will be unique.</p><p> </p><p>Create a Label within the Report and onCreate:</p><pre class="_prettyXprint _lang-js">this.text = reportContext.getHttpServletRequest().getAttribute("attributeBean").isDesigner();</pre><p>I hope someone could use this. It´s very simple and works very well.</p><p> </p><p>best regards</p><p>rjf</p>
Donna111
<p>HI there</p><p>I usually save pdf files using a pdf processing tool.They support to <a data-ipb='nomediaparse' href='
http://www.rasteredge.com/how-to/csharp-imaging/pdf-get-to-start/'>save
or print pdf</a> files.It's convinient for my work.</p><p>But i've never tried to save pdf on server after Report Rendering.You can just have a try on the pdf program.</p>