PDF 生成模板编辑器
开源可视化 PDF 生成引擎,支持自定义模板,并提供面向开发者的 API,灵活构建文档生成流程。
标记密文有以下两个步骤:
通过这两个步骤,您可以创建密文注释并应用标记密文,彻底删除文档中的敏感数据。
创建密文注释
您可以通过 CPDFRedactAnnotation 类来创建密文注释。使用 setRect 方法设置应该被密文注释覆盖的区域。
此外, 在此阶段还可以对密文的外观进行自定义设置。需要注意,一旦密文注释被应用,其外观将无法更改,因为密文注释将在应用后变为不可编辑、不可修改的静态内容,而非可交互的密文注释。
以下是创建密文注释的示例代码:
CPDFDocument document = new CPDFDocument();
document.open(pdfPath);
CPDFPage pdfPage = document.pageAtIndex(0);
CPDFRedactAnnotation redactAnnotation = (CPDFRedactAnnotation) pdfPage.addAnnot(CPDFAnnotation.Type.REDACT,document);
RectF insertRect = new RectF(0, 0, 100, 100);
redactAnnotation.setRect(insertRect);
CPDFTextAttribute textAttribute = new CPDFTextAttribute("Helvetica", 14, Color.YELLOW.getRGB());
redactAnnotation.setTextDa(textAttribute);
redactAnnotation.setFillColor(Color.RED.getRGB());
redactAnnotation.setOverLayText("REDACTED");
redactAnnotation.updateAp();
redactAnnotation.applyRedaction();应用密文更改
ComPDFKit SDK 确保如果文本、图像或矢量图形包含在密文注释所标记的区域中,则该部分的图像或路径数据将被彻底删除,且无法还原。
以下是应用密文更改的示例代码:
redactAnnotation.applyRedactions();