原創|其它|編輯:郝浩|2013-02-01 13:35:57.000|閱讀 319 次
概述:通過activePDF Toolkit,終端用戶可以互動式地完成PDF表格填充。簡單地輸入需要的信息,然后點擊提交即可。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
通過activePDF Toolkit,終端用戶可以互動式地完成PDF表格填充。簡單地輸入需要的信息,然后點擊提交即可。這樣數據就會無縫地傳輸到你指定的區域。本地存儲到表格或者離線內存里。除了互動的表格填充, Toolkit還能由程序自動填充表格框,同時允許你用任意來源的文字和圖片填充PDF表格和模板。
示例代碼如下:
// Copyright (c) 2013 activePDF, Inc. // Example created 01/31/13 // Make sure to add the activePDF product .NET DLL(s) to your application. // .NET DLL(s) are typically found in the products 'bin' folder. class Examples { public static void Example() { string strPath; int intOpenOutputFile; int intOpenInputFile; int intCopyForm; strPath = System.AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APToolkitNET.Toolkit oTK = new APToolkitNET.Toolkit(); // This example will take one PDF form and fill it out twice // resulting in a 2 page PDF containing two filled forms // The new PDF will have renamed fields so they do not conflict // Unused fields will be flattened (removed) // Create the new PDF file intOpenOutputFile = oTK.OpenOutputFile(strPath + "new.pdf"); if (intOpenOutputFile != 0) { ErrorHandler("OpenOutputFile", intOpenOutputFile); } // Open the template PDF intOpenInputFile = oTK.OpenInputFile(strPath + "form.pdf"); if (intOpenInputFile != 0) { ErrorHandler("OpenInputFile", intOpenInputFile); } // Set how you want form field data formatting to be handled // By default the field will remain the same (1) // You can have the field formatting be ignored (0) oTK.DoFormFormatting = 1; // As we will be using the same PDF form for multiple pages we do not want // the field names to conflict as different data will be in same named fields // Using FormNumbering will rename the fields so they do not conflict // field 'name' would become 'name__1', 'name__2', etc oTK.FormNumbering = 1; // Populate form fields for the first page with data // Refer to the documentation for possible flag options oTK.SetFormFieldData("name", "John Doe", 1); oTK.SetFormFieldData("date", "03-27-1984", -997); oTK.SetFormFieldData("amount", "4231.34", -997); // Copy the first page (with field data) to the new pdf intCopyForm = oTK.CopyForm(0, 0); if (intCopyForm != 1) { ErrorHandler("CopyForm", intCopyForm); } // Use ResetFormFields to clear the form data we previously used oTK.ResetFormFields(); // Populate form fields for the second page with data oTK.SetFormFieldData("name", "Jane Doe", 1); oTK.SetFormFieldData("date", "07/13/1988", -997); oTK.SetFormFieldData("amount", "1567.12", -997); // Copy the second page (with field data) to the new pdf intCopyForm = oTK.CopyForm(0, 0); if (intCopyForm != 1) { ErrorHandler("CopyForm", intCopyForm); } // Set whether to flatten all other fields not touched by SetFormFieldData oTK.FlattenRemainingFormFields = true; // Close the new file to complete PDF creation oTK.CloseOutputFile(); // Release Object oTK = null; // Process Complete System.Diagnostics.Debug.WriteLine("Done!"); } // Error Handling // Error messages written to debug output public static void ErrorHandler(string strMethod, object rtnCode) { System.Diagnostics.Debug.WriteLine(strMethod + " error: " + rtnCode.ToString()); } }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網