翻譯|使用教程|編輯:李顯亮|2021-07-16 09:49:39.447|閱讀 215 次
概述:當(dāng)想將 PDF 表單字段與 .NET 應(yīng)用程序中的內(nèi)容合并,因此這些字段不可編輯時(shí),您想知道如何在 C# 代碼中拼合 PDF 表單字段?Aspose.PDF for .NET API用幾行代碼幫助回答這個(gè)問(wèn)題。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
當(dāng)您想將 PDF 表單字段與 .NET 應(yīng)用程序中的內(nèi)容合并,因此這些字段不可編輯時(shí),您想知道如何在 C# 代碼中拼合 PDF 表單字段?Aspose.PDF for .NET API用幾行代碼幫助回答這個(gè)問(wèn)題。
使用此 .NET API,可以一次展平基于 acroform 的PDF、所有表單字段或選擇特定字段以在您的 C# 應(yīng)用程序中展平。ASP.NET Web 應(yīng)用程序、Windows 桌面應(yīng)用程序或其他 .NET 平臺(tái)的代碼相同。
Aspose.PDF for .NET是用于.NET Core的高級(jí)PDF處理API,可以在跨平臺(tái)應(yīng)用程序中輕松生成,修改,轉(zhuǎn)換,呈現(xiàn),保護(hù)和打印文檔。無(wú)需使用Adobe Acrobat。你可以下載《Aspose.PDF for .NET開(kāi)發(fā)者指南》獲取更多幫助。
代碼如下:
using System; //Add Aspose.Pdf for .NET package reference //Use following namespaces to flatten PDF form Fields using 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:\asposelicense\license.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 文件合并。通過(guò)提供字段名稱(chēng)作為參數(shù),您可以使用此方法展平任意數(shù)量的字段。
using System; //Add Aspose.Pdf for .NET package reference //Use following namespaces to flatten PDF form Fields using 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:\asposelicense\license.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"); } } }
請(qǐng)注意,在 C# 中拼合 PDF 表單字段時(shí),您不需要Adobe Acrobat或任何其他 PDF 編輯軟件。此 API 包含在 .NET 中以編程方式展平 pdf 所需的一切。
如果您仍然不清楚如何在 C# 中展平 PDF 表單字段,請(qǐng)?jiān)?a target="_blank">Aspose.Words 免費(fèi)支持論壇中提問(wèn)哦 。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn