配置 apache + PDFlib + wordpress
Config apache + PDFlib + wordpress
我在我的 apache 中安装 PDFlib 以便在我的 wordpress 应用程序中使用时遇到问题。
我按照教程做了 PHP
我还是做了下面的命令,因为我想到了另外一个安装的疑惑:
echo "katleia.com.br localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
它是 katleia.com。br/worpress 我在浏览器上设置的访问我页面的路径。
但是当我发出命令时:
service apache2 restart
这是下一个错误的出口:
* Restarting web server apache2 [fail]
* The apache2 configtest failed.
Output of config test was:
AH00526: Syntax error on line 1 of /etc/apache2/conf-enabled/fqdn.conf:
Invalid command 'katleia.com.br', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
有人可以帮我配置 PDFlib 吗?因为我花了大约四个小时试图让它在 wordpress 中工作,但没有什么可以纠正的。
我已经注意到不想安装 wordpress 插件。
更新
要撤消此命令:
echo "katleia.com.br katleia" | sudo tee /etc/apache2/conf-available/fqdn.conf
更新2
我设法让他停止报错,但还是不行。
为了能够重新启动服务器,我执行了以下命令:
echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
service apache2 restart
有了这个我的服务器恢复了工作,我将这段代码添加到一个 php 文件中,该文件以单击要测试的按钮命名:
try{
$pdf = new PDFlib();
} catch (Exception $e) {
echo "error: ".$e->getMessage()."<br>";
} finally {
// open a file
pdf_open_file($pdf, "test.pdf");
// start a new page (A4)
pdf_begin_page($pdf, 595, 842);
// get and use a font object
$arial = pdf_findfont($pdf, "Arial", "host", 1);
pdf_setfont($pdf, $arial, 10);
// print text
pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,",50, 750);
pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50,730);
// end page
pdf_end_page($pdf);
// close and save file
pdf_close($pdf);
}
他没有任何错误,但是当我尝试文件时找不到任何地方。
更新3
这个命令在理论上是为了得到一个输出,显示 PDFlib 是 运行,但是当我在我的提示下执行它时它没有显示任何内容:
# php -i |grep PDF
PDFlib
PDFlib Support => enabled
PDFlib GmbH Binary-Version => 7.0.5p3
我可以完成这部分工作但忘记添加 extension = pdf.so
文件 /etc/php5/cli/php.ini
。在我重新启动 apache 后,他给出了预期的输出。
但它仍然没有出现 test.pdf
任何地方。
更新4
try {
$p = new PDFlib();
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "hello.php");
$p->set_info("Author", "Rainer Schaaf");
$p->set_info("Title", "Hello world (PHP)!");
$p->begin_page_ext(595, 842, "");
$font = $p->load_font("Helvetica-Bold", "winansi", "");
$p->setfont($font, 24.0);
$p->set_text_pos(50, 700);
$p->show("Hello world!");
$p->continue_text("(says PHP)");
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=teste_do_katleia.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
$len = mb_strlen($buf, 'ASCII');
exit();
用上面的代码可以生成pdf并在网站上查看,但这不是我想要的。我想要的是将它保存在一个文件夹中,然后在另一个页面上恢复。
有谁知道我必须更改此代码才能执行此操作?
With the above code can generate a pdf and view it on the site, but that's not what I want. What I want is to save it in a folder
您应该检查 begin_document():
之前行中的注释
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
此外,您应该查看 PDFlib 7 教程,第 3.1.4 章 "Generating PDF Documents in Memory" 以了解更多详细信息。
提示:在光盘上创建文件时,不能使用get_buffer(),它会从内存中获取PDF 数据。 (请查阅 API 参考,它也包含在 doc 目录中的 PDFlib 7 包中)
我在我的 apache 中安装 PDFlib 以便在我的 wordpress 应用程序中使用时遇到问题。
我按照教程做了 PHP
我还是做了下面的命令,因为我想到了另外一个安装的疑惑:
echo "katleia.com.br localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
它是 katleia.com。br/worpress 我在浏览器上设置的访问我页面的路径。
但是当我发出命令时:
service apache2 restart
这是下一个错误的出口:
* Restarting web server apache2 [fail]
* The apache2 configtest failed.
Output of config test was:
AH00526: Syntax error on line 1 of /etc/apache2/conf-enabled/fqdn.conf:
Invalid command 'katleia.com.br', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
有人可以帮我配置 PDFlib 吗?因为我花了大约四个小时试图让它在 wordpress 中工作,但没有什么可以纠正的。
我已经注意到不想安装 wordpress 插件。
更新
要撤消此命令:
echo "katleia.com.br katleia" | sudo tee /etc/apache2/conf-available/fqdn.conf
更新2
我设法让他停止报错,但还是不行。
为了能够重新启动服务器,我执行了以下命令:
echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
service apache2 restart
有了这个我的服务器恢复了工作,我将这段代码添加到一个 php 文件中,该文件以单击要测试的按钮命名:
try{
$pdf = new PDFlib();
} catch (Exception $e) {
echo "error: ".$e->getMessage()."<br>";
} finally {
// open a file
pdf_open_file($pdf, "test.pdf");
// start a new page (A4)
pdf_begin_page($pdf, 595, 842);
// get and use a font object
$arial = pdf_findfont($pdf, "Arial", "host", 1);
pdf_setfont($pdf, $arial, 10);
// print text
pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,",50, 750);
pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50,730);
// end page
pdf_end_page($pdf);
// close and save file
pdf_close($pdf);
}
他没有任何错误,但是当我尝试文件时找不到任何地方。
更新3
这个命令在理论上是为了得到一个输出,显示 PDFlib 是 运行,但是当我在我的提示下执行它时它没有显示任何内容:
# php -i |grep PDF
PDFlib
PDFlib Support => enabled
PDFlib GmbH Binary-Version => 7.0.5p3
我可以完成这部分工作但忘记添加 extension = pdf.so
文件 /etc/php5/cli/php.ini
。在我重新启动 apache 后,他给出了预期的输出。
但它仍然没有出现 test.pdf
任何地方。
更新4
try {
$p = new PDFlib();
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "hello.php");
$p->set_info("Author", "Rainer Schaaf");
$p->set_info("Title", "Hello world (PHP)!");
$p->begin_page_ext(595, 842, "");
$font = $p->load_font("Helvetica-Bold", "winansi", "");
$p->setfont($font, 24.0);
$p->set_text_pos(50, 700);
$p->show("Hello world!");
$p->continue_text("(says PHP)");
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=teste_do_katleia.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
$len = mb_strlen($buf, 'ASCII');
exit();
用上面的代码可以生成pdf并在网站上查看,但这不是我想要的。我想要的是将它保存在一个文件夹中,然后在另一个页面上恢复。 有谁知道我必须更改此代码才能执行此操作?
With the above code can generate a pdf and view it on the site, but that's not what I want. What I want is to save it in a folder
您应该检查 begin_document():
之前行中的注释 /* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
此外,您应该查看 PDFlib 7 教程,第 3.1.4 章 "Generating PDF Documents in Memory" 以了解更多详细信息。
提示:在光盘上创建文件时,不能使用get_buffer(),它会从内存中获取PDF 数据。 (请查阅 API 参考,它也包含在 doc 目录中的 PDFlib 7 包中)