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] Fri, 25 May 2012 03:48 Go to next message
Madhana Gopal is currently offline Madhana GopalFriend
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 14:20 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
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
>
>
Re: PDF Render: Export to PDF file exports only first page [message #1691325 is a reply to message #876660] Mon, 06 April 2015 03:12 Go to previous message
Eric Leong is currently offline Eric LeongFriend
Messages: 1
Registered: April 2015
Junior Member
Now, the multiple pages issues had been resolved. But we found that there are some PDF were locked for more than an hour by tomcat6.exe. We need to manually unlock the file before it can be picked up and copied to another folder. Any suggestion to unlock the PDF faster?
Previous Topic:fix for CVE-2015-0250
Next Topic:Unable to view Report
Goto Forum:
  


Current Time: Fri Jul 31 03:07:45 GMT 2015

Powered by FUDForum. Page generated in 0.02068 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software