原創|其它|編輯:郝浩|2013-01-07 13:56:56.000|閱讀 296 次
概述:activePDF Toolkit可以幫助用戶創建和管理pdf文件。該工具箱具有強大功能的API,使得對PDF 文件管理的任何自動化操作成為可能,本文將要給出的是在PDF中添加批注的代碼示例。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
activePDF Toolkit是一個可擴展的可編程的COM組件,它可以幫助用戶創建和管理PDF文件。該工具箱具有強大功能的API,使得對PDF文件管理的任何自動化操作成為可能,比如用戶可以進行追加,印戳,縫合,合并,噴繪,填充表格等一系列操作。
本教程將要給出的是在PDF中添加批注的代碼示例。
示例代碼如下:
// Copyright (c) 2013 activePDF, Inc. // Example created 01/05/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 void main() { string strPath; int intOpenOutputFile; int intOpenInputFile; int intCopyForm; string strXMLData; strPath = AppDomain.CurrentDomain.BaseDirectory; // Instantiate Object APToolkitNET.Toolkit oTK = new APToolkitNET.Toolkit(); // This example will take a PDF and add a comment to it // then it will extract the comment from the new PDF // 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 + "PDF.pdf"); if (intOpenInputFile != 0) { ErrorHandler("OpenInputFile", intOpenInputFile); } // Add a comment to first page of the input PDF oTK.AddComment(72.0f, 660.0f, 144.0f, 100.0f, "Lorem Ipsum", "Test", 0, 128, "#BEBEBE", true, 1, "John Doe", "Lorem"); // Copy the template (with any changes) to the new file intCopyForm = oTK.CopyForm(0, 0); if (intCopyForm != 1) { ErrorHandler("CopyForm", intCopyForm); } // Close the new file to complete PDF creation oTK.CloseOutputFile(); // Open the PDF with a comment intOpenInputFile = oTK.OpenInputFile(strPath + "new.pdf"); if (intOpenInputFile != 0) { ErrorHandler("OpenInputFile", intOpenInputFile); } // Extract the comments as XML Data to a variable // Use the strXMLData variable to handle the XML data strXMLData = oTK.ExportComments(0); // Close the PDF input file oTK.CloseInputFile(); // Release Object oTK = null; // Process Complete System.Diagnostics.Debug.WriteLine("Done!"); } // Error Handling public static void ErrorHandler(string strMethod, object rtnCode) { System.Diagnostics.Debug.WriteLine(strMethod + " error: " + rtnCode.ToString()); } }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網