spipu / html2pdf

OFFICIAL PROJECT | HTML to PDF converter written in PHP
http://html2pdf.fr/en/default
Open Software License 3.0
1.67k stars 746 forks source link

How to Install HTML2PDF on Wordpress #599

Open alejoblue opened 3 years ago

alejoblue commented 3 years ago

Hey there! I can't find a way to install html2pdf on a wordpress site. Is there a plugin or how can i do it manually?

After installation how can I make it work with Contact Form 7 plugin?

thanks in advanced

ghost commented 3 years ago

Just run the composer on your theme folder, then use the require command at the top of your functions.php

Then you should be able to use the class

GeoffreyOlivier commented 2 years ago

Hello, I tried but I have this error : Fatal error: Uncaught Error: Class 'Spipu\Html2Pdf\Html2Pdf' not found in C:\xampp\htdocs\wordpress\wp-content\plugins\agence\agence.php:12

There my code :

<?php
/**
 * Plugin Name: Agence Plugin
 */

use Spipu\Html2Pdf\Html2Pdf;

add_action('init', 'generate_pdf');
function generate_pdf()
{
    $html2pdf = new Html2Pdf();
    $html2pdf->writeHTML('<h1 style="color:pink;">CodeWall PDF</h1> <br/> <p>Convert this HTML to PDF please!</p>');
    $html2pdf->output('myPdf.pdf, F');
}

Thanks

GeoffreyOlivier commented 2 years ago

I juste missed to write this require_once 'vendor/autoload.php';

Bouquetin-fr commented 2 years ago

I juste missed to write this require_once 'vendor/autoload.php';

It did worked ?

I used the same code than you (I've just changed the path of require_once). It doesn't give a pdf file : https://zupimages.net/up/21/49/lj9n.png

GeoffreyOlivier commented 2 years ago

I don't think so ^^ I changed for Dompdf and it's work well.

Bouquetin-fr commented 2 years ago

^^ thanks