gpt4 book ai didi

javascript - 在 pdf 页面中设置边距和字体大小,并在 pdf 页面中删除 url 和 datetime

转载 作者:行者123 更新时间:2023-11-30 11:06:57 25 4
gpt4 key购买 nike

将我的 aspx 页面导出为 pdf 时,在页面的右上角,我得到了页面的 url,在右下角,它正在显示 datetime。如何从 pdf 页面中删除它?

而且我必须减少 pdf 页面的左右边距并更改字体大小?可能吗?

<div id="printIt">
// data grid
</div>
<asp:Button ID="btn_print" runat="server" ClientIDMode="Static" Text="Print" OnClientClick="printPage();" />

js代码

 function printPage() {
var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";
var newstr = document.getElementById("printIt").innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = newstr;
window.print();
document.body.innerHTML = oldstr;
}

我怎样才能将这个打印函数修改为::

1. remove url and date time from top of the pdf
2. set left and right margins for the pdf page
3. set font size and font type for pdf page

最佳答案

尝试使用 CSS 属性

样式:

@media print {
body {
font-size: 14px;
font-family: 'Times New Roman'
}
}

定位:

@page {
margin: 0cm 2cm 0cm 2cm;
}

关于javascript - 在 pdf 页面中设置边距和字体大小,并在 pdf 页面中删除 url 和 datetime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55227466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com