wpdesk/wpdesk-mpdf

This package is abandoned and no longer maintained. No replacement package was suggested.

Prefixed MPDF library for WP Desk plugins.

Maintainers

Details

gitlab.com/wpdesk/wpdesk-mpdf

Installs: 106

Dependents: 0

Suggesters: 0

Security: 0

pkg:composer/wpdesk/wpdesk-mpdf

This package has no released version yet, and little information is available.


README

Prefixed mPDF library for Flexible Invoices, Flexible Coupons, Print Orders & Labels

Current version: 8.0.6

Usage

<?php

namespace MyPluginPrefix;

use WPDesk\Mpdf\Mpdf;
use WPDesk\PDF\ConfigSample;
use WPDesk\PDF\FontsDataSample;

class PDF {

    public function render() {
        $config =  new ConfigSample();
        // Define a temporary path for mPDF.
        // Do not set a directory where other files exist!
        // Otherwise they will be deleted! 
        $config->set_temp_dir( dirname( __FILE__ ) . '/temp/' );
        
        // You can change the dir font by adding another one.
        // If you are changing the directory, move the default fonts into your project.
        $config->set_font_dir( [ dirname( __FILE__ ) . '/fonts/' ] );
        
        $fonts_data = new FontsDataSample();
        // Adds full font (bold, italic, regular)
        // The first argument is a slug that can be set to CSS, the second argument is the name of the .ttf file.
        $fonts_data->set_font( 'opensans', 'OpenSans' );
        
        // Adds a font without a bold file.
        $fonts_data->set_font_without_bold( 'rubik', 'Rubik' );
        
        // Adds a font without a italic file.
        $fonts_data->set_font_without_italic( 'rubik', 'Rubik' );
        
        // Adds a font without a bold and italic file.
        $fonts_data->set_font_without_bold_italic( 'rubik', 'Rubik' );
        
        // Set fonts data for mPDF.
        $config->set_font_data( $fonts_data->get()  );
        $mpdf = Mpdf( [ $config->get() ] );
        $mpdf->WriteHTML( '<h1>My PDF</h1>' );
        return $mpdf->Output( '', \WPDesk\Mpdf\Output\Destination::STRING_RETURN 
    }
    
}