我的报告打印问题 [英] Printing issue with my report

查看:71
本文介绍了我的报告打印问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的打印页面存在问题。当用户单击打印按钮时,我会弹出一个打印预览,并显示页面在打印前的外观。徽标占据了页面的一半,文本框没有正确对齐,URL,数据,时间和页码都在打印输出上。这是一种解决所有这些问题的方法吗?



这是要打印的页面的代码:



I have an issue with my print page. When the user clicks the print button I have a print preview that pops up and shows how the page looks before it is printed. The logo takes up half of the page, the textboxes are not aligning right and the URL, Data, Time and Page numbers are on the print out. Is the a way to fix all of this?

This is the code for the Page to be printed:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WordFormA.aspx.cs" Inherits="SACSCOCLogin1._1.WebForm1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"   runat="server">
    <title></title>
    <style>
@media print {
.header, .hide { visibility: hidden }
}
   </style>
<style type="text/css">
        .style1
        {
            font-size: x-large;
            text-align: center;
        }
        .style2
        {
            width: 100%;
        }
        .style11
        {
            height: 23px;
        text-align: left;
    }
        .newStyle1
        {
        }
        .style49
        {
            font-size: x-large;
        }
        .style51
        {
            font-weight: bold;
            font-size: x-large;
            text-align: center;
        }
        .style52
        {
            width: 670px;
        }
        .style56
        {
            font-weight: bold;
            font-size: large;
            text-align: center;
        }
        .style59
    {
        font-size: medium;
        text-align: left;
    }
    .style62
    {
        text-align: left;
    }
    .newStyle59
    {
    }
    .style69
    {
        font-size: medium;
    }
    .newStyle60
    {
    }
    .newStyle61
    {
    }
    .style80
    {
        font-size: medium;
        text-align: left;
        width: 548px;
    }
    .style83
    {
        text-align: left;
        width: 447px;
    }
    .style84
    {
        font-size: medium;
        text-align: left;
        width: 277px;
    }
    p.MsoNormal
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:10.0pt;
	margin-left:0in;
	line-height:115%;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	}
    .style85
    {
        width: 265px;
        height: 17px;
    }
    </style>
    <script language="javascript" type="text/javascript">
// <![CDATA[

        function Reset1_onclick() {

        }

        // 
    </script>
</head>
<body background="Images/bkg-blu.jpg" bgcolor="#3399ff">
    <form id="form1"   runat="server">
    <div class="style1">
    <asp:Panel ID="Panel1" runat="server">
        <div style="text-align: left">
            <table 

                class="style2">
            </table>                                                                                                        
        <span class="style49">Financial Profile 
            2013                              
            <img alt="" class="style85" src="Images/e9210433_logo.jpg" />
            
        </span></div>
                
     <asp:TextBox ID="TextBoxINST_ID" runat="server" Enabled="False" ReadOnly="True" 

        Visible="False"></asp:TextBox>
                
    <asp:TextBox ID="TextBoxaccessLevel" runat="server" style="text-align: center" 

        Visible="False"></asp:TextBox>
                
    <br />
    <table class="style2">
        <tr>
            <td style="text-align: center">
                <asp:Label ID="lblSchool" runat="server" CssClass="style51"></asp:Label>
            </td>
        </tr>
    </table>
    <table class="style2">
        <tr>
            <td class="style52" style="text-align: right">
                <asp:Label ID="lblCity" runat="server" CssClass="style56"></asp:Label>
                ,</td>
            <td style="text-align: left">
 <asp:Label ID="lblState" runat="server" CssClass="style56"></asp:Label>
            </td>
        </tr>
        </table>
    <br />
    <table class="style2">
 
        <tr>
            <td class="style83">
                <span style="text-align: justify"><span class="style59">Total Revenues and Other 
                Additions </span></span></td>
            <td style="text-align: left">
                <asp:TextBox ID="TextBoxTROA" runat="server" style="text-align: left" 

                    Width="180px" ToolTip="IPEDS Part B, line 25">0</asp:TextBox>
                </td>
        </tr>
    </table>
    <br />
    <table class="style2">
        <tr>
            <td class="style83">
                <span class="style59">Instruction </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxInstr" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Research </span></td>
            <td class="style11">
                <asp:TextBox ID="TextBoxRes" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 02, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Public Service </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxPubS" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 03, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Academic Support </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxAcad" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 05, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Student Services </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxStudS" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 06, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Institutional Support </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxInstiS" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 07, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Operation & Maintenance of Plant </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxOperM" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 08, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Scholarships & Fellowships, Excluding Discounts & 
                Allowances </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxSFEDA" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 10, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Auxiliary Enterprises </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxAuxE" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 11, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Hospital Services </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxHosS" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 12, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Independent Operations </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxIndeO" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 13, Column 01">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style83">
                <span class="style59">Other Expenses & Deductions </span></td>
            <td class="style62">
                <asp:TextBox ID="TextBoxOED" runat="server" Width="180px" 

                    ToolTip="IPEDS Part C, Line 14, Column 01">0</asp:TextBox>
            </td>
        </tr>
        </table>
    <table class="style2">
        <tr>
            <td class="style84">
                <span class="style69">Financial Indicators</span></td>
            <td class="style80">
                 </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Total Assets</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTA" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Total Liabilities</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTL" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Nonexpendable/Permanently Restricted Net Assets</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxNPRNA" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Expendable/Temporarily Restricted Net Assets</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTUNA" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Total Unrestricted Net Assets</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTR" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Total Revenue</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTFN" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Tuition and Fees, Net</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxCD" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Current Debt</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxLTD" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Long-term Debt</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBox9" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
    </table>
        <table class="style2">
            <tr>
                <td>
                    <p class="MsoNormal" style="margin-top:1.15pt;margin-right:-1.0pt;margin-bottom:
0in;margin-left:11.0pt;margin-bottom:.0001pt;line-height:normal;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none">
                        
                        <span style="font-size:
14.0pt;font-family:"Arial","sans-serif";letter-spacing:-.05pt">S</span><span 

                            style="font-size:14.0pt;font-family:"Arial","sans-serif";letter-spacing:.1pt">i</span><span 

                            style="font-size:14.0pt;font-family:"Arial","sans-serif"">gn<span 

                            style="letter-spacing:.05pt">at</span>ur<span style="letter-spacing:.05pt">e</span>s<span 

                            style="letter-spacing:-.6pt"> </span>of<span style="letter-spacing:-.05pt"> 
                        V</span><span style="letter-spacing:.05pt">e</span>r<span 

                            style="letter-spacing:.1pt">i</span><span style="letter-spacing:.05pt">f</span><span 

                            style="letter-spacing:-.05pt">i</span><span style="letter-spacing:.05pt">cat</span><span 

                            style="letter-spacing:-.05pt">i</span>on</span><span 

                            style="font-size:14.0pt;font-family:"Arial","sans-serif""><p></p>
                        </span>
                    </p>
                </td>
            </tr>
            <tr>
                <td>
                    <p class="MsoNormal" style="text-align: left">
                        
                        <span style="font-size: 12.0pt; font-family: "Arial","sans-serif"; letter-spacing: .05pt; text-align: left;">
                        W</span><span 

                            style="font-size:12.0pt;font-family:"Arial","sans-serif"">e<span 

                            style="letter-spacing:-.05pt"> </span><span style="letter-spacing:.05pt">ce</span>r<span 

                            style="letter-spacing:-.05pt">t</span>i<span style="letter-spacing:.1pt">f</span>y<span 

                            style="letter-spacing:-.3pt"> </span><span style="letter-spacing:-.05pt">t</span>h<span 

                            style="letter-spacing:.05pt">a</span>t <span style="letter-spacing:-.05pt">t</span>he<span 

                            style="letter-spacing:.05pt"> </span>in<span style="letter-spacing:.1pt">f</span>orm<span 

                            style="letter-spacing:.05pt">a</span><span style="letter-spacing:-.05pt">t</span>ion 
                        pro<span style="letter-spacing:-.2pt">v</span>id<span style="letter-spacing:
.05pt">e</span>d in <span style="letter-spacing:-.05pt">t</span>he<span style="letter-spacing:.05pt"> 20</span><span 

                            style="letter-spacing:-.05pt">1</span>3<span style="letter-spacing:.05pt">
                        </span>Fin<span style="letter-spacing:.05pt">a</span><span 

                            style="letter-spacing:-.15pt">n</span><span style="letter-spacing:.05pt">c</span>i<span 

                            style="letter-spacing:.05pt">a</span>l<span style="letter-spacing:-.05pt">
                        </span><span style="letter-spacing:.05pt">P</span><span 

                            style="letter-spacing:-.1pt">r</span>o<span style="letter-spacing:-.05pt">f</span>ile<span 

                            style="letter-spacing:.05pt"> a</span>nd</span>
                        <span style="font-size:12.0pt;font-family:"Arial","sans-serif";removed:relative;

removed.5pt;mso-text-raise:-.5pt">Indi<span style="letter-spacing:.05pt">ca</span><span 

                            style="letter-spacing:-.05pt">t</span>ors<span 

                            style="letter-spacing:-.05pt"> </span><span style="letter-spacing:.05pt">a</span>re<span 

                            style="letter-spacing:-.05pt"> </span><span style="letter-spacing:.05pt">c</span>orr<span 

                            style="letter-spacing:-.05pt">e</span><span style="letter-spacing:.05pt">c</span><span 

                            style="letter-spacing:-.05pt">t</span>.</span><span 

                            style="font-size:12.0pt;font-family:"Arial","sans-serif""><p></p>
                        </span>
                    </p>
                </td>
            </tr>
        </table>
        <table class="style2">
            <tr>
                <td style="text-align: left">
                    _________________________</td>
                <td style="text-align: left">
                    _________________________</td>
                <td style="text-align: left">
                    _________________________</td>
            </tr>
            <tr>
                <td style="text-align: left">
                    Chief Executive Officer</td>
                <td style="text-align: left">
                    Chief Financial Officer</td>
                <td style="text-align: left">
                    Respondent(if other than CEO or CFO)</td>
            </tr>
        </table>
    <br />
    </asp:Panel>
    <br />
    <table class="style2">
        <tr>
            <td style="text-align: center">
                <asp:Button ID="ButtonPrint" runat="server" onclick="ButtonPrint_Click" 

                    style="text-align: center" Text="Print" Width="121px" />
            </td>
        </tr>
    </table>
    <br />
    <br />
    </form>
    </body>
</html>





This is the Code Behind that Page:





This is the Code Behind that Page:

using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Drawing.Printing;
using System.IO;
using System.Web.SessionState;

namespace SACSCOCLogin1._1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
            con.Open();
            SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
            con2.Open();
            SqlConnection con3 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
            con3.Open();

            TextBoxINST_ID.Text = Session["inst_id"].ToString();
            SqlCommand scmd = new SqlCommand("Select INST_ID, LongName, City, State from Table22 where INST_ID = '" + TextBoxINST_ID.Text + "'", con);
            SqlCommand scmd2 = new SqlCommand("Select INST_ID, TOTAL_REVE, INSTRUCTIO, RESEARCH, PUBLIC_SER, ACADEMIC_S, STUDENT_SE, INSTITUTIO, PHYSICAL_P, SCHOLARSHI, AUXILIARY_, HOSPITALS, INDEPENDEN, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT from Table99 where INST_ID = '" + TextBoxINST_ID.Text + "'", con2);
            SqlCommand scmd3 = new SqlCommand("Select INST_ID, accessLevel from Table33 where INST_ID = '" + TextBoxINST_ID.Text + "'", con3);
            SqlDataReader dr = scmd.ExecuteReader();
            SqlDataReader dr2 = scmd2.ExecuteReader();
            SqlDataReader dr3 = scmd3.ExecuteReader();

            if (dr.Read())
                if (dr2.Read())
                    if (dr3.Read())
                    {
                        TextBoxaccessLevel.Text = dr3["accessLevel"].ToString();
                        lblCity.Text = dr["City"].ToString();
                        lblState.Text = dr["State"].ToString();
                        lblSchool.Text = dr["LongName"].ToString();
                        TextBoxInstr.Text = dr2["INSTRUCTIO"].ToString();
                        TextBoxRes.Text = dr2["RESEARCH"].ToString();
                        TextBoxPubS.Text = dr2["PUBLIC_SER"].ToString();
                        TextBoxAcad.Text = dr2["ACADEMIC_S"].ToString();
                        TextBoxStudS.Text = dr2["STUDENT_SE"].ToString();
                        TextBoxInstiS.Text = dr2["INSTITUTIO"].ToString();
                        TextBoxOperM.Text = dr2["PHYSICAL_P"].ToString();
                        TextBoxSFEDA.Text = dr2["SCHOLARSHI"].ToString();
                        TextBoxAuxE.Text = dr2["AUXILIARY_"].ToString();
                        TextBoxHosS.Text = dr2["HOSPITALS"].ToString();
                        TextBoxIndeO.Text = dr2["INDEPENDEN"].ToString();
                        TextBoxOED.Text = dr2["OTHEREXP"].ToString();
                        TextBoxTA.Text = dr2["TOTASSETS"].ToString();
                        TextBoxTL.Text = dr2["TOTLIABILITY"].ToString();
                        TextBoxNPRNA.Text = dr2["NoNEXPPERMRESASSETS"].ToString();
                        TextBoxTUNA.Text = dr2["UNRNETASSETS"].ToString();
                        TextBoxTR.Text = dr2["TOTALREV"].ToString();
                        TextBoxTFN.Text = dr2["TUITFEES"].ToString();
                        TextBoxCD.Text = dr2["CURRDEBT"].ToString();
                        TextBoxLTD.Text = dr2["LONGTERMDEBT"].ToString();
                        TextBoxTROA.Text = dr2["TOTAL_REVE"].ToString();


                    }
            dr.Close();
            con.Close();
            dr2.Close();
            con2.Close();
            dr3.Close();
            con3.Close();
        }

        protected void ButtonPrint_Click(object sender, EventArgs e)
        {
            Session["ctrl"] = Panel1;
            ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('Print.aspx','PrintMe','height=300px,width=300px,scrollbars=1');</script>");
        }
    }
}





This the code for the Print Preview Page:





This the code for the Print Preview Page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Print.aspx.cs" Inherits="SACSCOCLogin1._1.Print" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title></title>
</head>
<body>
    <form id="form1"  runat="server">
    <div>
    
        
    </div>
    </form>
</body>
</html>





Here is the code behind that page:





Here is the code behind that page:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SACSCOCLogin1._1
{
    public partial class Print : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Control ctrl = (Control)Session["ctrl"];
            PrintHelper.PrintWebControl(ctrl);
        }
    }
}





When the Print Button is clicked it also refers to this page for the action.



Here is the code behind for this page:





When the Print Button is clicked it also refers to this page for the action.

Here is the code behind for this page:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SACSCOCLogin1._1
{
    public partial class Print : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Control ctrl = (Control)Session["ctrl"];
            PrintHelper.PrintWebControl(ctrl);
        }
    }
}





Sorry for all the code but trying to make sure I don’t miss anything. Thanks.



Sorry for all the code but trying to make sure I don't miss anything. Thanks.

推荐答案

Unfortunately, not. You can’t remove those. :)



We hope to have this feature in future updates of browser.
Unfortunately, not. You can't remove those. :)

We hope to have this feature in future updates of browser.


Go through the reference posted below



http://stackoverflow.com/questions/13136863/remove-url-and-print-text-from-the-printed-page[^]



http://stackoverflow.com/questions/355313/how-do-i-hide-an-element-when-printing-a-web-page[^]



http:/ /coding.smashingmagazine.com/2013/03/08/tips-tricks-print-style-sheets/[^]



Hope this helps
Go through the reference posted below

http://stackoverflow.com/questions/13136863/remove-url-and-print-text-from-the-printed-page[^]

http://stackoverflow.com/questions/355313/how-do-i-hide-an-element-when-printing-a-web-page[^]

http://coding.smashingmagazine.com/2013/03/08/tips-tricks-print-style-sheets/[^]

Hope this helps


I just deleted the project. I will start another project.
I just deleted the project. I will start another project.


这篇关于我的报告打印问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆