Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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和drupal将pdf转换为文本_Php_Drupal_Github_Shared Libraries_Pdftotext - Fatal编程技术网

使用php和drupal将pdf转换为文本

使用php和drupal将pdf转换为文本,php,drupal,github,shared-libraries,pdftotext,Php,Drupal,Github,Shared Libraries,Pdftotext,我正在使用pdf转换为文本,工作正常,但不支持瑞典语字符, 比如: 代码是: <?php require_once "pdf.pdf2text.inc"; $filename = "customerfile.pdf"; $pdf = new Pdf(urldecode($filename)); print utf8_decode($pdf->getText());//with utf-8 print $pdf->getText(); //

我正在使用pdf转换为文本,工作正常,但不支持瑞典语字符, 比如:

代码是:

<?php
    require_once "pdf.pdf2text.inc";
    $filename = "customerfile.pdf";
    $pdf = new Pdf(urldecode($filename));
    print utf8_decode($pdf->getText());//with utf-8
    print $pdf->getText(); //without utf-8
?>

我添加了utf-8编码/解码,但它不工作。

请任何人帮助我或建议我使用此代码显示正确的文本(单词)

提前感谢。

iconv()可能是一种可能性

$myUnicodeString=“ääö”;
echo iconv(“UTF-8”、“ISO-8859-1”、$MyUnicode销毁)正如一些评论所说
UTF-8_decode()不足以处理重音

根据Drupal.org上的评论:

在数组$pdfDocToUni第18行文件initialize.pdf2text.inc中添加所需字符的八进制和unicode等价物(请记住,八进制必须是3位数字,就像在数组的其他条目中一样)

然后只需转到pdf2text.module的第335行,并以与其他字符相同的格式添加您的字符

不确定“just”这个词的用法,但它可能会有所帮助

这似乎是他正在谈论的模块,它确实有他提到的阵列-也许您的版本可能缺少模块-似乎有很多模块在提供中


只是一个快速检查-您是在页面中还是在命令行中输出?如果是前者,是否设置了正确的内容类型?terförsäljaruppgifter实际上不是一个瑞典语单词。我想你的意思是återförsäljaruppgifter。如果你看pdf2text中的代码,不确定这是否有帮助。可能有一种方法可以添加一个函数,使其能够处理其他字符。如果你联系他们,也许它的作者会乐意帮忙。他们自己的笔记提供了处理德语“Umlaut”的方法——也许它也适用于瑞典语。从他们的Drupal pdf2test issues页面,按照@GrahamAsher,您可以在DOCTYPE下找到
<?php
    require_once "pdf.pdf2text.inc";
    $filename = "customerfile.pdf";
    $pdf = new Pdf(urldecode($filename));
    print utf8_decode($pdf->getText());//with utf-8
    print $pdf->getText(); //without utf-8
?>