Print files from list view of Module and Subpanel

How to add print file button in Action menu of  record.?

When the user selects records in the list view (module) or is viewing the records in the subpanel, clicking on the Print Files button will cause the files in those records to mass print.  (Makes it more of a one step process to print instead of having to open each file, open the download, print the download one at a time.)

Parents Reply Children
  • Thanks For your quick response.

  • Hi I am using jsgrouping to print the files . I have implemented it but  somehow i am not able to print the pdf file from record. 

    As you can see , i want to print the content of file 'C20-02633 79.pdf'. How can i print the content of the pdf file. Please suggest me any way.

  • Can you share the code which triggers the print functionality? My initial guess is that you're printing current window instead of the file itself. 

  • Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    generateAndPrint: function (model) { console.log("In Generate Print label");
    if (_.isEmpty(model) === false) {
    var apiUrl = app.api.buildURL("printEmailFile", "create", requestParams, {});
    var edocIds = [];
    edocIds.push({
    edocIds: this.model.get("id"),
    });
    var requestParams = {
    edocIds: edocIds,
    };
    console.log("edocIds Id : "+this.model.get("id"));
    console.log("API URL : "+apiUrl);
    app.api.call("create", apiUrl, requestParams, null, { success: this.printLabels.bind(this) });
    }
    },
    printLabels: function (data) { console.log("==="+JSON.stringify(data));
    if (_.isEmpty(data) === false) {
    window.print();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I am using the window.print(); , but i don't know how to get the pdf content and print it. 

  • Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <?php
    if (!defined('sugarEntry') || !sugarEntry) {
    die('Not A Valid Entry Point');
    }
    class printEmailFileApi extends ModuleApi
    {
    public function registerApiRest()
    {
    return array(
    'printEmailFiles' => array(
    'reqType' => 'POST',
    'path' => array('printEmailFile'),
    'pathVars' => array(''),
    'method' => 'printEmailFileData',
    'shortHelp' => '',
    'longHelp' => '',
    ),
    );
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I am trying with 

    $file->temp_file_location = UploadFile::get_upload_path($file_id);
    $file_contents = $file->get_file_contents();
    but it's not working
  • I just took a quick look at your code, and looks like you're using window.print - that will not work, since it will only print your current page.

    But - try with print.js - it's a simpler option:

    Download the print.js from https://github.com/crabbly/Print.js/releases/tag/v1.3.1 and include it in your jsGroupings.

    Download the CSS file and add it in your custom.less with 

    @import (inline) 'print.min.css';

    Then - in your JS code, when you click in the print button, all you have to do is:

    generateAndPrint: function () {
    printJS('index.php?entryPoint=download&id=a09ba29c-f98a-11ea-9864-ac2b6e3c0d93&type=Notes')
    },

    I am just using download entrypoint for example - since it's easy and you don't have to pass authToken.

  • Thank you so much. I will try by this way.

  • I have downloaded the files from mentioned link but there are bunch of files in zip . Should we need to upload all these files to Sugar? And how these would be called in sugar ? Can you please explain.

  • Please follow the documentation from printjs site here :.  https://printjs.crabbly.com

  • Hi  I am not able to understand from the documentation, As there is no documentation for sugar crm. Would you please explain me more ?