javascript - 是否可以使 Window.Print() 方法使用其背景颜色打印突出显示的文本?
问题描述
正如我们可以通过html
在以下 w3schools.com链接上复制/粘贴以下内容来验证它突出显示单词highlighted
withyellow background
和单词test
with red foreground
。但是,如下图所示,当您使用Window.Print()
命令打印此 html 页面时,它不会打印 word 的黄色背景highlighted
。问题:是否有一种解决方法可以使Window.Print()
方法也适用于突出显示的文本?
<!DOCTYPE html>
<html>
<body>
<h2>The window.print() Method</h2>
<p>Click the button to print the current page.</p>
<p>This is a <span style='background:yellow;'> highlighted</span> text. And <span style='color:red;'>test</span> for font color.</p>
<button onclick="window.print()">Print this page</button>
</body>
</html>
Print to PDF
上述 html 预览的Windows 10 中的快照
解决方案
推荐阅读
- ruby-on-rails - Rails - 关闭当前的数据库连接
- python - 当我从批处理文件和任务计划程序运行脚本时,子进程运行、check_output、Popen 返回空字符串
- python - Python FTP ftplib 将整个文件夹移动到另一个目录失败,并显示“无法链接到另一个设备上的文件”
- python - 将 csv 目录读入 Pandas 数据框
- shell - 操作系统版本捕获脚本 - 使用 awk 时出现意外结果
- python - 无法通过请求库将文件上传到 API
- c++ - 对象已定义
- c++ - 如何使用 bitblt 在屏幕上绘制由数组制作的位图?
- amazon-web-services - LDAP 与受信任的 Active Directory 域的集成
- python - 使用 argparse 将登录信息传递给 Python 中的请求