原創(chuàng)|其它|編輯:郝浩|2013-01-07 13:56:56.000|閱讀 296 次
概述:activePDF Toolkit可以幫助用戶創(chuàng)建和管理pdf文件。該工具箱具有強(qiáng)大功能的API,使得對(duì)PDF 文件管理的任何自動(dòng)化操作成為可能,本文將要給出的是在PDF中添加批注的代碼示例。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
activePDF Toolkit是一個(gè)可擴(kuò)展的可編程的COM組件,它可以幫助用戶創(chuàng)建和管理PDF文件。該工具箱具有強(qiáng)大功能的API,使得對(duì)PDF文件管理的任何自動(dòng)化操作成為可能,比如用戶可以進(jìn)行追加,印戳,縫合,合并,噴繪,填充表格等一系列操作。
本教程將要給出的是在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()); } }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)