ios - TPPDF (iOS) - 页脚部分的图像显示超出页面边界
问题描述
我正在显示一个示例 pdf,其中包含页眉图像、页脚图像和中间的一些内容。(库 - https://github.com/techprimate/TPPDF)
页眉图像显示正常,但页脚图像显示在页面底部边界下方。
这是代码:
var layout = PDFPageLayout()
layout.margin = UIEdgeInsets(top: 30, left: 30, bottom: 30, right: 30)
layout.size = PDFPageFormat.a4.size
layout.space.header = 30
let document = PDFDocument(layout: layout)
let headerImage = UIImage(named: "header")!
let headerImageElement = PDFImage(image: headerImage)
headerImageElement.quality = 1.0
headerImageElement.options = [.none]
document.addImage(.headerCenter, image: headerImageElement)
for i in 1...100 {
document.addText(.contentCenter, text: "Content goes here. \(i)")
}
let footerImage = UIImage(named: "footer")!
let footerImageElement = PDFImage(image: footerImage)
footerImageElement.quality = 1.0
footerImageElement.options = [.none]
document.addImage(.footerCenter, image: footerImageElement)
do {
var docURL = try PDFGenerator.generateURL(document: document, filename: "Example.pdf")
let request = NSURLRequest(url: docURL);
webView.load(request as URLRequest);
}
catch {
print("error loading PDF")
}
输出如下(未显示页脚图像):
现在,如果我将底部边距插图增加到 150 左右,即
layout.margin = UIEdgeInsets(top: 30, left: 30, bottom: 150, right: 30)
页脚图像开始显示,但页脚图像和内容之间存在很大差距。
注意:页脚图像内部没有任何空白。
我在这里有什么遗漏吗?
解决方案
推荐阅读
- matplotlib - Matplotlib:设置animation.rc参数
- python - 如何将模板字段与forms.py和views.py连接起来,以便在模板字段中传递的值可以通过函数
- emacs - emacs 独立并排拆分窗口
- python - Selenium:无法调用单击按钮元素
- java - 请检查 JNDI 领域配置
- c - 简单c程序中的奇怪输出值
- lua - ROBLOX - 如果语句不会在 while 循环内运行?
- java - 在 JAVA 中使用 char '{' 定义字符串
- ios - AudioKit 的 RenderToFile 无法正常工作
- cakephp - 如何在 Cakephp 3.5 中的控制器/视图中动态设置头部 css 和页脚上的 js