Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » PDF Render: Export to PDF file exports only first page(PDF Render: Export to PDF file exports only first page)
PDF Render: Export to PDF file exports only first page [message #876660] Thu, 24 May 2012 23:48 Go to next message
Madhana Gopal is currently offline Madhana Gopal
Messages: 2
Registered: January 2012
Junior Member
Hi,

I am trying to export the report as PDF while rendering the report using JAVASCRIPT. I have put the below code under afterFactory event (actually tried in all event beforeFactory, beforeRender & afterRender). It is generating the PDF file successfully, but it is generating only the first page. But while rendering the report it shows 2 pages.

Below here is my Code:

****************************************************************************
mmap = reportContext.getHttpServletRequest().getAttribute("attributeBean").getModuleOptions();

myAttributeBean = reportContext.getHttpServletRequest().getAttribute('attributeBean');
rptdoc = myAttributeBean.getReportDocumentName();

importPackage(Packages.org.eclipse.birt.report.engine.api);
importPackage(Packages.java.io);
importPackage(Packages.java.util);
importPackage(Packages.java.lang);

var re = reportContext.getReportRunnable().getReportEngine();
var mdocument = re.openReportDocument(rptdoc);

var fName = reportContext.getPersistentGlobalVariable("ponumber");
var cNum = reportContext.getPersistentGlobalVariable("compnumber")+"";


var options = new PDFRenderOption();
options.setOption(PDFRenderOption.PAGE_OVERFLOW, Integer.valueOf(PDFRenderOption.OUTPUT_TO_MULTIPLE_PAGES));
options.setOutputFormat("pdf");
options.setOption(PDFRenderOption.PAGE_OVERFLOW, IPDFRenderOption.FIT_TO_PAGE_SIZE);
options.setOption( IRenderOption.HTML_PAGINATION, Boolean.FALSE );

switch (cNum){
case '201':
options.setOutputFileName("D:/InforWflow/attachment/test/comp201/" + fName +".pdf");
break;
case '202':
options.setOutputFileName("D:/InforWflow/attachment/test/comp202/" + fName +".pdf");
break;
case '801':
options.setOutputFileName("D:/InforWflow/attachment/test/comp801/" + fName +".pdf");
break;
case '802':
options.setOutputFileName("D:/InforWflow/attachment/test/comp802/" + fName +".pdf");
break;
case '251':
options.setOutputFileName("D:/InforWflow/attachment/test/comp251/" + fName +".pdf");
break;
case '252':
options.setOutputFileName("D:/InforWflow/attachment/test/comp252/" + fName +".pdf");
break;
case '851':
options.setOutputFileName("D:/InforWflow/attachment/test/comp851/" + fName +".pdf");
break;
case '852':
options.setOutputFileName("D:/InforWflow/attachment/test/comp852/" + fName +".pdf");
break;
default:
options.setOutputFileName("D:/InforWflow/attachment/test/" + fName +".pdf");
break;
}

var ntask = re.createRenderTask(mdocument);
ntask.setRenderOption(options);

ntask.render();

ntask.close();
if (ntask != null) ntask = null;
mdocument.close();
if (mdocument != null) mdocument = null;
****************************************************************************

Please let me know, is there any mistake i am doing and i am badly struck over here.

Thanks in Advance
Madhan

Re: PDF Render: Export to PDF file exports only first page [message #876930 is a reply to message #876660] Fri, 25 May 2012 10:20 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Can you try the attached? It take a little bit after running for the
handle to be released.

Jason

On 5/24/2012 11:48 PM, Madhana Gopal wrote:
> Hi,
>
> I am trying to export the report as PDF while rendering the report using
> JAVASCRIPT. I have put the below code under afterFactory event (actually
> tried in all event beforeFactory, beforeRender & afterRender). It is
> generating the PDF file successfully, but it is generating only the
> first page. But while rendering the report it shows 2 pages.
>
> Below here is my Code:
>
> ****************************************************************************
>
> mmap =
> reportContext.getHttpServletRequest().getAttribute("attributeBean").getModuleOptions();
>
>
> myAttributeBean =
> reportContext.getHttpServletRequest().getAttribute('attributeBean');
> rptdoc = myAttributeBean.getReportDocumentName();
>
> importPackage(Packages.org.eclipse.birt.report.engine.api);
> importPackage(Packages.java.io);
> importPackage(Packages.java.util);
> importPackage(Packages.java.lang);
>
> var re = reportContext.getReportRunnable().getReportEngine();
> var mdocument = re.openReportDocument(rptdoc);
>
> var fName = reportContext.getPersistentGlobalVariable("ponumber");
> var cNum = reportContext.getPersistentGlobalVariable("compnumber")+"";
>
>
> var options = new PDFRenderOption();
> options.setOption(PDFRenderOption.PAGE_OVERFLOW,
> Integer.valueOf(PDFRenderOption.OUTPUT_TO_MULTIPLE_PAGES));
> options.setOutputFormat("pdf");
> options.setOption(PDFRenderOption.PAGE_OVERFLOW,
> IPDFRenderOption.FIT_TO_PAGE_SIZE);
> options.setOption( IRenderOption.HTML_PAGINATION, Boolean.FALSE );
>
> switch (cNum){
> case '201':
> options.setOutputFileName("D:/InforWflow/attachment/test/comp201/" +
> fName +".pdf");
> break;
> case '202':
> options.setOutputFileName("D:/InforWflow/attachment/test/comp202/" +
> fName +".pdf");
> break;
> case '801':
> options.setOutputFileName("D:/InforWflow/attachment/test/comp801/" +
> fName +".pdf");
> break;
> case '802':
> options.setOutputFileName("D:/InforWflow/attachment/test/comp802/" +
> fName +".pdf");
> break;
> case '251':
> options.setOutputFileName("D:/InforWflow/attachment/test/comp251/" +
> fName +".pdf");
> break;
> case '252':
> options.setOutputFileName("D:/InforWflow/attachment/test/comp252/" +
> fName +".pdf");
> break;
> case '851':
> options.setOutputFileName("D:/InforWflow/attachment/test/comp851/" +
> fName +".pdf");
> break;
> case '852':
> options.setOutputFileName("D:/InforWflow/attachment/test/comp852/" +
> fName +".pdf");
> break;
> default:
> options.setOutputFileName("D:/InforWflow/attachment/test/" + fName
> +".pdf");
> break;
> }
>
> var ntask = re.createRenderTask(mdocument); ntask.setRenderOption(options);
>
> ntask.render();
>
> ntask.close();
> if (ntask != null) ntask = null;
> mdocument.close();
> if (mdocument != null) mdocument = null;
> ****************************************************************************
>
>
> Please let me know, is there any mistake i am doing and i am badly
> struck over here.
>
> Thanks in Advance
> Madhan
>
>


Jason Weathersby

BIRT Exchange
Previous Topic:ReferenceError: "BarSeriesImpl" is not defined. at line X of chart script:''
Next Topic:BIRT with Multiple Data sets
Goto Forum:
  


Current Time: Wed Apr 23 20:43:34 EDT 2014

Powered by FUDForum. Page generated in 0.02318 seconds