Skip to content

Breaking Changes and Missing Functionality in v4 Migration #33

@earthly-pixel

Description

@earthly-pixel

[Bug]: Regression in v4 migration - Missing scale(), pageBreakMode() issues, and margins() ignored

Description

After upgrading from Filament v3 to v4, several core configuration methods for Html2Media are either missing from the codebase or no longer functioning as they did in the previous version. This breaks existing PDF/Image generation workflows.


Technical Details

  • Filament Version: v4.x
  • Package Version: v2.1.2
  • PHP Version: 8.2

Identified Issues

1. Missing scale() Method

In v3, scale($n) was used to adjust the zoom/resolution. In v4, calling this method results in a:
BadMethodCallException: Call to undefined method ...::scale()
It appears the method was removed from the Traits (Concerns) during the refactor.

2. pagebreak() vs pageBreakMode()

The transition from pagebreak() to pageBreakMode() is currently undocumented. Furthermore, passing standard CSS values (e.g., 'avoid') to pageBreakMode() does not seem to trigger the expected behavior in the resulting output.

3. margins() Refactor

The change from margin() (singular) to margins() (plural) appears to have broken the data mapping to the underlying driver. Even when defined, the output uses default/zero margins.


Reproduction

Code Snippet

// Updated namespace
use Torgodly\Html2Media\Actions\Html2MediaAction;

// This implementation worked in v3 but fails/ignores settings in v4
Html2MediaAction::make('print')
        ->content(fn ($record, array $data) => view('page', ['record' => $record, 'data' => $data]))
        ->scale(2)                  // ERROR: Method does not exist
        ->pageBreakMode('avoid-all') // ISSUE: No effect on output
        ->margins(10, 10, 10, 10)    // ISSUE: Ignored by renderer
        ->savePdf()
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions