简体   繁体   English

在xampp上安装mikehaertl-phpwkhtmltopdf-傻瓜

[英]Installation of mikehaertl-phpwkhtmltopdf on xampp - for dummies

I've tried to use this post: How do I get WKHTMLTOPDF to execute via PHP? 我尝试过这篇文章: 如何使WKHTMLTOPDF通过PHP执行? but I'm missing something. 但我想念一些东西。

I'm hoping for a real dummies guide here... 我希望在这里找到真正的假人指南...

Installing mikehaertl-phpwkhtmltopdf on windows/xampp/codeigniter 在Windows / xampp / codeigniter上安装mikehaertl-phpwkhtmltopdf

  1. Acquire and install wkhtmltopdf. 获取并安装wkhtmltopdf。 This will typically install to C:\\program files\\wkhtmltopdf\\lib or similar on windows. 这通常会安装到Windows上的C:\\ program files \\ wkhtmltopdf \\ lib或类似文件中。
  2. Acquire and unpack Mikehaertl's wrapper (eg wkhtmltox-win64_0.12.0-03c001d) 获取并解压缩Mikehaertl的包装器(例如wkhtmltox-win64_0.12.0-03c001d)
  3. Place the WkHtmlToPdf.php file in ??????? 将WkHtmlToPdf.php文件放在???????
  4. Do I edit the WkHtmlToPdf.php file and put in 是否编辑WkHtmlToPdf.php文件并放入
    • the binPath (C:\\program files\\wkhtmltopdf\\lib) ???? binPath(C:\\ program files \\ wkhtmltopdf \\ lib) ????
    • the output folder ???? 输出文件夹????
  5. Now test it with 现在用

     shell_exec("c:/programs/wkhtmltopdf/wkhtmltopdf.exe http://www.google.com c:/google.pdf"); 

As I may have mentioned... the real dummies guide. 正如我可能已经提到过的...真正的虚拟人指南。 :( :(

(Old question I know, but spent a fair bit of time figuring out his example as well :|) (我知道这个老问题,但是花了很多时间来弄清楚他的例子:|)

1) Install wkhtmltopdf (for the Bin files) and Mike's files @ https://github.com/mikehaertl/phpwkhtmltopdf 1)安装wkhtmltopdf (用于Bin文件)和Mike的文件@ https://github.com/mikehaertl/phpwkhtmltopdf

2) Copy all of wkhtmltopdf & Mike's files to a desired location in your codeigniter folder. 2)将所有wkhtmltopdf和Mike的文件复制到codeigniter文件夹中的所需位置。

3) To recreate Mikes example, you can create his demo.html (or use an actual link) and pdf.css (no css will also work), however in his php example, you'll be calling on, the first few lines go like this (he subtly mentions these requirements in the documentation): 3)要重新创建Mikes示例,您可以创建他的demo.html(或使用实际链接)和pdf.css(没有css也将起作用),但是在他的php示例中,您将在前几行中调用像这样(他在文档中巧妙地提到了这些要求):

require_once('WkHtmlToPdf.php'); // link to where you placed Mike's WkHtmlToPdf.php


// Create a new WKHtmlToPdf object with some global PDF options
$pdf = new WkHtmlToPdf(array(
'binPath' => '/wkhtmltopdf/bin/wkhtmltopdf.exe', // link to where placed your bin files

 ... // rest of code

 $pdf->addPage('demo.html'); // or something like $pdf->addPage('http://google.com');
 $pdf->send();
 // or $pdf->saveAs('/save/to/see/your/new.pdf'); 

Hope that helps 希望能有所帮助

The real reason I was looking for this dummies guide, was that I wanted a way to generate a PDF from my PHP app. 我寻找该虚拟指南的真正原因是,我想要一种从PHP应用程序生成PDF的方法。

Whilst trying to find any solution to this particular (mikehaertl-phpwkhtmltopdf) component, I came across another one called fpdf, which can be found at http://www.fpdf.org/ 在尝试找到针对此特定(mikehaertl-phpwkhtmltopdf)组件的任何解决方案时,我遇到了另一个名为fpdf的组件,可以在http://www.fpdf.org/上找到它

This was painless. 这很轻松。

  1. Download FPDF (v1.7 2011-06-18) ZIP file 下载FPDF(v1.7 2011-06-18)ZIP文件
  2. Unzip 拉开拉链
  3. Copy everything into /php/fpdf17 in your IDE 将所有内容复制到您的IDE中的/ php / fpdf17中
  4. in your Controller create a function like this: 在Controller中创建如下函数:

     function PDF() { require('fpdf17/fpdf.php'); $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output(); } 
  5. Call your function. 调用您的函数。

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

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