简体   繁体   中英

Printing PDF file, with print dialog, without file preview

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.

我认为绕过浏览器打印对话框并将打印直接发送到打印机是不可能的

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM