PDF 生成模板编辑器
开源可视化 PDF 生成引擎,支持自定义模板,并提供面向开发者的 API,灵活构建文档生成流程。
在文档中移动指定页面到目标位置。移动页面的步骤如下:
以下示例演示如何移动页面:
const pdfReaderRef = useRef<CPDFReaderView>(null);
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={ComPDFKit.getDefaultConfig({})}
/>
// 将第 1 页移动到第 2 页的位置(页面索引从 0 开始)
const fromIndex = 0;
const toIndex = 1;
const moveResult = await pdfReaderRef.current?._pdfDocument.movePage(
fromIndex,
toIndex
);
if (moveResult) {
// 刷新页面以应用移动效果
await pdfReaderRef.current?.reloadPages2();
}