使用JavaScript打开Chrome PDF查看器对话框 [英] Open Chrome PDF viewer dialogue with JavaScript

查看:89
本文介绍了使用JavaScript打开Chrome PDF查看器对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为用户提供使用Chrome本身将当前网页另存为PDF的选项,不需要其他浏览器支持,并且引入第3方系统也不可行.

I am trying to offer users the option to save the current webpage as a PDF using Chrome natively, no other browser support is required and introducing a 3rd party system is not a practical option.

当前,我必须手动指示用户打印预览中打开PDF"链接在打印对话框中的位置,并且仅提供以下按钮:

Currently I have to manually instruct the user where the "Open PDF in Preview" link is within the print dialogue and only offer the following button:

<a href="#" onclick="event.preventDefault(); window.print();">
    PDF Preview
</a>

我想直接将用户跳转到PDF预览对话框以供他们保存,以下内容当然行不通,但与我想要实现的功能更加相似.

I would like to jump the user straight to the PDF preview dialogue for them to save, the following will of course not work, but is more similar to what I would like to achieve.

<a href="#" onclick="event.preventDefault(); window.print('pdf');">
    PDF Preview
</a>

推荐答案

无法做到这一点.

Chrome当前符合HTML标准,因为打印"通常意味着以某种物理方式获取页面,无论是传统的打印文档还是PDF.如何选择执行此操作取决于浏览器供应商.

Chrome currently meets the HTML standard as "print" generically means obtaining the page in some physical way, be that a traditional printed document or a PDF. How it chooses to do this is up to the browser vendor.

此外,Chrome用户可以选择其默认打印操作为PDF或网络上的打印机.

Additionally Chrome users can select their default action for printing to be PDF or a printer on their network.

据此我推断Chrome不太可能让Web应用程序覆盖用户首选项.

From that I would infer that it's unlikely Chrome would let the web application override the user preference.

来源

这篇关于使用JavaScript打开Chrome PDF查看器对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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