【问题标题】:when the pdf orientation is landscape the pdf width is not occupied fully even though width is 100%当 pdf 方向为横向时,即使宽度为 100%,pdf 宽度也不会被完全占据
【发布时间】:2023-03-11 05:05:01
【问题描述】:
当我的pdf report 具有landscape 方向时。即使 Header 表的宽度为 100%,并且 pdf 报告的 margin-right 应用了 1cm,但仍然没有全宽,但 Header 表未采用全宽标题占用
如果我的 pdf 报告具有 portrait 方向标题宽度被完全占用,问题仅在我的 pdf 报告具有 landscape 方向时,任何人都可以帮助我。
我的表格css是
table
{
width:100%
}
【问题讨论】:
标签:
css
ruby-on-rails
wicked-pdf
【解决方案1】:
我刚在本地试了一下,你应该可以用这个:
# controller
render pdf: 'foo',
orientation: 'Landscape',
margin: { top: 0, bottom: 0, left: 0, right: 0 }
注意 PDF 本身的边距设置。
# stylesheet
body{
padding: 0;
margin: 0;
}
table {
border: 1px solid black;
border-collapse: collapse;
width: 100%;
}
以及去除包裹表格的 HTML body 标签上的内边距和边距(无论你添加与否,webkit 都会这样做)。