彩票走势图

activePDF Toolkit使用教程:基本表格填充

原创|其它|编辑:郝浩|2013-02-01 13:35:57.000|阅读 264 次

概述:通过activePDF Toolkit,终端用户可以互动式地完成PDF表格填充。简单地输入需要的信息,然后点击提交即可。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

通过activePDF Toolkit,终端用户可以互动式地完成PDF表格填充。简单地输入需要的信息,然后点击提交即可。这样数据就会无缝地传输到你指定的区域。本地存储到表格或者离线内存里。除了互动的表格填充, Toolkit还能由程序自动填充表格框,同时允许你用任意来源的文字和图片填充PDF表格和模板。

》》》下载activePDF Toolkit试用版

示例代码如下:

 

// 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@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP