我需要用
HTML制作一个应该是A4尺寸的报告.它需要页眉和页脚.当然这可以用css来完成吗?
有没有人有任何示例或示例代码?
我用谷歌搜索和代码片段,我得到所有谈论媒体查询,他们不工作..
所以基本上它是用于打印目的,生成的html将转换为PDF文档.
我正在使用MVC4并找到了一个将视图转换为PDF的工具.视图只是纯HTML.所以我想为什么不用HTML来表示输出报告,然后用PDF表示.
所以我需要能够有一个标题和一个页脚(页面底部),然后内容在两个中间
我尝试使用以下代码,但它似乎没有工作..
@page {
size: A4 portrait; /* can use also 'landscape' for orientation */
margin: 1.0in;
border: thin solid black;
padding: 1em;
@bottom-center {
content: element(footer);
}
@top-center {
content: element(header);
}
}
#page-header {
display: block;
position: running(header);
}
#page-footer {
display: block;
position: running(footer);
}
.page-number:before {
content: counter(page);
}
.page-count:before {
content: counter(pages);
}
Header text
Page 1.
Page 2.