在iOS中,如何以编程方式填写pdf表单字段? [英] In iOS, how can you programmatically fill out a pdf form field?

查看:82
本文介绍了在iOS中,如何以编程方式填写pdf表单字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取现有的pdf文件并以编程方式填写带有文本的表单字段列表,然后保存pdf而不将其显示给用户。

I need to take an existing pdf file and programmatically fill in a list of form fields with text and then save the pdf without ever displaying it to the user.

例如,如果pdf文件包含名为LastName和FirstName的字段,我想将FirstName的值设置为Louis,然后保存文件。

For instance, if the pdf file contains fields named "LastName", and "FirstName" I would like to set the value of "FirstName" to "Louis" and then save the file.

我一直在搜索很长时间,因为iOS文档(以及这里的大多数问题)似乎都是为了显示或创建pdf内容而不是修改它,所以无法找到任何指导。

I've been searching for a long time and can't find any guidance on even where to start since the iOS documentation (and most of the questions on here) seem geared towards displaying or creating pdf content instead of modifying it.

编辑:

我的主要问题是:是否可以打开pdf流(我知道怎么做这个)并将每个现有的pdf字典项复制到一个新的pdf中?我无法找到将字典项写入pdf的方法。


My main question is: Is it possible to open a pdf stream (I know how to do this) and copy each existing pdf dictionary item into a new pdf? I have not been able to find a way to write the dictionary items to a pdf.

推荐答案

我怀疑这种功能是否会曾经在iOS框架中。您可以找到的大多数相关信息似乎是为了显示或创建pdf内容而不是修改它,因为这是绝大多数用例对PDF功能所需要或需要的。

I doubt that kind of functionality will ever be in the iOS frameworks. The reason most of the related info you can find "seem[s] geared towards displaying or creating pdf content instead of modifying it" is because that's what the vast majority of use cases will want or need for PDF functionality.

您需要找到可以打开PDF的第三方库,填写AcroForm字段,然后标出PDF。我在Java上使用iText(还有用于C#的iTextSharp)但我不知道Objective-C的任何内容。

You'll need to find a 3rd party library that can open up PDFs, fill out the AcroForm fields, and then stamp out a PDF. I use iText on Java (there is also iTextSharp for C#) but I don't know of anything for Objective-C.

一旦找到该库,你就会需要将它集成到您​​的项目中。对于您正在使用的SDK的任何版本,毫无疑问,这里有几个相关的问题/答案。

Once you find that library, you'll need to integrate it into your project. There are undoubtedly several related questions/answers here on SO for whatever version of the SDK you're using.

这篇关于在iOS中,如何以编程方式填写pdf表单字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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