我正在尝试使用.NET (使用PDF4NET或iTextSharp,但不关闭这些)或Objective-C (CGContextXXX,CGPDFXXX等)来裁剪PDF。但不保留不可见的内容!
目前,我可以使用裁剪框或剪辑区域进行裁剪操作,但所有不可见的内容仍然存在于PDF中...
有可能吗?
谢谢(对不起,我是法国人……)
发布于 2011-10-25 23:47:06
您可以尝试使用Amyuni PDF Creator .Net来完成此任务。您可以使用方法IacDocument.GetObjectsInRectangle来检索您感兴趣的所有“图形对象”:
IacDocument.GetObjectsInRectangle方法
GetObjectsInRectangle方法获取指定矩形中的所有对象。
然后,您可以迭代页面中的所有对象并删除那些您不感兴趣的对象:
//open a pdf document
document.Open (testfile,"");
IacPage page1 = document.GetPage (1);
Amyuni.PDFCreator.IacAttribute attribute = page1.AttributeByName ("Objects");
// listobj is an array list of graphic objects
System.Collections.ArrayList listobj = (System.Collections.ArrayList) attribute.Value;
foreach ( object pdfObj in listobj )
{
// if pdfObj is not in the collection of interest
// then call pdfObj.Delete();
}
更新:
Amyuni PDF Creator .Net 5.0版添加了一个新的方法IacDocument.Redact,它在这种情况下可能也很有帮助:
方法检索指定矩形中指定类型的所有对象,删除它们,并在它们所在的位置绘制一个纯色矩形。
免责声明:我在Amyuni Technologies工作
https://stackoverflow.com/questions/7890101
复制相似问题