Fórumok

Printing the Report

Hiten Shah, módosítva 9 év-val korábban

Printing the Report

New Member Bejegyzések: 16 Csatlakozás dátuma: 2014.05.21. Legújabb bejegyzések
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, módosítva 9 év-val korábban

RE: Printing the Report

Expert Bejegyzések: 493 Csatlakozás dátuma: 2012.05.26. Legújabb bejegyzések
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, módosítva 9 év-val korábban

RE: Printing the Report

New Member Bejegyzések: 16 Csatlakozás dátuma: 2014.05.21. Legújabb bejegyzések
Hello,
I tried whatever you said but it didn't work.

Thank you.
thumbnail
Jignesh Vachhani, módosítva 9 év-val korábban

RE: Printing the Report

Liferay Master Bejegyzések: 803 Csatlakozás dátuma: 2008.03.10. Legújabb bejegyzések
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, módosítva 9 év-val korábban

RE: Printing the Report

New Member Bejegyzések: 16 Csatlakozás dátuma: 2014.05.21. Legújabb bejegyzések
Hello,
Thank you Jignesh. Your code is working .

Thank you.