如何在所有页面上打印背景文本 [英] How to print background text all pages

查看:77
本文介绍了如何在所有页面上打印背景文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<!DOCTYPE html><html class=''>
<head>
<style type="text/css" media="print">   
	th {
		font-family:Arial;
		color:black;
		background-color:lightgrey;
	}
	thead {
		display:table-header-group;
	}
	tbody {
		display:table-row-group;
	}
	tfoot {
		display:table-footer-group;		
	}
</style>
<style class="cp-pen-styles">

#watermark{
    position:absolute;
    z-index:-1;
    display:block;
	top: 50%;
    left: 50%;
    margin-top: -50px;
    margin-left: -50px;
	
}
body
{
	position:absolute;
	z-index:1;
}

#bg-text
{
    color:lightgrey;
    font-size:30px;
	opacity: 0.8;
	text-align: center;
	filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476); /* IE6,IE7 */
}
</style>
</head>

<body id="content" onload="window.print()">
	<tbody>
	
<pre lang="HTML"><div id="watermark">
	<p id="bg-text">watermark</p>
	</div>







页面内容就在这里.... .................



下午到星期四晚上好几天来到这里星期几没有看到这么多美元b / b




Content of the page goes here.....................

HI TO EVERBODY TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
HI TO EVERBODY TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT

推荐答案

我希望你的意思是在后台打印,而不是背景文字。让我告诉你:这个问题并不存在。



I hope you mean "print in the background", not "background text". Let me tell you: this problem does not really exist.

  1. 根据定义,打印始终是在后台相对于Web应用程序。它总是一个独立的过程;所以你不要等到打印完成,但希望用户得到通知(这取决于一些客户端或局域网软件)。



    但是,有一点点使用当前网页的进程和线程所花费的时间;这个时候需要形成打印数据并将其传递给打印队列,但你不能真正避免它(我建议你想为什么会这样)。无论如何,这段时间通常很短 - 所有非废话浏览器都不像Adobe软件那样垃圾: - )。
  2. HTML没有页面,除非你以某种方式模仿它们,或者除非你混淆了术语网页与打印页面,但可能这是偏离主题。同时,页面在呈现打印时实际上是由HTML构成的;你也可以在打印预览中看到它们。你并没有真正控制那些页面;你可以用CSS破坏你的页面,但这可能不是你问题的一部分(如果有兴趣,你可以开始,例如,这里: @ page - CSS | MDN [ ^ ];并非您的浏览器可能无法实现所有CSS功能;而且,分页规则不是强制性的,而是建议渲染)。此外,您无法控制要打印的页面集(范围) - 用户在打印对话框中定义要打印的内容。
  1. Printing is always "in the background" relative to your Web application, by definition. It's always a separate process; so you don't wait until printing is complete, but hopefully the user gets notification (it depends on some client or LAN software).

    However, there is a little time taken on the process and thread working with your current Web page; this time is needed to form printing data and pass it to the print queue, but you cannot really avoid it (I suggest you think why is it so). Anyway, this time is usually pretty short — all non-nonsense browsers are not such trash as Adobe software :-).
  2. HTML doesn't have pages, unless you emulate them somehow, or unless you confuse the term "Web page" with print pages, but probably this is off-topic. At the same time, pages are really formed out of HTML when it is rendered for printing; you can see them in print preview as well. You don't really control those pages; you can affect breaking of your pages with CSS, but probably this is not a part of your question (if interested, you can start, for example, here: @page — CSS | MDN[^]; not that your browser may not implement all CSS features; also, paging rules are not obligatory, they are rather recommendation for rendering). Also, you don't have control over the set of pages (range) to be printed — the user defines what to print in the print dialog.



总体而言,它看起来你无需担心。



现在,你的水印问题与打印没有直接关系。 如何打印第二页的问题是错误的;你只是没有第二页。



它可以是两个因素的组合:使用绝对定位和不同的打印介质样式。相对于父HTML元素,绝对定位实际上是相对的。它用于重叠元素,这本身就足够危险,应小心使用。打印时,您会以与屏幕相同的方式获取元素渲染,并考虑CSS,此外,内容将分解为打印页面。如果水印文本覆盖了第一页的某些内容,则没有任何内容会导致它出现在第二页上。你得到了你所期望的。



怎么办? IT取决于您的目标。如果您想在单独的页面上使用水印,请使用@media规则,也许不要使其成为打印介质的绝对。这正是@media规则的目的,使屏幕和打印渲染不同。这是现代替代那种过时的设计功能,打印版本。使用此CSS功能,打印版本将自动从唯一的页面版本创建。



-SA


这篇关于如何在所有页面上打印背景文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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