How To Print A Pdf From Asp. Net Page

Active5 years, 4 months ago
  1. How To Print A Pdf From Asp Net Page In Asp.net Mvc
  2. How To Print A Pdf Document

I have spent 5 days researching how to print a DataList in a C# Visual Studio WEB SITE. I can print the DataList in a Web Project. It appears that since a Site does not have 'namespace' as does a Project, Microsoft just didn't bother making a Web Site page printable. I have a rather large Web Site almost developed, and now it appears a major function of a Site is not possible. I need help! Thanks in advance.

P.S. It would seem that Microsoft would have mentioned this little problem in their literature comparing a Project to a Site, but they didn't.

John Saunders
149k23 gold badges210 silver badges372 bronze badges

Re: Print PDF document from asp.net web page Patrick Leckey Mar 25, 2008 10:40 AM ( in response to (Clay_Seifert) ) The info across the top and bottom is added by Internet Explorer, not the Reader plug-in.

user1830924user1830924

3 Answers

If you want to print only a Datalist from a webpage. You can create a Div Name around the datalist and use the below code

Double

Give a div name around the Datalist like this.

Finally Create a print button.

EDIT

Your exact code worked for me. I created a ASP.NET website (Not Project). I copied your entire code and pasted into a new page and it worked.

The only thing I changed is the following.

I changed CodeBehind='PageLinkDetails.aspx.cs' to CodeFile='PageLinkDetails.aspx.cs'

EDIT

Here is my Complete Code.

This is code for aspx.cs

Cherian M PaulCherian M Paul

What about your print media types style in the CSS?

CodersjuntoCodersjunto

This might be a very late answer, but for the new users who might come to this post like me, I want them to know that they can easily print the page using CTRL + P (PRINT COMMAND). To print just a few elements you can add the classname or id. Have a look as below:

Printing the page

To print the page, simply press the Print Command on any browser. Or simply use the JS command

You can keep this inside an event or anyother thing that you might want to be used such as a button:

Printing only a part

Now that we have CSS3 in our hand, we can easily snip out the part we want to be printed. Here is example:

Any of the property you declare here would be applied to the document while its in hard copy (printed form). If you want to hide the footer or other divs, you can set them to invisible as

Now, when you send the print command or click the button. You're gonna see only the printable part. It has been made easy using CSS3 Media Query.

Afzaal Ahmad ZeeshanAfzaal Ahmad Zeeshan
13k9 gold badges42 silver badges85 bronze badges

Not the answer you're looking for? Browse other questions tagged asp.net or ask your own question.

Active3 years, 10 months ago

My Requirement is to print invoices in pdf direct to local printer from web application developed in .net mvc framework.

I need to do exact like shipstation is doing with SHIPSTATION CONNECT

Does it use process like

or using WMI library to share printer remotely.

Any expert thought will help me and my programmer to build the solution.I am not expecting code or spoon feeding but like to know the process and way to start on this in right direction.

Thanks in advance for the help!

regards

sunnysunny

2 Answers

you can write javascript function that print from local printer,

working example:

if you want to print from the server you need to send a request for the server for example : www.mysite.com/print.aspx?file=invoice.pdf

to print it by the server you have 2 solutions the first is calling to other process to accomplish it like you can see in this answer:

the second is write your own implementation using PrintDocument namespace for example:

original taken from free 3rd party library

Community
ProxytypeProxytype

check printnode.com might be of some help.Seems like doing same thing what you want.The service is not free chargeable or alternatively you can build same using google cloud print.

How To Print A Pdf From Asp Net Page In Asp.net Mvc

Saurabh DSaurabh D

How To Print A Pdf Document

Not the answer you're looking for? Browse other questions tagged c#.netasp.net-mvc-4windows-services or ask your own question.