我想使用PdfCleanUpProcessor
和以下代码提供PDF编辑功能:
Rectangle redactionRectangle = new Rectangle(74, 503, 385, 761);
PdfReader pdfReader = new PdfReader(sourcePath);
PdfStamper pdfStamper = new PdfStamper(pdfReader,
new FileStream(destinationPath, FileMode.Create));
List<PdfCleanUpLocation> cleanUpLocations = new List<PdfCleanUpLocation>
{
new PdfCleanUpLocation(1, redactionRectangle, BaseColor.WHITE)
};
PdfCleanUpProcessor cleaner = new PdfCleanUpProcessor(cleanUpLocations, pdfStamper);
cleaner.CleanUp();
pdfStamper.Close();
这适用于没有图像的PDF,但带图像的PDF会导致异常。
Running on the linked file throws:
不支持颜色深度1.
And running on the linked file throws:
对象引用未设置为对象的实例。