从浏览器中仅打印SVG [英] Print Only SVG from Browser

查看:306
本文介绍了从浏览器中仅打印SVG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于用户互动动态渲染SVG图形的网页。一旦完成,我希望用户能够仅打印图形 - 不仅仅打印它们驻留在的网页和SVG以及它,而只是打印SVG。此外,理想情况下,打印版本的绘制方式与屏幕浏览器版本略有不同。对于当前的浏览器和SVG,这种事情是否可行?

I'm working on a webpage that will dynamically render SVG graphics based on user interaction. Once complete, I would like the user to be able to print the graphics only - not simply print the webpage they reside on and the SVG along with it, but just the SVG. Also, the printed version will ideally be drawn slightly differently than the onscreen browser version. Is this sort of thing possible with current browsers and SVG?

在Java中,我可以为我的应用程序绘制例程提供绘制引擎或打印引擎,这个句柄简单地说同样的问题。但是,我是SVG的新手,我无法确定是否存在类似的机制。

In Java, I can provide either a paint engine or a print engine to my applications drawing routine, and this handles the same problem simply. I'm a novice to SVG, however, and I can't determine whether some similar mechanism exists.

推荐答案

你可以打电话 window.print 从javascript开始打印过程。

You can call window.print to start the printing process from javascript.

您可以使用媒体查询例如

@media print { different css for print SVG }

如果您不希望打印页面上的现有内容,请使用媒体查询设置它显示:无或可见性:隐藏。

If you don't want existing stuff on the page to print, use the media query to set it display:none or visibility:hidden.

这篇关于从浏览器中仅打印SVG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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