掲示板

Printing the Report

9年前 に Hiten Shah によって更新されました。

Printing the Report

New Member 投稿: 16 参加年月日: 14/05/21 最新の投稿
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
9年前 に Manish Yadav によって更新されました。

RE: Printing the Report

Expert 投稿: 493 参加年月日: 12/05/26 最新の投稿
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
9年前 に Hiten Shah によって更新されました。

RE: Printing the Report

New Member 投稿: 16 参加年月日: 14/05/21 最新の投稿
Hello,
I tried whatever you said but it didn't work.

Thank you.
thumbnail
9年前 に Jignesh Vachhani によって更新されました。

RE: Printing the Report

Liferay Master 投稿: 803 参加年月日: 08/03/10 最新の投稿
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>


9年前 に Hiten Shah によって更新されました。

RE: Printing the Report

New Member 投稿: 16 参加年月日: 14/05/21 最新の投稿
Hello,
Thank you Jignesh. Your code is working .

Thank you.