在Python中使用XHTMLPDF2;很棒的工具!
我正在生成要集成到另一个PDF中的PDF,所以我需要第一页从顶部的某个高度开始(例如,有时是432pt,其他时候是200pt;它在一个变量中)。
然而,之后的每一页都应该从顶部开始。
我试过这个CSS,它就像我想要的那样工作……除了第二页和第二页,从覆盖第一页开始,你会得到原始第一页的网格,第二页从第一页开始。其他每一页都没问题。
这是我的风格:
<style>
@page {
size: letter landscape;
@frame content1_frame {left: 50pt; width: 512pt; top: 494pt; height: 118pt;}
@frame content2_frame {left: 50pt; width: 512pt; top: 20pt; height: 612pt;}
}
</style>我也尝试过只使用一个框架(仅限content1_frame),但每一页都从顶部开始494磅。提前感谢
发布于 2015-06-11 23:49:08
在你的内容之前,使用
<pdf:spacer height="400px">因此您的源HTML可能如下所示
<html><head><style>
@page {
size: letter landscape;
@frame content2_frame {left: 50pt; width: 512pt; top: 20pt; height: 612pt;}
}
</style>
</head><body>
<pdf:spacer height="400px">
My exciting content goes here! <span style="font-family: Verdana, Arial; font-size: 13.3999996185303px; line-height: 19.1428565979004px; text-align: center; background-color: #ccccdd;">T</span>
</body></html>和你的Python代码
from xhtml2pdf import pisa # import python module
resultFile = open('out.pdf', "w+b")
pisaStatus = pisa.CreatePDF(sourceHTML, dest=resultFile)
resultFile.close()https://stackoverflow.com/questions/30769656
复制相似问题