0

I'm trying to find a way to open a "choose printer" dialog when the user push "print", in my PHP page, not the SaveAs window.

i read all posts here , couldn't find a reply that works. also read this post : mPDF auto print issue

but the following code opens the saveas window, not the "choose printer" window:

$pdf=new mPDF('en','A4','','DejaVuSansCondensed',$template->margin_left,$template->margin_right,$template->margin_top,$template->margin_bottom,$template->margin_header,$template->margin_footer);

$pdf->setAutoFont();

$pdf->SetHTMLHeader($header);

$pdf->SetHTMLFooter($footer);

$pdf->SetJS('this.print();');

$pdf->writeHTML($printable);

$pdf->Output();

can anyone help? why do i still get the "save as" window?

Community
  • 1
  • 1
Rodniko
  • 4,926
  • 20
  • 69
  • 93

1 Answers1

0

To get a print dialog, you can simply use JS

window.onload = function() { window.print(); }

MPDF Functions:- You can also use

<?php
// Saves file on the server as 'filename.pdf'
$mpdf=new mPDF();
$mpdf->WriteHTML('<p>Hallo World</p>');
$mpdf->Output('filename.pdf','F');
?>

OR

ADD 'D' parameter to download it

$mpdf->Output('filename.pdf', 'D');

Also REFER How to open print dialog after pdf generated?

Community
  • 1
  • 1
lokeshsk
  • 443
  • 4
  • 9
  • Thank you, but that doesn't help me. window.print(); prints the page i'm in and it is not the PDF, it is another php page. i need to open a printer dialog to print the PDF, not the window. also calling Output with Parameters "D" or "F" is not relevant because i want to print the pdf , not save it as a file. as you can see above, i'm trying to print the PDF from the PHP code – Rodniko Mar 13 '14 at 05:50