从客户端JavaScript填写在scribus中创建的pdf表单 [英] Fill pdf form created in scribus from client side javascript

查看:85
本文介绍了从客户端JavaScript填写在scribus中创建的pdf表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个pdf表格,我想在其中填写javascript生成的密码,以便用户可以打印它.密码是敏感的,可能不会发送到服务器,因此必须在客户端javascript中进行.在此> 帖子中,可以使用Adobe Acrobat. >

这个想法是,创建一个具有唯一值的预填充表单,然后在生成最终的pdf显示给用户时,使用somple search替换该值,并用javascript替换.

由于我不拥有actobat,所以我想用 scribus 进行尝试.

我在scribus中生成了一个测试表单,并为其提供了预填充的值%HELLO%.但是,查看重新发布的pdf文件,我看不到我可以用简单的文本替换将%HELLO%值替换为密码.

解决方案

事实证明,这

代码还更新了pdf中的"xref",当pdf的长度发生变化(或某些元素在文件中的位置不同)时,该操作必须执行.由于我没有更改TextField值的长度,因此不必这样做.

I have a pdf form, into which I want to fill a password generated in javascript, so that the user can print it. The password is sensitive and may not be send to the server, so this has to happen in client side javascript. In this post it is possible using adobe acrobat.

The Idea is, that one creates a pre-filled form with a unique value, and than replaces that value using somple search and replace in javascript when generating the final pdf for displaying the user.

Since I do not own actobat, I thought I try it with scribus.

I generated a test form in scribus and gave it the prefilled value %HELLO%. But looking at the resuling pdf, I do not see that I can replace the %HELLO% value by the password with simple text replacement.

解决方案

It turns out, while this post already gives the answer in the code it does not explain it.

The value of TextField has to be converted to a sequence of hex-encoded unicode characters (so each 4 digits) and it has to start with "fffe". Using this string, one can do the search and replace in the pdf document.

The code also updates the "xref" in the pdf, which one has to do when the length of the pdf changes (or some elements are positioned different in the file). Since I did not change the length of the value of the TextField, I did not have to do that.

这篇关于从客户端JavaScript填写在scribus中创建的pdf表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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