1

I use FPDF to generate a pdf file and open it in a new window.

how to pop up the print window when it is opened in a new window?

4

2 回答 2

1

如果您正在处理网页,Zombat 的答案有效,但 PDF 文件没有正文标签。对于 PDF 文件,我不确定是否可行。

但!我会争辩说,无论如何,这种方式更好。让用户点击 ctrl-p 进行打印比假设他们想要打印并“有帮助地”为他们抛出对话框更具侵入性。国际海事组织当然。

于 2009-07-31T02:48:35.680 回答
0

Put the following into your <body> tag in the popup window:

<body onload="window.print()" />

This is Javascript, which will then open the browser's Print dialog. You cannot print directly from Javascript, but you can open the prompt.

If you're just opening the raw PDF in the window, you could control it from the parent window as well, either in a button, or any other javascript handler:

<input type="button" value="Generate PDF" onclick="var w = window.open('generated_pdf.pdf','mywin'); w.print();"/>

于 2009-07-31T02:44:58.213 回答