1. Printer Will Not Print Pdf
  2. Asp.net Print Pdf Directly To Printer
  3. Print Pdf Firefox
  4. Free Print Pdf Download
Active2 years, 7 months ago

I've generated a pdf using iTextSharp and I can preview it very well in ASP.Net but I need to send it directly to printer without a preview. I want the user to click the print button and automatically the document prints.

I know that a page can be sent directly to printer using the javascript window.print() but I don't know how to make it for a PDF.

Edit: it is not embedded, I generate it like this;

Print to PDF from ASP.NET. This content is based on version 10.8 and later of the virtual printer. At the time of writing, it has not been released. PDF Printing Library for.NET Print, display or convert your PDF documents with ease, using our PDFPrinting.NET library. As a standalone.NET assembly, just reference it in your product and start coding right away.

And here I am.

Nelson Miranda
Nelson MirandaPdfNelson Miranda
4,5105 gold badges28 silver badges47 bronze badges

5 Answers

Printer Will Not Print Pdf

Finally I made it, but I had to use an IFRAME, I defined an IFrame in the aspx and didn't set the src property, in the cs file I made generated the pdf file and set the src property of the iFrame as the generated pdf file name, like this;

And that made the trick, however, I think that i should implement your solution Stefan, the problem is that I'm new to asp.net and javascript and if I don't have a complete source code I could not code your suggestion but at least is the first step, I was very surprised how much code in html and javascript i need to learn. Thnx.

PrintNelson MirandaNelson MirandaAsp.net Print Pdf To Printer
4,5105 gold badges28 silver badges47 bronze badges

Is the pdf embedded in the page with embedd-tag or just opened in a frame or how are you showing it?

If its embedded, just make sure that the object is selected and then do a print().

Get the ref to the embedded document.

StefanStefan
9,9647 gold badges46 silver badges74 bronze badges

It's a little more tricky if you're using pdfsharp but quite doable

frenchonefrenchone
6552 gold badges8 silver badges21 bronze badges

ALso, try this gem:

I havent tested it, but what I have read about it, it can be used in this way to let the mypdf.pdf be printed instead of page content whatever method you are using to print the page.

Search for media='print' to check out more.

Asp.net Print Pdf Directly To Printer

StefanStefan
9,9647 gold badges46 silver badges74 bronze badges

You can embed javascript in the pdf, so that the user gets a print dialog as soon as their browser loads the pdf.

I'm not sure about iTextSharp, but the javascript that I use is

For iTextSharp, check out http://itextsharp.sourceforge.net/examples/Chap1106.cs

Tim

protected by WillAug 25 '10 at 13:32

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Free Print Pdf Download

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