通过javascript打印pdf [英] print a pdf via javascript

查看:91
本文介绍了通过javascript打印pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML页面,其中包含指向PDF的链接。此PDF将在新窗口中打开。
父HTML页面有一个File-> Print菜单项。当用户单击打印时,我希望能够自动打开PDF并进行打印。印刷部件是我卡住的地方。

I have a HTML page that has a link to a PDF. This PDF opens in a new window. The parent HTML page has a File->Print menu item. When the user clicks Print I want to be able to automatically open the PDF and print it. The printing part is where I am stuck.

非常感谢任何帮助。

谢谢。

推荐答案

如果您在指向该链接的链接中打开具有特定名称的窗口(例如 target =nameofwin) PDF,您可以使用 nameofwin.print()。但是,我不确定这是否有效,因为PDF将使用插件显示,而不是页面的原生部分。可能有一些API允许您与PDF显示插件进行交互,但是你会想知道你是否在那里运行Acrobat或FoxIt或WhateverElse。

If you open that window with a specific name (e.g. target="nameofwin") in the link pointing at the PDF, you might get away with nameofwin.print(). However, I'm not sure if that'd work since the PDF will be shown using a plugin, and not be a native part of the page. There may be some API that allows you to interface with the PDF display plugin, but then you're stuck wondering if you've got Acrobat or FoxIt or WhateverElse running in there.

这篇关于通过javascript打印pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆