PDF 生成模板编辑器
开源可视化 PDF 生成引擎,支持自定义模板,并提供面向开发者的 API,灵活构建文档生成流程。
拆分页面可以将当前文档指定的页码拆分重组为一份新的PDF文档,以下是拆分页面的步骤:
使用CPDFReaderWidget:
CPDFReaderWidgetController? _controller;
// 初始化 CPDFReaderWidget,并在 onCreated 回调中获取 controller
CPDFReaderWidget(
document: documentPath,
configuration: CPDFConfiguration(),
onCreated: (controller) {
setState(() {
this._controller = controller;
});
},
)
var pages = [0,1,2];
var savePath = '/data/user/0/com.compdfkit.flutter.example/cache/temp/PDF_Document.pdf';
// 在 Android 上,您可以使用 ComPDFKit.createUri() 来创建 Uri
// var savePath = ComPDFKit.createUri('split_document.pdf');
bool splitResult = await _controller.document.splitDocumentPages(savePath, pages);使用CPDFDocument:
// 创建并打开文档
CPDFDocument document = await CPDFDocument.createInstance();
var error = await document.open(pdfFilePath);
if (error == CPDFDocumentError.success) {
var pages = [0,1,2];
var savePath = '/data/user/0/com.compdfkit.flutter.example/cache/temp/PDF_Document.pdf';
// 在 Android 上,您可以使用 ComPDFKit.createUri() 来创建 Uri
// var savePath = ComPDFKit.createUri('split_document.pdf');
bool splitResult = await document.splitDocumentPages(savePath, pages);
}