Change filename of generated PDF

Hello,


 


It is possible to change filename of generated PDF?


 


For example i have report which show 'product_line' from 'classic models db' filtered by input parameter and i want to get PDF with filename 'Motorcycles.PDF'.


 


Right now i'm generating PDF by adding '&__format=pdf' to URL via javascript. 

 

 

P.S. 

I don't want to change anything in BIRT itself, because this must be enviroment independent.

Comments

  • No replies? Anyone?


     


     


    I searched again forum and found some example report, but i got error.

     

    There are two script:

     

    -beforeFactory:

     

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

     

     

     

    -beforeRender:

     

    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();

     

    fout = new FileOutputStream("c:/test/myreport.pdf");   

    fout.write(baos.toByteArray());

    fout.flush()

    fout.close();   

     

     

    I'm getting error:

     

    There are errors evaluating script "mmap = reportContext.getHttpServletRequest().getAttribute("attributeBean").getModuleOptions()":

    TypeError: Cannot call method "getModuleOptions" of null (/report/method[@name="beforeFactory"]#1)

     

     

    This example report worked on BIRT2.3.2. Something changed in 4.4.0?

     

     

    Could anyone help me with this topic?

  • I would recommend to check zetpdf.com/
    library

Sign In or Register to comment.