Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want print data without using crystal report .i.e noramlly as we use MSoffice in Doc print command how it works like that is it possible ?
Posted
Comments
Mohd Wasif 14-Jun-11 1:58am    
It is a web application or desktop.
If it is a web application then use java script.

Assuming that you want something related to asp.net(from tags), if you want to print data in gridview then you can do like this:

Add the following java script in the head section of the page:
XML
<script>
        function doPrint()
        {
            var prtContent = document.getElementById('<%= GridView1.ClientID %>');
            prtContent.border = 0; //set no border here
            var WinPrint = window.open('','','left=100,top=100,width=1000,height=1000,toolbar=0,scrollbars=1,status=0,resizable=1');
            WinPrint.document.write(prtContent.outerHTML);
            WinPrint.document.close();
            WinPrint.focus();
            WinPrint.print();
            WinPrint.close();
        }
</script>


Add the asp.net button control like the following:

<asp:button id="btnPrint" runat="server" text="Print" onclientclick="doPrint()" xmlns:asp="#unknown">

for more info refer this:

http://www.aspsnippets.com/Articles/Print-functionality-in-ASP.Net-GridView-control.aspx[^]

help this helps :)
 
Share this answer
 
//below code I am using in silverlight 4. It will work in ASP.net also.
//use this namespace
//using System.Drawing.Printing;


PrintDocument doc = new PrintDocument();
_elementToPrint = elementToPrint;
doc.PrintPage += (s, args) =>
{
// Set element to be printed
_elementOriginalWidth = _elementToPrint.Width;
_elementOriginalHeight = _elementToPrint.Height;
if (stretchToFullSize)
{
_elementToPrint.Width = args.PrintableArea.Width;
_elementToPrint.Height = args.PrintableArea.Height;
// Printing only starts when args.PageVisual != null
// Only set args.PageVisual to elementToPrint once its size has been updated
_elementToPrint.SizeChanged += (s1, args1) =>
{
args.PageVisual = elementToPrint;
};
}
else
{
args.PageVisual = elementToPrint;
}
};
doc.BeginPrint += (s, args) =>
{
// Show that printing has begun: not implemented in this case
};
doc.EndPrint += (s, args) =>
{
// Show that printing has ended: not implemented in this case
// Reset printed element size to original
_elementToPrint.Width = _elementOriginalWidth;
_elementToPrint.Height = _elementOriginalHeight;

MessageBox.Show("Sucess");
};
doc.Print(documentName);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900