我可以使用批处理脚本在PDF文档中填写表单字段吗?

发布于 2025-02-13 09:37:07 字数 1551 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诺曦 2025-02-20 09:37:08

是的,您可以

“在此处输入图像描述”

结果

使用Acrobat有潜在的限制,并且最好使用其API,但是,我更喜欢Pdfxedit跟踪器,它也将对同一FDF表单文件的响应更好,尤其是允许保存,导入导出等。

“输入图像描述在这里”

您不需要像我所做的相同的方式构建相同的方式,而是像使用标头字符串和拖车字符串一样复杂或简单

%FDF-1.4
%âãÏÓ
1 0 obj
<<
/FDF <<
/F (AcroForm.pdf)
/Fields [<<

,理想地将数字更改为有效ID&lt; 16x2&gt; &lt; 16x2&gt;

>>]
/ID [<31323334353637383940414243444546> <31323334353637383940414243444546>]
/UF (AcroForm.pdf)
>>
/Type /Catalog
>>
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF

字段数据为A /TAG和 /值对,每个对都必须通过&gt;&gt; &lt;&lt;
(字面文字)是括号的。有可能将位图用作文本和其他嵌入的可能性,但这超出了此概念证明。

/T (CheckBox1)/V /On
>> <<
/T (TestTextBox)/V (The quick brown fox jumped over the lazy form.)

有关更复杂的案例,请参见 https://stackoverflow.com/a/a/72547163/72547163/10802527

现在您需要完成该过程用新名称保存文件,该名称取决于您选择的FDF应用程序。 Windows的前三个应用程序都可以由批处理文件键盘宏来驱动,因为我们避免了鼠标选择字段的任何需求。对于pdfxchange,它将开始像alt+f+a+b+“ filepath \ name.pdf”

使用香草CMD我们可以编写一个vbs脚本或更易于使用 sendkeys.exe 运行集中序列(再次超出一个简短答案的范围)但是,对于 xchange (/关闭[:[mode =]保存|丢弃|问]),我认为 foxit 他们有自己的命令行 /API方法。

最好是通过管道DDE完成命令,因为它更容易说打开的FDF和关闭PDF,但是这些方法似乎通常会折旧,而在唯一的三个Acrobat仍然可以使用它们。

Yes you can

enter image description here

Result

enter image description here

There are potential restrictions using Acrobat, and its better to use their API, however, I prefer PDFXedit from Tracker, which will also respond better to that same FDF form File especially allowing for saving, import export etc.

enter image description here

You dont need to build the same way I did but its as complex or as simple as use a header string

%FDF-1.4
%âãÏÓ
1 0 obj
<<
/FDF <<
/F (AcroForm.pdf)
/Fields [<<

and a trailer string, ideally change the number as a valid ID <16x2> <16x2>

>>]
/ID [<31323334353637383940414243444546> <31323334353637383940414243444546>]
/UF (AcroForm.pdf)
>>
/Type /Catalog
>>
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF

The Field data is a /Tag and /Value pair and each must be separated by >> <<
and (literal text) is bracketed. There are possibilities to use bitmaps as text, and other embedment's, but that's way beyond this Proof Of Concept.

/T (CheckBox1)/V /On
>> <<
/T (TestTextBox)/V (The quick brown fox jumped over the lazy form.)

For a more complex case see https://stackoverflow.com/a/72547163/10802527

Now to complete the process you need to save the file with a new name which will depend on your choice of FDF application. The top three apps for windows can all be driven by batch file keyboard macros, since we have avoided any need for mouse selection of fields. For PDFXchange it would start like ALT+F+A+B+"Filepath\name.pdf"

Using vanilla cmd we can write a vbs script or easier use sendkeys.exe to run the focused sequence (again beyond the scope of a short answer) but for Xchange (/close[:[mode=]save|discard|ask]) and I think Foxit they have their own command line /api methods.

Preferably the commands should be done via piped DDE as easier to say open FDF and close PDF but those methods seem to generally be depreciated and of the three only Acrobat may still use them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文