We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

C# 删除双层PDF上面的文本

我使用以下代码

      Document pdfDocument = new Aspose.Pdf.Document(@"E:\桌面\666\001.pdf");
        //使用文本显示操作符
        List<string> ts = new List<string>();
        Operator[] operators = new Operator[]
        { new Operator.ShowText(),new Operator.SetGlyphsPositionShowText(new List()),
            new Operator.MoveToNextLineShowText(),new Operator.SetSpacingMoveToNextLineShowText(0,0,""),
        };

        foreach (Page page in pdfDocument.Pages)
        {
            ArrayList list = new ArrayList();
            OperatorCollection pageOperators = page.Contents;

            foreach (Operator op in operators)
            {
                OperatorSelector operatorSelector = new OperatorSelector(op);
                pageOperators.Accept(operatorSelector);
                list.AddRange(operatorSelector.Selected);
            }
            pageOperators.Delete(list);
        }

        pdfDocument.Save("TextRemoved_operators_18.4.pdf");

new List() 报错我该如何传递参数。360截图18141215157163.png (87.4 KB)
360截图17720227529772.png (17.4 KB)
360截图18180710114130120.png (8.2 KB)

Operator[] operators = new Operator[]
{ new Operator.ShowText(),new Operator.SetGlyphsPositionShowText(new List()),
new Operator.MoveToNextLineShowText(),new Operator.SetSpacingMoveToNextLineShowText(0,0,""),
};

@fhn123456

您能否也与我们分享示例 PDF?我们将在我们的环境中测试该场景并相应地解决它。另外,在共享请求的文件之前,请确保使用 22.2 版本的 API。

另外,请初始化 Operator[] 数组,如下所示

Operator[] operators = new Operator[]
{
 new Aspose.Pdf.Operators.ShowText(),
 new Aspose.Pdf.Operators.SetGlyphsPositionShowText(new List<Aspose.Pdf.Operators.GlyphPosition>()),
 new Aspose.Pdf.Operators.MoveToNextLineShowText(),
 new Aspose.Pdf.Operators.SetSpacingMoveToNextLineShowText(0,0,"")
};