概述:作为一款强大的生成修改工具,activePDF Toolkit能够实现一切PDF相关的功能。本文是关于创建和导出功能的示例介绍。
作为一款强大的PDF生成修改工具,activePDF Toolkit能够实现一切PDF相关的功能。本文是关于创建和导出功能的示例介绍。
代码如下:
// Copyright (c) 2013 activePDF, Inc. // Example created 01/03/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()); } }
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>