html - 使用飞碟生成风景 pdf?
问题描述
我正在使用飞碟生成 pdf 文件。我想要第一页,第二页处于横向模式,其余页面处于纵向模式。所以,我这样做:
@page {
margin-top: 3.3cm;
margin-left: 2cm;
margin-right: 2cm;
margin-bottom: 3.3cm;
size: A4 portrait;
height: 21cm; width: 28.6cm
}
@page land { size: a4 landscape;}
.landscapePage { page:land; height: 21cm; width: 28.6cm}
<div class="page-break landscapePage">
page 1
</div>
<div class="page-break landscapePage">
page 2
</div>
但它会自动在第一个 pdf 文件中创建 2 个空白页?我如何解决它?
解决方案
我认为罪魁祸首是height
横向页面中的属性。
高度(21cm)加上边距(2*3.3cm)大于(真实)页面上的可用高度,飞碟添加了一个额外的页面来处理内容。
使其工作的最简单方法是删除有关大小的属性。唯一需要的是横向页面上的宽度,以确保 div 将使用整个页面宽度。
.page-break{page-break-before: always}
@page {
margin-top: 3.3cm;
margin-left: 2cm;
margin-right: 2cm;
margin-bottom: 3.3cm;
size: A4 portrait;
}
@page land { size: a4 landscape;}
.landscapePage { page:land; width:25.3cm}
推荐阅读
- amazon-web-services - 为什么 EB 将我抛出 Not Found 在此服务器上找不到请求的 URL?
- docker - Docker服务因依赖而无法启动
- python - 逐层评估 U-Net
- java - 如何聚合 MongoDB 的最终总和?从之前计算的总和
- javascript - 为什么它在重新加载后显示 JSON 数据而不是显示前端?
- scheduled-tasks - Windows 任务计划程序的端口
- facebook-graph-api - 通过 API 的 Facebook 受众重叠不起作用
- gcc - 缺少 GTK3 功能
- fullcalendar - Fullcalender 自定义 mothsNames
- python - 使用 Bleak 和 PyQtGraph 包实时绘制 BLE 数据