Forums de discussion

Printing the Report

Hiten Shah, modifié il y a 9 années.

Printing the Report

New Member Publications: 16 Date d'inscription: 21/05/14 Publications récentes
Hello,

I created a portlet which contains the report. It display the graphical report means contains pie chart and bar chart .
i want to print that report.
so how can i print it???

Thank you.
thumbnail
Manish Yadav, modifié il y a 9 années.

RE: Printing the Report

Expert Publications: 493 Date d'inscription: 26/05/12 Publications récentes
Hiten Shah:
Hello,

I created a portlet which contains the report. It display the graphical report means contains pie chart and bar chart .
i want to print that report.
so how can i print it???

Thank you.


Dear Hiten,

You can use jquery to print div. I'll recommend to create div id for graphs and then print that id using jquery or javascript.

Hope below link will help

1. http://www.aspdotnet-suresh.com/2013/08/jquery-print-div-content-with-css-using.html
2. http://stackoverflow.com/questions/2255291/print-the-contents-of-a-div

Kind Regards,
Manish Yadav
Hiten Shah, modifié il y a 9 années.

RE: Printing the Report

New Member Publications: 16 Date d'inscription: 21/05/14 Publications récentes
Hello,
I tried whatever you said but it didn't work.

Thank you.
thumbnail
Jignesh Vachhani, modifié il y a 9 années.

RE: Printing the Report

Liferay Master Publications: 803 Date d'inscription: 10/03/08 Publications récentes
Hi Hiten,

Can you please give a try using below code :



    <title>Untitled Page</title>

    <script language="javascript" type="text/javascript">
        function printDiv(divID) {
            //Get the HTML of div
            var divElements = document.getElementById(divID).innerHTML;
            //Get the HTML of whole page
            var oldPage = document.body.innerHTML;

            //Reset the page's HTML with div's HTML only
            document.body.innerHTML = 
              "<html><head><title></title></head><body>" + 
              divElements + "</body>";

            //Print Page
            window.print();

            //Restore orignal HTML
            document.body.innerHTML = oldPage;

          
        }
    </script>



    <form id="form1" runat="server">
    <div id="printablediv" style="width: 100%; background-color: Blue; height: 200px">
        Print me I am in 1st Div
    </div>
    <div id="donotprintdiv" style="width: 100%; background-color: Gray; height: 200px">
        I am not going to print
    </div>
    <input type="button" value="Print 1st Div" onclick="javascript:printDiv('printablediv')">
    </form>


Hiten Shah, modifié il y a 9 années.

RE: Printing the Report

New Member Publications: 16 Date d'inscription: 21/05/14 Publications récentes
Hello,
Thank you Jignesh. Your code is working .

Thank you.