不保持不可见的内容裁剪PDF(.NET或ObjC) [英] Crop PDF without keeping invisible content (.NET or ObjC)

查看:289
本文介绍了不保持不可见的内容裁剪PDF(.NET或ObjC)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用.NET来裁剪PDF文件(使用PDF4NET或iTextSharp的,但没有关闭这些的)或Objective-C的(CGContextXXX,CGPDFXXX等)......但是,如果没有保持无形的内容!

I'm trying to crop a PDF using .NET (using PDF4NET or iTextSharp, but not closed to these ones) or Objective-C (CGContextXXX, CGPDFXXX, etc.)... But without keeping the invisible content !

目前,我能够使用裁剪框或剪辑区域做裁剪操作,但所有内容隐形仍是美元的的PDF p $ psent ...

Currently, I'm able to do the crop operation using the Crop Box or a Clip Region, but all content invisible is still present in the PDF...

这可能吗?

感谢(对不起,我是法国人......)

Thanks (and sorry, I'm french...)

推荐答案

您可以尝试的 Amyuni PDF创建的.Net 完成这个任务。你可以使用的方法<一href="http://amyuni.com/WebHelp/Amyuni_PDF_Creator_for_NET/Amyuni_PDFCreator_IacDocument/Methods/GetObjectsInRectangle_Method.htm"相对=nofollow> IacDocument.GetObjectsInRectangle 来检索所有的图形对象你的兴趣:

You could try Amyuni PDF Creator .Net for this task. You could use the method IacDocument.GetObjectsInRectangle to retrieve all the "graphic objects" of your interest:

IacDocument.GetObjectsInRectangle方法

IacDocument.GetObjectsInRectangle Method

该GetObjectsInRectangle方法获取所有处于该对象   指定的矩形。

The GetObjectsInRectangle method gets all the objects that are in the specified rectangle.

然后就可以遍历页面中所有对象,并删除那些你不感兴趣的:

Then you can iterate all the objects in the page and delete those that you are not interested in:

//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创建.NET版本5.0增加了一种新的方法<一href="https://www.amyuni.com/WebHelp/Amyuni_PDF_Creator_for_NET/Amyuni_PDFCreator_IacDocument/Methods/IacDocument.Redact_Method.htm"相对=nofollow> IacDocument.Redact 这也可能有助于在这种情况下的:

Update:
Amyuni PDF Creator .Net version 5.0 adds a new method IacDocument.Redact which might also be helpful in this kind of scenario:

本纂方法检索指定类型的所有对象   指定的矩形,删除它们,并绘制纯色   矩形在自己的位置。

The Redact method retrieves all the objects of the specified type in the specified rectangle, deletes them, and draws a solid color rectangle at their place.

声明:我Amyuni技术工作

这篇关于不保持不可见的内容裁剪PDF(.NET或ObjC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆