如何从窗口打印中删除日期?



我创建了看起来像PDF(Angular项目(form

我使用谷歌浏览器

当我运行浏览器在视图上生成的代码window.print

  1. 日期
  2. 文档标题
  3. 页脚(带网址(

要更改我的标题,我使用 ->document.title = 'u00A0';要更改我的页脚,我使用 ->

let footer="NR_"+this.contractForm.contract_number";
window.history.pushState("object or st
ring", "Title", footer.replace("http://", ""));

如何更改/删除日期?

我知道我可以在选项中禁用页脚和页眉,但我只想(!(删除日期。页脚对我来说非常必要。

我害怕使用一些技巧,例如:

@page 
{
size: auto;   
margin: 0mm; 
}

但它对我不起作用。

目前这是不可能的。您只能隐藏它们。最好的方法是创建自己的自定义页面,您可以在其中设置页面标题和页脚:

伪代码:

var pContents="
<html>
<title>Your custom title</title>
<head></head>
<body>
<h1>
Example Document
</h1>
<div>
<p>
This is an example document that shows how to have a footer that repeats at the bottom of every page, but also isn't covered up by paragraph text.
</p>
</div>
<div>
<h3>
Example Section I
</h3>
<p>
custom content
</p>
</div>
<div class="content-block">
<h3>Example Section</h3>
<p>
custom content
</p>
</div>
<footer>
This is the text that goes at the bottom of every page.
</footer>
<body>
</html>";
printMe(pContents);
function printMe(pageContents) {
var printContents = pageContents;
document.body.innerHTML = printContents;
window.print();
}

最新更新