问题
I've tried the following 2 methods..
<embed src="assets/pdf/mypdf.pdf" id="Pdf1" name="Pdf1" hidden="true">
<a class="print" onClick="document.Pdf1.printWithDialog();"></a>
<a onClick="document.getElementById('Pdf1').printWithDialog()" style="cursor:hand;">Print file</a>
Another attempt..
<script type="text/javascript">
function printPDF(pdfUrl)
{
var w = window.open(pdfUrl);
w.print();
}
</script>
<a class="print" onClick="printPDF("assets/pdf/mypdf.pdf");">a</a>
None seem to work. Any solution so I can click a link and it sends the pdf to the print dialog? window.print just brings up the actual site in the dialog, not the pdf.
来源:https://stackoverflow.com/questions/13080180/link-to-send-pdf-straight-to-printer-dialog