Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ZendPdf-setTextField西里尔字符编码_Php_Encoding_Pdf Generation - Fatal编程技术网

Php ZendPdf-setTextField西里尔字符编码

Php ZendPdf-setTextField西里尔字符编码,php,encoding,pdf-generation,Php,Encoding,Pdf Generation,我已应用此解决方案: 彼得·德涅夫。现在,我一直在努力对要填充的文本进行编码 基本上,我从Post参数读取文本,文本是西里尔文。无论我试图改变什么(我试图通过复制一些函数并将其应用于setTextField等来改变ZendFramework的Pdf.php中的编码),都没有任何效果。这是我的代码: $pdf = Zend_Pdf::load('reklam.pdf'); $pdf->setTextField("Text1", "Тест Инпут"); $pdf->setText

我已应用此解决方案:

彼得·德涅夫。现在,我一直在努力对要填充的文本进行编码

基本上,我从Post参数读取文本,文本是西里尔文。无论我试图改变什么(我试图通过复制一些函数并将其应用于setTextField等来改变ZendFramework的Pdf.php中的编码),都没有任何效果。这是我的代码:

$pdf = Zend_Pdf::load('reklam.pdf');
$pdf->setTextField("Text1", "Тест Инпут");
$pdf->setTextField("Text2", "Тест Инпут");
$pdf->setTextField("Text3", "Тест Инпут");
$pdf->save('outputfile.pdf');
输出文件中的文本不是人工文本

这是修改后的Pdf.php:

怎么办?请帮忙

提前谢谢

  • 确保您的字体包含所需的字符。显然,表单字段只考虑Acrobat表单字段属性中设置的字体设置,这意味着它独立于您在Zend中设置的字体
  • 如果是:这有助于我:

    public function setTextField($name, $value)
    {
    if (!isset($this->_formFields[$name])) {
        throw new Zend_Pdf_Exception(
            "Field '$name' does not exist or is not a textfield"
        );
    }
    
    /** @var Zend_Pdf_Element $field */
    $field = $this->_formFields[$name];
    $field->add(
        new Zend_Pdf_Element_Name('V'), 
    // you must set $font to one of the Zend_Pdf_Resource_Font objects
        new Zend_Pdf_Element_String($font->encodeString($value, 'UTF-8'))
    );
    $field->touch();
    }