PDF 生成模板编辑器
开源可视化 PDF 生成引擎,支持自定义模板,并提供面向开发者的 API,灵活构建文档生成流程。
以下是拆分页面的步骤:
CPDFDocument 对象。CPDFDocument 对象中。以下是拆分页面的示例代码:
// 循环拆分出所有页面
for i in 0..<(document?.pageCount ?? 0) {
let splitDocument = CPDFDocument()
let index = IndexSet(integer: IndexSet.Element(i))
splitDocument?.importPages(index, from: document, at: 0)
if let writeURL = URL(string: "writeFilePath") {
splitDocument?.write(to: writeURL)
}
}// 循环拆分出所有页面
for (int i = 0; i < document.pageCount; i++) {
CPDFDocument *splitDocument = [[CPDFDocument alloc] init];
NSIndexSet *index = [[NSIndexSet alloc] initWithIndex:i];
[splitDocument importPages:index fromDocument:document atIndex:0];
[splitDocument writeToURL:[NSURL fileURLWithPath:@"writeFilePath"]];
}