使用 SwiftUI 渲染 PDF 的便捷框架
PDFRenderer
使用 SwiftUI 渲染 PDF。
例
let document = PDFDocument {
PDFPage(.a4) { size in
VStack {
Text("This is the first page.")
}.frame(width: size.width, height: size.height)
}
PDFPage(.custom(width: 800, height: 600)) { size in
VStack {
Text("This is the second page.")
}.frame(width: size.width, height: size.height)
}
}
// PDF document creation requires @MainActor
Task {
// Render the PDF document and write it to a file.
try await document.render(to: URL(filePath: "/some/path/filename.pdf"))
// Render the PDF document in memory as a Data instance.
let pdfInMemory = try await document.renderInMemory()
}
取消许可证
这是发布到公共领域的免费且不受阻碍的软件。
任何人都可以出于任何目的(商业或非商业)以及以任何方式自由复制、修改、发布、使用、编译、销售或分发本软件,无论是源代码形式还是编译二进制文件。
在承认版权法的司法管辖区,本软件的作者将软件的任何和所有版权权益奉献给公共领域。我们做出这种奉献是为了广大公众的利益,并损害我们的继承人和继任者。我们打算将这种奉献精神作为根据版权法永久放弃该软件所有当前和未来权利的公开行为。
本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者均不对因本软件或本软件的使用或其他交易而引起、由本软件或与本软件的使用或其他交易有关的任何索赔、损害赔偿或其他责任负责,无论是在合同、侵权或其他诉讼中。
欲了解更多信息,请参阅 https://unlicense.org