2

I got a task today, to generate *.pdf out of *.odt file, and then make printing as user friendly as possible.

So far i managed to send pdf to user, to let him save it as file, and then he can print it by himself. Also i can open pdf in the browser.

But i wanted to ask if there is a way to print it without the popup window?

Wanted to ask if its possible to at least show the print/cancel window without opening actual pdf to the viewer eyes?

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

Yes, i have read some similar questions out there. Most of them were talking about some named action (which was supposed to be added by Acrobat Pro(?)), putting some javascript into the pdf file, which took me an hour to Google, without any luck how to do that with php/javascript if its even possible, and some other solutions involving Fpdf - but i need my pdf converted out of odt file, and i don't think that's possible in fpdf.

Any help, or tips appreciated.

PS. I want to print it on client side of course.

EDIT
I tried some embed or iframe solutions, but i was getting an error in firefox, saying something about not sufficient authorization or something. Will try to reproduce the issue on this PC, so i can give more details.

Kedor
  • 1,488
  • 5
  • 29
  • 53
  • An idea might be having the content of your pdf loaded in a small iFrame that also has the print code in JavaScript. As soon as it's loaded it will pop the print dialog for user to continue the action. – NickOpris Feb 17 '14 at 18:00
  • Well, the idea is good, but most of solutions have some issues in one of the main browsers, or are badly explained. That's why i asked this question here :P – Kedor Feb 17 '14 at 20:12

2 Answers2

1

I don't think its possible to bypass the browser print dialog and send a print directly to the printer

FlowPaper Team
  • 500
  • 3
  • 7
  • Alright then, that would cross out my first question. What about second one? Print dialog without showing the pdf to the user? (he "knows" what he choses to print) – Kedor Feb 17 '14 at 18:44
  • 1
    You could open the PDF in a iframe with 0% height and width and then trigger the print in the following manner: http://stackoverflow.com/questions/16239513/print-pdf-directly-from-javascript but it won't work in every browser. You can also have a look at http://flexpaper.devaldi.com or PDFJS if you want support for all browsers – FlowPaper Team Feb 17 '14 at 19:32
0

You can do it with our (commercial) PDF API, as we documented in this blog article. You're still going to get a dialog, and you'd need to use an Applet (so in fact you're probably going to get about a half-dozen dialogs the first time it's run).

The advantage of this approach is that the end user doesn't have to have Acrobat installed, and that the applet doesn't have to be visible to the viewer. The disadvantage is you'd need to purchase our software, and it's an applet - which means that there will be a one-off download of about 1MB and a few security dialogs the first time it's run.

The "invoke Acrobat with parameters" approach you may have seen documented elsewhere is unlikely to work these days due to the browser security levels being increased. Another approach that might work is if you know Acrobat Reader is installed and set up to run as a browser plugin, then you might be able to run an open-action on the PDF which triggers a print. Of course you'd need a PDF API to modify the PDF to do this. Or, if the browser can display PDFs natively then the answer by Flexpaper is a good one).

Cheers... Mike (CTO @ BFO)

Mike B
  • 1,600
  • 1
  • 12
  • 8