pdf表格填写 [英] pdf form fill

查看:66
本文介绍了pdf表格填写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了各种adobe sdk,但都没有成功;表单工具箱中的adobe reader控件具有最佳性能.但是唯一的API是

I have tried out various adobe sdk's with no success; the best performance has bee the adobe reader control in the forms toolbox. But the only API is

axAcroPDF1.LoadFile(FORM_NAME)

axAcroPDF1.LoadFile(FORM_NAME)

我们希望将此API扩展为包括

we would like this API to be extended to include

a)打开并阅读pdf文件

a) pdf file open and read

b)从pdf文件中获取字段

b) getfieldsfrompdffile

c)fillfieldvalue

c) fillfieldvalue

d)pdf文件的写入和关闭

d) pdf file write and close

因此,如果有一种方法可以将axAcroPDFLib扩展为包括这些功能,则将是一项有价值的增强功能.由于adobe独立于Visual Studio,因此库所做的更改应适用于所有版本的Visual Studio.使用旧版本 VS添加.csproj以引用增强功能是更好的解决方案.

So if there is a way to expand axAcroPDFLib to include these functions - would be a valuable enhancement. Since adobe is independent of Visual Studio the library  changes should be applicable to all versions of Visual Studio. With the older versions of VS adding a .csproj to reference the enhancements is the better solution.

推荐答案

这里是免费的pdf 提供的替代解决方案. dll ,您可以尝试一下.

Here is an alternative solution offered by a free pdf dll, you could give it a try.

//Load the PDF document
        PdfDocument document = new PdfDocument();
        document.LoadFromFile("Input.pdf");
        //Load the existing forms 
        PdfFormWidget loadedForm = document.Form as PdfFormWidget;

        //Go through the forms
        for (int i = 0; i < loadedForm.FieldsWidget.List.Count; i++)
        {                
            PdfField field = loadedForm.FieldsWidget.List[i] as PdfField;
            //Fill textbox form field
            if (field is PdfTextBoxFieldWidget)
            {
                PdfTextBoxFieldWidget textField = field as PdfTextBoxFieldWidget;
                //Get the field name and fill with content
                switch (textField.Name)
                {
                    case "fieldName":
                        textField.Text = "text";
                        break;
                    //```
                }
            }
        }
        //Save and close
        document.SaveToFile("Output.pdf");
        document.Close();

或者您可以使用文件名直接访问文件.

Or you can access the filed directly using its name.

PdfDocument doc = new PdfDocument();
doc.LoadFromFile("Input.pdf");
var form = doc.Form as PdfFormWidget;                      
var campoText = form.FieldsWidget["fieldName"] as PdfTextBoxFieldWidget;
campoText.Text = "text";
doc.SaveToFile("Output.pdf", FileFormat.PDF);

希望我的回答有帮助.

Hope my answer helps.


这篇关于pdf表格填写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆