简体   繁体   English

使用pdfSharp展平AcroForm以减小文件大小

[英]Flatten AcroForm using pdfSharp to reduce file size

Currently I have a couple of PDF files including filled acro forms. 目前,我有几个PDF文件,包括填充的Acro表单。 For reporting purpose I need to get the file size reduced. 出于报告目的,我需要减小文件大小。 So I'm searching for pdfsharp functionalities to remove the acroform fields (flatten?) hoping that it will reduce the total file sizes. 因此,我正在寻找pdfsharp功能以删除acroform字段(变平?),希望它将减少总文件大小。

Is there any possibility using pdfSharp? 使用pdfSharp是否有可能?

As far as I could see, iTextSharp is providing some mechanisms... 据我所知,iTextSharp提供了一些机制。

Update (due to the -1 rating): 更新(由于-1级):

Yes of course does flattening have other results. 当然,展平不会带来其他结果。 That was only a thought from my side. 那只是我的想法。 The idea behind that is, that acroforms is a really good feature that enables the software to use pdf as (quite performant) templates. 其背后的想法是,acroforms是一个非常好的功能,使软件可以将pdf用作(相当出色的)模板。 And all departments are able to prepare that. 所有部门都可以准备。 But on the composite, these AcroFields causes that teh pdf docs are much bigger. 但是在复合材料上,这些AcroFields导致pdf文档更大。 For reporting purpose I don't need the form fields. 出于报告目的,我不需要表单字段。

When it comes to PDF's "flattening" the acrofields will make the fields readonly. 当涉及PDF的“展平”时,acrofields将使字段变为只读。 It won't remove them from the document. 不会将它们从文档中删除。 This becomes apparent if you set the value of the fields before flattening them. 如果在展平字段之前设置字段的值,这将变得显而易见。 The values of the fields will be printed where the fields were located they just won't be changeable. 字段的值将被打印在字段所在的位置,它们将不会更改。

If that's what you want you can do it with PDFSharp 如果那是您想要的,则可以使用PDFSharp来完成。

PdfDocument doc = PdfReader.Open(filePath, PdfDocumentOpenMode.Modify);
doc.Flatten();

This will flatten the acrofields which will make them readonly. 这将使acrofield变平,使其变为只读状态。 I just tried it out, it does not seem to decrease the file size. 我只是尝试了一下,它似乎并没有减小文件大小。 So I'm not sure this is the solution you were searching for, but in response to your question. 因此,我不确定这是否是您正在寻找的解决方案,但可以回答您的问题。 Yes. 是。 It is possible to flatten Acroform using PDfSharp. 可以使用PDfSharp展平Acroform。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM