Aspose.PDF for .NET是用于.NET Core的高级PDF处理API,可以在跨平台应用程序中轻松生成,修改,转换,呈现,保护和打印文档。无需使用Adobe Acrobat。你可以下载《Aspose.PDF for .NET开发者指南》获取更多帮助。
在 C# 中展平 PDF 表单字段的步骤
- 为 .NET NuGet 包安装Aspose.PDF
- 包括Aspose.PDF和Aspose.PDF.Facades命名空间
- 使用许可证类设置 Aspose 许可证
- 创建 Form 类的实例
- 绑定要拼合的 PDF 文件
- 使用FlattenAllField 方法合并所有表单域
- 使用 FlattenField 方法展平特定字段
- 最后,保存拼合后的输出PDF文件
在 C# 中展平 PDF 表单字段的代码
代码如下:
using System;//Add Aspose.Pdf for .NET package reference//Use following namespaces to flatten PDF form Fieldsusing Aspose.Pdf;using Aspose.Pdf.Facades;namespace FlattenPDFFormFields{ class Program { static void Main(string[] args) { //Set Aspose license before flattening PDF form fields //with the help of Aspose.Pdf for .NET Aspose.Pdf.License AsposePDFLicense = new Aspose.Pdf.License(); AsposePDFLicense.SetLicense(@"c:asposelicenselicense.lic"); //create an object of Form class to initiate form field flattening Form PDFFormToBeFlattened = new Form(); //Bind the PDF file which contains the form fields to be flattened PDFFormToBeFlattened.BindPdf("SamplePDFFormwithFields.pdf"); //Use FlattenAllFields method to flatten all of the fields in the //PDF form loaded above PDFFormToBeFlattened.FlattenAllFields(); //Save output PDF file with form fields flattened using Save method //of Form object PDFFormToBeFlattened.Save("OutputPDFwithFlattenedFormFields.pdf"); } }}
以下 C# 示例使用 FlattenField 方法将特定字段与 PDF 文件合并。通过提供字段名称作为参数,您可以使用此方法展平任意数量的字段。
在 C# 中展平单个 PDF 表单字段的代码
using System;//Add Aspose.Pdf for .NET package reference//Use following namespaces to flatten PDF form Fieldsusing Aspose.Pdf;using Aspose.Pdf.Facades;namespace FlattenPDFFormFields{ class Program { static void Main(string[] args) { //Set Aspose license before flattening PDF form fields //with the help of Aspose.Pdf for .NET Aspose.Pdf.License AsposePDFLicense = new Aspose.Pdf.License(); AsposePDFLicense.SetLicense(@"c:asposelicenselicense.lic"); //create an object of Form class to initiate form field flattening Form PDFFormToBeFlattened = new Form(); //Bind the PDF file which contains the form fields to be flattened PDFFormToBeFlattened.BindPdf("SamplePDFFormwithFields.pdf"); //Use FlattenField method and specify the name of the particular field //when flattening only a single form field PDFFormToBeFlattened.FlattenField("TextFormField"); //Save output PDF file with form fields flattened using Save method //of Form object PDFFormToBeFlattened.Save("OutputPDFwithFlattenedFormFields.pdf"); } }}
如果您仍然不清楚如何在 C# 中展平 PDF 表单字段,请在Aspose.Words 免费支持论坛中提问哦 。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!