activePDF Toolkit使用教程:怎样实现创建和导出

概述:作为一款强大的生成修改工具,activePDF Toolkit能够实现一切PDF相关的功能。本文是关于创建和导出功能的示例介绍。

作为一款强大的PDF生成修改工具,activePDF Toolkit能够实现一切PDF相关的功能。本文是关于创建和导出功能的示例介绍。

》》》下载activePDF Toolkit试用版

代码如下:

// 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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值