2

如何使用 iTextSharp 从 pdf 文件中删除“线”形状?

我尝试:

var shape = page.GetAsStream(PdfName.LINE); //return null

var resources = PdfReader.GetPdfObject(page.Get(PdfName.RESOURCES)) as PdfDictionary; //return dictonary
var resShape = resources.GetAsStream(PdfName.LINE); //return null

PdfReader.KillIndirect(shape);
PdfReader.KillIndirect(resShape);

我做错了什么?

谢谢!

4

1 回答 1

4

像这样的东西:

 PdfDictionary pg = reader.GetPageN(1);
        PdfArray annotsArray = pg.GetAsArray(PdfName.ANNOTS);
        if (annotsArray != null)
        {
            for (int k = 0; k < annotsArray.Size; k++)
            {
                PdfDictionary annot = (PdfDictionary) PdfReader.GetPdfObject(annotsArray[k]);
                if(annot.GetAsName(PdfName.SUBTYPE).ToString() =="/Line")
                {
                    annotsArray.Remove(k);
                }
            }
        }
于 2013-06-27T14:24:13.893 回答