使用PDF格式的FPDM设置复选框和单选按钮 [英] Setting checkboxes and radiobuttons with FPDM in PDF form

查看:757
本文介绍了使用PDF格式的FPDM设置复选框和单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过FPDM填写PDF表单,例如以下示例: http://www.fpdf.org/en/script/script93.php

I'm trying to fill out a PDF form through FPDM, like in this example: http://www.fpdf.org/en/script/script93.php

填写文本,日期,十进制,...输入可以正常工作,但是我找不到如何检查复选框和分组复选框(单选按钮)的方法.这是两个问题:

Filling out text, date, decimal, ... inputs works correctly, but I can't find out how to check checkboxes and grouped checkboxes (radio buttons). This are two problems:

  1. 复选框具有常规名称,例如"mycheck1".将PHP数组中的值设置为true"true""1"1"checked""on""yes"不会激活复选框(也区分大小写).我必须设置哪个值来激活复选框?
  2. 甚至找不到分组的复选框(单选按钮)-脚本引发错误"FPDF-Merge Error: field yourtype not found".正确的名字是什么? Adobe Acrobat Pro DC将名称"yourtype"显示为组中所有复选框的名称.在字段列表中,它将分组的复选框显示为"yourtype#0","yourtype#1","yourtype#2"等.但是脚本似乎无法找到任何此名称.我也尝试过"yourtype [1]"之类的运气不佳.一旦我可以访问它们,是否必须为其中之一设置值,还是直接分配(integer?)值?
  1. Checkboxes have a regular name, like "mycheck1". Setting the value in the PHP array to true or or "true" or "1" or 1 or "checked" or "on" or "yes" doesn't activate the checkboxes (case-sensitively tested too). Which value do I have to set to activate checkboxes?
  2. Grouped checkboxes (radio buttons) cannot even be found - the script throws the error "FPDF-Merge Error: field yourtype not found". What is the correct name? Adobe Acrobat Pro DC shows the name "yourtype" as the name for all checkboxes in the group. In the field-list it shows the grouped checkboxes as "yourtype#0", "yourtype#1", "yourtype#2", etc. But the script doesn't seem to be able to find any of this names. I also tried something like "yourtype[1]" without luck. And as soon as I can access them, do I have to set the value for one of them, or do I assign the (integer?) value just directly?

我的例子:

<?php
    require('fpdm.php');

    $fields = array(
    'forname' => 'Jon Dow',  // text input: works
    'mycheck1' => true,  // checkbox: doesn't work! Also tried "true", 1, "1", "yes", "on", ... (with case-sensitive)
    'yourtype' => true,  // grouped checkbox (radio button): doesn't even find input with that name.
    );

    $pdf = new FPDM('template.pdf');
    $pdf->Load($fields, true);
    $pdf->Merge();
    $pdf->Output();
?>

FPDM类似乎不支持设置某些类型,如复选框和下拉列表.在文件fpdm.php中,在ToDo部分下的标题中说以下内容:extends filling to another form fields types (checkboxes,combos..)

The FPDM class does not seem to support setting some types like checkboxes and dropdowns. In the file fpdm.php says the following in the header unter the ToDo section: extends filling to another form fields types (checkboxes,combos..)

推荐答案

好,我遇到了这个问题,一直在尝试使用FPDM来解决.复选框字段在Adobe Acrobat上具有导出"值,默认情况下为是",但根据语言或用户手动更改,它可以是另一个值. 如果随后在FPDM上分配了该值,则在下载并在Adobe的pdf阅读器中查看该复选框时,它将正确标记该复选框.但是,Web查看器似乎存在问题. Firefox会在复选框内显示以字符串形式覆盖的文本,而chrome根本无法显示任何复选框.这可能是我的问题,但是由于我只需要pdf阅读器支持,所以我没有做进一步的研究.

Ok I had this problem and have been trying to figure it out using FPDM. Checkbox fields have an Export value on Adobe Acrobat, this value is by default 'Yes' but it can be another value depending on language or if changed manually by the user. If the value is then assigned on FPDM it will mark the checkbox correctly when downloading it and viewing it in Adobe's pdf reader. However there seems to be problems with web viewers. Firefox will display the text overlayed as a string inside the checkbox, while chrome did not manage to display any check at all. It might be a problem on my side but since I only need the pdf reader support I did not do further research.

这篇关于使用PDF格式的FPDM设置复选框和单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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