【发布时间】:2023-01-27 00:28:48
【问题描述】:
我在这里寻找 HTML 表格 PDF 视图中的 CSS 页脚以在 IOS 设备中打印。
我将在我的代码下方分享,在那里我只能获得表格的页脚末尾,但我希望在 IOS 设备的每一页末尾都有页脚。
对于我的代码,它还在 android 中为我提供了每页末尾的页脚。但是我正在运行一个 IOS 设备,所以我希望在我的 PDF 视图中看到每页末尾的页脚。
请帮我在 IOS 设备上做。感谢您的尝试。
const html = `
<style>
@page {
margin: 0.1cm;
size: landscape;
orientation: landscape;
size: A4;
}
.demo {
border:1px solid #C0C0C0;
border-collapse:collapse;
padding:5px;
page-break-inside:auto;
margin-buttom:300px;
table-layout:fixed;
}
.demo tr{
page-break-inside:avoid; page-break-after:auto;
}
.demo th {
border:2px solid #C0C0C0;
padding:5px;
background:#F0F0F0;
}
.demo td {
border:2px solid #C0C0C0;
padding:5px;
text-align: center;
}
.images {
text-align: center;
}
body{
padding-top: 60px;
padding-bottom: 60px;
}
.footer {
position: fixed;
bottom: 0;
width: 100%;
color: black;
font-weight: bold;
text-align: center;
flex-direction:column;
}
.page-number:after {
counter-increment: pages;
content: counter(page) " of " counter(pages);
}
</style>
<html>
<div class="images">
<img src="https://www.comdelta.com.my/wp-content/uploads/2021/10/Logo.jpeg"
alt="Comdelta Technologies Sdn. Bhd"
width="200" height="100"/>
</div>
<table class="demo">
<h2>Comdelta Technologies Sdn. Bhd</h2>
<thead>
<tr>
<th>Lamp No</th>
<th>Road</th>
</tr>
</thead>
<tbody>
<tr>
<td> ${htmlDataLm[0]}</td>
<td> ${htmlDataR[0]}</td>
<td> ${htmlDataM[0]}</td>
<td> ${htmlDataS[0]}</td>
<td> ${htmlDataL[0]}</td>
<td> ${htmlDataB[0]}</td>
<td> ${htmlDataPG[0]}</td>
<td> ${htmlDataPC[0]}</td>
<td> ${htmlDataUP[0]}</td>
</tr>
<tr>
<td> ${htmlDataLm[1]}</td>
<td> ${htmlDataR[1]}</td>
<td> ${htmlDataM[1]}</td>
<td> ${htmlDataS[1]}</td>
<td> ${htmlDataL[1]}</td>
<td> ${htmlDataB[1]}</td>
<td> ${htmlDataPG[1]}</td>
<td> ${htmlDataPC[1]}</td>
<td> ${htmlDataUP[1]}</td>
</tr>
<tbody>
</table>
<p>
</p>
<div class="footer ">
<span class="page-number">Page </span>
<p>Copyright © 2022 Comdelta Technologies Sdn. Bhd.All rights reserved.</p>
</div >
</html>
`;
const generatePdf = async () => {
const { uri } = await printToFileAsync({
html,
margins: {
left: 20,
top: 20,
right: 20,
bottom: 20
},
});
console.log('File has been saved to:', uri);
await shareAsync(uri, { UTI: '.pdf', mimeType: 'application/pdf' });
}
【问题讨论】: