Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

How can i print a document(pdf, doc, jpg, etc...) in C# on client side ?
Posted

First, you need access to the printer.
If you have acess, you can go ahead and print.

For printing examples, have a look at
http://www.dotnetcurry.com/ShowArticle.aspx?ID=92[^]
http://www.beansoftware.com/ASP.NET-Tutorials/Printing-Reporting.aspx[^]
Creating print preview page dynamically in ASP.NET[^]
 
Share this answer
 
Comments
Monjurul Habib 12-Dec-11 0:43am    
5+, nice links for print page. but the question also includes how to print document like pdf, doc, jpg, etc...
Abhinav S 12-Dec-11 0:47am    
Thanks for the 5. The first link should help him out.
Monjurul Habib 12-Dec-11 0:49am    
yes indeed :)
There are many ways to do that, but for free i have used a very good library named iTextSharp. Please read the following article to implement according to your requirement.
Create PDF document using iTextSharp in ASP.Net 4.0 and MemoryMappedFile
Creating PDF Documents with ASP.NET and iTextSharp
Creating PDF Documents in ASP.NET

Working with images
iTextSharp - Working with images

AS iTextSharp does not have the required feature set to load and process MS Word file formats.

You can use Aspose.Words for .NET

Aspose.Words for .NET

Let me know if you need further help.

Enjoy :)
 
Share this answer
 
v3
Comments
Abhinav S 12-Dec-11 0:47am    
Your answer is more appropriate. My 5.
Monjurul Habib 12-Dec-11 0:48am    
thank you
thatraja 12-Dec-11 2:54am    
5!
Monjurul Habib 12-Dec-11 2:55am    
thank you RAJA
HTML
This may help you


One method to print
C#
<input  type="button" onclick="javascript:window.print();" value="Print" />


another method to print
XML
<div id="div1">
  <input id="Button1"  onclick="javascript:CallPrint('div1')" class="button" type="button" value="Print" />
       </div>


C#
 <script type="text/javascript" language="javascript">
        function CallPrint(strid)
        {
            var prtContent = document.getElementById(strid);
            var docwrite=prtContent.innerHTML;
            var WinPrint = window.open('','','left=0,top=0,toolbar=0,status=0');
            WinPrint.document.open();
            WinPrint.document.write(docwrite);
            WinPrint.document.close();
            WinPrint.focus();
            WinPrint.print();
            WinPrint.close();
//          prtContent.innerHTML=strOldOne;
        }
        </script>
 
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