作者:飞教书的粉红色 | 来源:互联网 | 2023-01-30 13:43
我的html内容必须从页面的绝对左上角开始。但是,HtmlConverter会自动在pdf页面的顶部和左侧添加0.5英寸的间隙。如何覆盖此默认边距?
1> Samuel Huyle..:
您可以使用@page通过CSS设置页面的页边距。以下声明将所有页边距设置为0,并在段落周围绘制边框以供可视参考:
@page{
margin:0pt;
}
p{
border-left: solid 2pt blue;
border-top: solid 1pt blue;
border-bottom: solid 1pt blue;
}
使用以下内容作为输入:
This page should have the margins set at 0
您会看到该段落的边框触及页面的左侧,但尚未触及页面的顶部。那是因为该段落也有一些先天的空白作为阻碍。将此设置为0将达到目的:
p{
border-left: solid 2pt blue;
border-top: solid 1pt blue;
border-bottom: solid 1pt blue;
margin-top: 0pt;
}
@page{
margin:0pt;
}
并输出: