1

I have a web app that creates a pdf using Websupergoo's ABCPDF. Right now after the user clicks the CreatePDF button the browser just downloads the created PDF. Instead I would like the print dialog to open so that the user can choose a printer and then print the PDF.

How can this be accomplished?

Please let me know if you need to see any of my code in the comment area and I will oblige.

Brian Rasmussen
  • 114,645
  • 34
  • 221
  • 317
broguyman
  • 1,386
  • 4
  • 19
  • 36
  • possible duplicate of [Print Pdf in C#](http://stackoverflow.com/questions/5566186/print-pdf-in-c-sharp) – Igby Largeman Apr 18 '12 at 19:39
  • 2
    @IgbyLargeman He wants to force to print a pdf automatically when a user clicks a button in a browser. Like the print() function in javascript.... – madflow Apr 18 '12 at 19:43
  • Duplicate ? http://stackoverflow.com/questions/687675/can-a-pdf-files-print-dialog-be-opened-with-javascript – madflow Apr 18 '12 at 19:45

2 Answers2

2

You can either return an html page and using javascript print function show a print dialog or ask the user to download a pdf.

In your case, a good option would be 2 buttons: "Download pdf" and "Print". When the user clicks on Print, (s)he can choose the printer that could be a PDF Printer.

See related: Can a PDF file's print dialog be opened with Javascript?

Community
  • 1
  • 1
jorgebg
  • 6,560
  • 1
  • 22
  • 31
1

I think what you're essentially asking to do is to ask the application that opens the PDF to print, which unless there are proprietary hooks that certain applications use, is not possible (and outside of Adobe, probably won't be very cross-platform friendly).

Javascript's print function is a "standardized" method to tell browsers to print, and so generally that is safe to perform, but both PDF applications and the plugins they provide to browsers so they may display a PDF "in-browser" don't seem to have hooks to do so.

Once the PDF has been opened, that control scheme is outside of your domain of control. As @jorgebg mentioned, either print an HTML page, or let them download the PDF so they can do whatever they please with it. Unfortunately there's no clear way to do both.

Mattygabe
  • 1,772
  • 4
  • 23
  • 44
  • Yeah, I've decided that I'm just going to let the user download and then do whatever they please like you said. It's just that WebSuperGoo's website said that it could be done using C# but they conveniently don't explain how. – broguyman Apr 18 '12 at 20:35
  • I'm curious what they meant there - can you provide a link to where they mention that? Perhaps they were treating the printer just like another resource to send data to, and so it wouldn't necessarily be applicable for a web app as you're using? Otherwise, I'm stumped. – Mattygabe Apr 18 '12 at 20:43