iTextSharp - 使用图像裁剪PDF会引发异常

时间:2016-06-27 12:18:27

标签: c# pdf itext redaction

我想使用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:

  

对象引用未设置为对象的实例。

0 个答案:

没有答案