Question

I have a invoice for which I want to show in preview mode with a watermark. I have integrated the report with my web application (Spring MVC).

Any solution?

EDIT: I want to pick a value from a dataset (Table: invoiceheader), and use that value to decide whether to show /not show the watermark. I am unable to pick that value from Birt script. Can you please please guide..

Sorry .. the customer asked for a different way of identifying the fact rather that from passing the parameter.

Thanks

Was it helpful?

Solution

You need to declare a report parameter in the .rptdesign of the invoice. For example we name it "useWatermark", and we set the datatype to boolean and a default value to true.

enter image description here

Select the report root in the outline view of the designer -> script tab -> beforeFactory

if (!params["useWatermark"].value){
    reportContext.getDesignHandle().findMasterPage("Simple MasterPage").setProperty("backgroundImage", "");
}

This script removes the watermark if the parameter is set to false. By default, the master page is named "Simple Masterpage" but if you have renamed it or if there are multiple masterPages defined in the report you should adjust the script consequently.

EDIT: if we need to extract the information from a dataset, then we can't make use of the masterPage, we have to use a grid instead.

  • Create a grid with one cell, and drop all the content of your page into it
  • Set your watermark as background-image of the grid
  • Create a report variable "useWatermark" in the "Outline/variables" branch (see picture below), set default value to true/false as you like
  • Select dataset invoiceHeader -> script tab -> onFetch, and affect the variable from a boolean dataset column, or from any expression returning true/false:

    vars["useWatermark"]=row["myBooleanDatasetColumn"];

This dataset must be used somewhere in the report body, otherwise it won't be triggered and the variable won't be initialized

  • Select the grid -> script tab -> onRender

    if (!vars["useWatermark"]){ this.getStyle().backgroundImage=""; }

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top