PHPackages                             institut-agro-ead/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. institut-agro-ead/html2media

ActiveLibrary[Payment Processing](/categories/payments)

institut-agro-ead/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 also provides seamless integration with Filament actions, enabling dynamic content rendering in modals 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.

v1.0.3(10mo ago)014MITPHPPHP ^8.1

Since Mar 27Pushed 10mo agoCompare

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

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

🌟 **Html2Media Filament Action Documentation** 📄
================================================

[](#-html2media-filament-action-documentation-)

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

---

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

[](#-overview)

The **Html2MediaAction** provides a set of flexible actions for your Filament resources, 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 in a modal 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.

---

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

[](#-installation)

To install the package, simply run the following command:

```
composer require torgodly/html2media
```

Once installed, the **Html2MediaAction** can be used within your Filament resources or tables.

---

⚙️ **Configuration Methods**
----------------------------

[](#️-configuration-methods)

Here’s how you can customize your **Html2MediaAction**!

### 1. 📂 `filename()`

[](#1--filename)

Set the name of the generated PDF file. ✍️

**Usage**:

```
Html2MediaAction::make('print')
    ->filename('my-custom-document')
```

- 🏷️ **Default**: `'document.pdf'`
- 🔠 **Accepts**: `string` or `Closure`

---

### 2. 📄 `pagebreak()`

[](#2--pagebreak)

Define page break behavior. Customize how and where page breaks occur within the document. 🛑

**Usage**:

```
Html2MediaAction::make('print')
    ->pagebreak('section', ['css', 'legacy'])
```

- 🔄 **Default**: `['mode' => ['css', 'legacy'], 'after' => 'section']`
- 🛠️ **Accepts**:

    - `mode`: Array of strings (`['avoid-all', 'css', 'legacy']`)
    - `after`: Element ID, class, tag, or `*` for all elements.
    - `avoid`: (Optional) Element ID, class, or tag to avoid page breaks.
- 📖 **More info on page breaks**: [here](https://ekoopmans.github.io/html2pdf.js/#page-breaks).

---

### 3. 🔄 `orientation()`

[](#3--orientation)

Set the page orientation for the PDF, either **portrait** or **landscape**. 🖼️

**Usage**:

```
Html2MediaAction::make('print')
    ->orientation('landscape')
```

- 🏷️ **Default**: `'portrait'`
- 🔠 **Accepts**: `string` (`'portrait'`, `'landscape'`) or `Closure`

---

### 4. 📐 `format()`

[](#4--format)

Define the format of the PDF, including standard sizes like A4 or custom dimensions. 📏

**Usage**:

```
Html2MediaAction::make('print')
    ->format('letter', 'in')
```

- 🏷️ **Default**: `'a4'`
- 🔠 **Accepts**: `string`, `array` (e.g., `[width, height]`), or `Closure`

---

### 5. 🔗 `enableLinks()`

[](#5--enablelinks)

Enable or disable automatic hyperlink conversion in the PDF. 🔗

**Usage**:

```
Html2MediaAction::make('print')
    ->enableLinks()
```

- 🏷️ **Default**: `false`
- 🔠 **Accepts**: `bool` or `Closure`

---

### 6. 🔧 `scale()`

[](#6--scale)

Adjust the scaling factor for HTML to PDF conversion. 🔍

**Usage**:

```
Html2MediaAction::make('print')
    ->scale(2)
```

- 🏷️ **Default**: `2`
- 🔠 **Accepts**: `int` or `Closure`

---

### 7. 🖨️ `print()`

[](#7-️-print)

Enable or disable the print button in the modal. 🖨️

**Usage**:

```
Html2MediaAction::make('print')
    ->print(true)
```

- 🏷️ **Default**: `true`
- 🔠 **Accepts**: `bool` or `Closure`

---

### 8. 👁️ `preview()`

[](#8-️-preview)

Enable a preview option for the document content before printing or saving. 👀

**Usage**:

```
Html2MediaAction::make('print')
    ->preview()
```

- 🏷️ **Default**: `false`
- 🔠 **Accepts**: `bool` or `Closure`

---

### 9. 💾 `savePdf()`

[](#9--savepdf)

Enable the option to directly save the content as a PDF. 💾

**Usage**:

```
Html2MediaAction::make('print')
    ->savePdf()
```

- 🏷️ **Default**: `false`
- 🔠 **Accepts**: `bool` or `Closure`

---

### 10. ✅ `requiresConfirmation()`

[](#10--requiresconfirmation)

Show a confirmation modal before performing the action. 🛑

**Usage**:

```
Html2MediaAction::make('print')
    ->requiresConfirmation()
```

- 🏷️ **Default**: `true`
- 🔠 **Accepts**: `bool` or `Closure`

---

### 11. 💻 `content()`

[](#11--content)

Set the content for the document. Typically, you’ll pass a Blade view for the content. 📝

**Usage**:

```
Html2MediaAction::make('print')
    ->content(fn($record) => view('invoice', ['record' => $record]))
```

- 🔠 **Accepts**: `View`, `Htmlable`, or `Closure`

---

🎨 **Example Usage**
-------------------

[](#-example-usage)

Here’s a complete example of configuring the **Html2MediaAction**:

```
Html2MediaAction::make('print')
    ->scale(2)
    ->print() // Enable print option
    ->preview() // Enable preview option
    ->filename('invoice') // Custom file name
    ->savePdf() // Enable save as PDF option
    ->requiresConfirmation() // Show confirmation modal
    ->pagebreak('section', ['css', 'legacy'])
    ->orientation('portrait') // Portrait orientation
    ->format('a4', 'mm') // A4 format with mm units
    ->enableLinks() // Enable links in PDF
    ->margin([0, 50, 0, 50]) // Set custom margins
    ->content(fn($record) => view('invoice', ['record' => $record])) // Set content
```

This configuration will:

- 📄 Generate a PDF from the `invoice` Blade view.
- 🖨️ Allow users to `preview` and `print` the document.
- 💾 Enable `saving as PDF` and show a confirmation modal before executing.
- 📏 Set A4 format with portrait orientation.
- 🔗 Enable links and set custom margins.

---

📊 **Filament Action or Table Action**
-------------------------------------

[](#-filament-action-or-table-action)

You can use the **Html2MediaAction** in the same way, whether it's in a Filament table action or a regular action. Simply import the appropriate class:

```
use Torgodly\Html2Media\Actions\Html2MediaAction;
use Torgodly\Html2Media\Tables\Actions\Html2MediaAction;
```

This makes the action flexible and usable in various contexts. 🌍

---

⚡ **Quick Example: Direct Print or Save as PDF**
------------------------------------------------

[](#-quick-example-direct-print-or-save-as-pdf)

1. **For direct printing**:

```
Html2MediaAction::make('print')
    ->content(fn($record) => view('invoice', ['record' => $record]))
```

This will directly open the print dialog for the HTML content. 🖨️

2. **For saving as PDF**:

```
Html2MediaAction::make('print')
    ->savePdf()
    ->content(fn($record) => view('invoice', ['record' => $record]))
```

This will save the HTML content as a PDF. 💾

---

🏁 **Conclusion**
----------------

[](#-conclusion)

The **Html2Media** package for Filament makes it easy to generate PDFs, preview documents, and print content directly from your Laravel app. With flexible configuration options, you can tailor it to your specific needs, ensuring smooth document handling. ✨

We hope this documentation helps you get started quickly. 🚀 Happy coding! 🎉

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance55

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~27 days

Total

4

Last Release

327d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/da34b396e31dc456a9f4e77ba237053c77a76c2c53bd4e307a0ffdf86884cd11?d=identicon)[ia-ead](/maintainers/ia-ead)

---

Top Contributors

[![torgodly](https://avatars.githubusercontent.com/u/57685643?v=4)](https://github.com/torgodly "torgodly (14 commits)")[![institut-agro-ead](https://avatars.githubusercontent.com/u/126262543?v=4)](https://github.com/institut-agro-ead "institut-agro-ead (6 commits)")

---

Tags

laravelpdfreportinginvoicefilamentprintingdocumentshtml-to-pdfpdf-generation

### Embed Badge

![Health badge](/badges/institut-agro-ead-html2media/health.svg)

```
[![Health](https://phpackages.com/badges/institut-agro-ead-html2media/health.svg)](https://phpackages.com/packages/institut-agro-ead-html2media)
```

###  Alternatives

[torgodly/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 also provides seamless integration with Filament actions, enabling dynamic content rendering in modals 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.

4532.5k1](/packages/torgodly-html2media)[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.5k1.3M4](/packages/laraveldaily-laravel-invoices)[anam/phantommagick

PhantomMagick provides a simple API to ease the process of converting HTML to PDF or images

161456.4k2](/packages/anam-phantommagick)[maartenpaauw/filament-cashier-billing-provider

Filament billing provider for Laravel Cashier

10228.1k](/packages/maartenpaauw-filament-cashier-billing-provider)[tomatophp/filament-payments

Manage your payments inside FilamentPHP app with multi payment gateway integration

542.3k](/packages/tomatophp-filament-payments)[andreia/filament-stripe-payment-link

Filament action to generate a Stripe payment link

141.9k](/packages/andreia-filament-stripe-payment-link)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
