Batch Print

  • Last update:  2021-04-26
  • I. Overview

    1. Version

    Designer Version
    10.0

    2. Expected effect

    For multiple templates, users want to print them out with one click.

    For dynamic parameter templates, users want to print reports with different parameter values in one click.

    For example, there is a performance report of sales personnel across the country. After passing in the parameters of different regions, these reports are printed out in batches. As shown below:

    1.gif



    3. Realization idea

    Use JavaScript to call FineReport's print interface FR.doURLPrint(config) to print reports in batches.

    II. Interface introduction

    For the content of the FR.doURLPrint(config) print interface, please refer to Chapter 2 of the document JS Calls FR Print Method.

    To realize batch printing, you need to set the data parameter in the interface. Data parameter form:

    data: {
    reportlets: "[{reportlet: 'reportname1.cpt',param1: 'value1',param2: 'value2'},
    {reportlet: 'reportname2.cpt',param3: 'value3',param4: 'value4}]"
    }

    Note: The content in "[]" corresponds to the content that needs to be printed, a "{}" corresponds to a template, and the content in "{}" is separated by ",", the order is the template name, the parameter name in the template, if There are multiple parameters separated by ",".

    Give examples of corresponding settings in different application scenarios:

    1) Print the same template, the parameters of the incoming template are different

    "[{reportlet: 'GettingStartedEN.cpt',Region: 'North China'}, 
    {reportlet: 'GettingStartedEN.cpt', Region: 'East China'}]"

    2) Print multiple templates, the name of the incoming template is different

    "[{reportlet: 'GettingStarted001.cpt',Region: 'North China'}, 
    {reportlet: 'GettingStarted002.cpt', Region: 'East China'}]"

    3) Print the same template and pass in two parameters

    "[{reportlet: 'GettingStarted.cpt',Region: 'North China',Salesperson: 'Sun Lin'}, 
    {reportlet: 'GettingStarted.cpt', Region: 'East China',Salesperson: 'Zhang Shan'}]"

    III. Example

    1. Template preparation

    1) Create a new dataset

    Create a new normal report, create a new dataset ds1: SELECT * FROM Sales_Volume

    2)  Set parameter checkbox button

    Drag the area field into cell A2, select A2, and click the "Cell Element"> "Advanced" to customize the displayed value, as shown in the following figure:

    Custom display value content:

    '<input id="config1" type="checkbox" value="'+$$$+'" checked />'+$$$

    Note: checked means that the parameter check boxes are all selected by default during initialization. If you don't need to be selected, remove this parameter.

    2.png

    In order to display A2 as a checkbox style, you also need to design its style to "Display by HTML".

    Select A2, click "Cell Element> Other", and set the Display Content to "Display by HTML", as shown in the following figure:

    3.png

    3) Set button widget

    Select A4, click "Widget Setting", and set it to "Button".

    The button type is "Common" and the button name is "Batch Print", as shown in the figure below:

    4.png


    2. Set up batch printing JS event

    Select cell A4, click "Widget Setting"> "Event", add "Click Event", and enter the JavaScript code, as shown in the figure below:

    5.png

    The JavaScript code is as follows:

    var printurl = "http://localhost:8075/webroot/decision/view/report";
    var p = [];
    //Get the parameter value selected on the current page and put the value into the array
    $(":checkbox").each(function() {
    if ($(this).attr("checked") == "checked")
    p.push("{reportlet:'GettingStartedEN.cpt', Region: "+ $(this).val() + "}");
    })
    if (p.length> 0) {
    //Convert the array of parameter values into a string
    var rp = p.join(",");
    var reportlets = "[" + rp + "]";
    var config = {
    printUrl: printurl,
    isPopUp: true,
    // Whether to pop up the setting window, true means pop up, false means no pop up
    data: {
    reportlets: reportlets // list of templates to be printed
    },
    printType: 0, // Print type, 0 means zero client printing, 1 means local printing
    // The following are the parameters for local printing, which only take effect when printType is 1
    printerName:'Microsoft Print to PDF', // printer name
    pageType: 2, // Print page number type: 0: all pages, 1: current page, 2: specified page
    pageIndex: '1-3', // Page number range. Valid when pageType is 2
    copy: 1, // print the number of copies
    };
    FR.doURLPrint(config);
    } else
    alert("Please select the parameters to be printed");

    3. Effect preview

    Save the template, click Data Entry Preview, you can print the selected button values in batches according to different parameters. The effect is shown in "Section I.2 Expected effect".

    Note: Mobile terminal is not supported.

    IV. Template download

    Please refer to the completed template:%FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\FeaturesApplication\BatchPrint.cpt

    Click to download: 

    BatchPrint.cpt


    Attachment List


    Theme: Report Application
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy