如果您想让 iPad 应用程序识别 pdf 中的文本字段、按钮、链接。您可以编辑实际的 pdf(您需要一个 Adobe Acrobat 版本)并将这些字段添加到 pdf 中。在您的 ios 代码中,使用以下内容解析 pdf 字段:
在解析方法中:
-(void)parse:(CGPDFPageRef)page
{
for (int i = 0; i < CGPDFArrayGetCount (annotations); i++)
CGPDFArrayGetCount 返回 PDF 数组中的项目数。
在循环中获取字段名称:
if (CGPDFDictionaryGetString(dict, "T", &stringRef))
{
char *s = (char *) CGPDFStringGetBytePtr(stringRef);
fieldName = [NSString stringWithCString:s encoding:NSUTF8StringEncoding];
}
如果字段名称匹配,例如“button_1”或“hlink_3”,请检查您想要做什么:
if ([fieldName isEqualToString:@"hlink_3"])
{
// do whatever, example add a button where the field was
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = rect;
[self addSubview:button];
}
它还有很多内容,但这是一般的想法。