简体   繁体   English

将另一个php网页转换为pdf并保存在服务器上,单击当前php页面上的按钮即可

[英]Convert another php webpage to pdf and save in server on button click from current php page

I am using PHP4.4. 我正在使用PHP4.4。 And want to convert some other webpage to PDF and save it in server on button click from my current PHP page. 并希望将其他网页转换为PDF并将其保存在服务器上,只需单击我当前PHP页面上的按钮即可。

There are many options available but all supports PHP > 5 version. 有许多选项可用,但都支持PHP> 5版本。

I want some API where if I will pass webpage URL and click on a button from my current webpage, then it should convert that webpage to PDF and save in server. 我想要一些API,如果我要传递网页URL并单击当前网页中的按钮,则它将该网页转换为PDF并保存在服务器中。

Please suggest some free version API. 请提出一些免费版本的API。 Already tried many options like wkhtmltopdf, FPDF, PDFJs etc.but nothing works as I am using PHP 4.4. 已经尝试了很多选项,例如wkhtmltopdf,FPDF,PDFJs等,但是没有任何效果,因为我使用的是PHP 4.4。

Mybe you help using Pdfcrowd . 也许您可以帮助使用 Pdfcrowd Simple example : 简单的例子:

require 'pdfcrowd.php';

try
{   
    // create an API client instance
    $client = new Pdfcrowd("username", "apikey");

    // convert a web page and store the generated PDF into a $pdf variable
    $pdf = $client->convertURI('http://example.com/');

    // set HTTP response headers
    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=\"created.pdf\"");

    // send the generated PDF 
    echo $pdf;
}
catch(PdfcrowdException $e)
{
    echo "Pdfcrowd Error: " . $e->getMessage();
}

Pdfcrowd is simple library end if you catch an exception you will change the library. Pdfcrowd是简单的库结尾,如果您捕获异常,则将更改库。 Mybe it's help you. 也许可以帮到您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM