PHPackages                             xslain/html2media - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. xslain/html2media

ActiveLibrary[Payment Processing](/categories/payments)

xslain/html2media
=================

Html2Media is a versatile Laravel package that allows users to convert HTML content into high-quality PDFs with options for either downloading or triggering a print dialog. Ideal for generating documents, invoices, and reports, this package includes configurable settings for file name, page orientation, format, margins, and scale. Html2Media provides seamless integration with Livewire components, enabling dynamic content rendering and customizable output previews. Whether you need to save a PDF or send it directly to the printer, Html2Media simplifies the process with robust, flexible features.

1.0.0(7mo ago)01MITPHPPHP ^8.1|^8.2|^8.3CI failing

Since Sep 23Pushed 7mo agoCompare

[ Source](https://github.com/ogoungaemmanuel/Html2Media)[ Packagist](https://packagist.org/packages/xslain/html2media)[ RSS](/packages/xslain-html2media/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

🌟 **Html2Media Livewire Component Documentation** 📄
===================================================

[](#-html2media-livewire-component-documentation-)

**Html2Media** is a powerful Laravel Livewire package that allows you to generate PDFs, preview documents, and directly print content from your application. 🚀

---

📌 **Overview**
--------------

[](#-overview)

The **Html2Media** package provides flexible Livewire components for your Laravel applications, enabling:

- 📑 **PDF Generation**: Convert HTML to a PDF and download it.
- 🖨️ **Direct Printing**: Print HTML content directly from the application.
- 👀 **Document Preview**: Preview the content before printing or exporting.

---

✨ **Features**
--------------

[](#-features)

- 🎨 **Customizable File Naming**: Define a custom name for the generated PDF.
- 🔍 **Preview &amp; Print Options**: Preview the content before printing or saving as a PDF.
- 📏 **Page Configuration**: Adjust page orientation, size, margins, and scaling.
- 🛠️ **Advanced PDF Options**: Control page breaks, hyperlink inclusion, and more.
- ⚡ **Livewire Integration**: Seamless integration with Livewire components and events.

---

🔧 **Installation**
------------------

[](#-installation)

To install the package, simply run the following command:

```
composer require xslain/html2media
```

After installation, publish the assets:

```
php artisan vendor:publish --tag=html2media-assets
```

The **Html2Media** components will be automatically registered with Livewire.

---

🚀 **Basic Usage**
-----------------

[](#-basic-usage)

### Method 1: Using the Livewire Component

[](#method-1-using-the-livewire-component)

You can use the Html2Media Livewire component directly in your Blade templates:

```
// In your Livewire component or controller
public function render()
{
    return view('your-view', [
        'record' => $this->record
    ]);
}
```

```

@livewire('html2media', [
    'record' => $record,
    'content' => view('your-pdf-template', ['record' => $record])
])
```

### Method 2: Using the Button Component

[](#method-2-using-the-button-component)

For a simple button that triggers PDF generation:

```
@livewire('html2media-button', [
    'record' => $record,
    'label' => 'Download Invoice',
    'content' => view('invoice-template', ['record' => $record])
])
```

### Method 3: Creating Custom Livewire Components

[](#method-3-creating-custom-livewire-components)

Create your own Livewire component that uses the Html2Media trait:

```
