- Can I use magelan/htmltopdf-bundle in a Laravel application?
- No, this package is a Symfony bundle with no Laravel service provider, facade, publishable config file, or package auto-discovery. Installing it in a Laravel app will not register any routes, bindings, or configuration for you. Treat the repository as a reference implementation and wire the underlying HTML-to-PDF library yourself behind your own interface.
- How do I install magelan/htmltopdf-bundle?
- The typical path is composer require magelan/htmltopdf-bundle, followed by enabling the bundle in config/bundles.php for Symfony applications. Before installing, check composer.json for declared PHP and Symfony constraints and confirm the dependency graph resolves cleanly in a throwaway branch. Pin an exact version and commit hash rather than floating dev-master on a zero-star package.
- Which HTML-to-PDF library does this bundle wrap?
- The repository structure strongly suggests it wraps spipu/html2pdf, but you should confirm this directly in the bundle's composer.json and service definitions. The bundle itself is a thin Symfony integration layer, so the real rendering behavior, CSS fidelity, and security posture come from that underlying library. If you adopt anything, evaluate the wrapped library first and the bundle second.
- How do I configure page size, orientation, margins, and fonts?
- Configuration is handled through standard Symfony bundle settings via the DependencyInjection Extension and Configuration.php pair, typically in config/packages. That exposes page size, orientation, margins, fonts, default CSS, and the underlying binary path or options. In a Laravel app you would reproduce the same settings in a config/pdf.php file and bind a singleton in a service provider.
- How do I stream or download a PDF from a Symfony controller?
- Inject the bundle's conversion service into your controller, render a Twig template or raw HTML string to PDF, then return a Symfony streamed or binary response. Use a Content-Disposition header of attachment for downloads or inline for in-browser display. Keep this logic behind a small adapter class so the controller does not depend directly on the bundle.
- Does the bundle support Twig templates and raw HTML strings?
- Yes, the service API is designed to convert either Twig templates or plain HTML markup into PDF documents. In a Laravel context the equivalent pattern is to render a Blade view to a string and pass that string to the underlying renderer. Keep template rendering separate from PDF conversion so each piece remains testable.
- Is magelan/htmltopdf-bundle maintained and safe for production?
- The package shows zero stars, zero dependents, no issue history, and an effective bus factor of one, so there is no production signal to rely on. Composer constraints are unverified, and pinning old Symfony or PHP ranges can poison a modern lockfile and force ignore-platform-reqs. Plan on adopting or forking the underlying library rather than depending on this bundle directly.
- What Laravel alternatives should I use instead of this Symfony bundle?
- For Laravel, evaluate first-class options such as spatie/laravel-pdf, a knplabs/knp-snappy wrapper, spatie/browsershot, or a Gotenberg or headless Chrome client. Define a PdfRenderer interface in your domain layer first, then implement one candidate behind it. That interface is the real architectural decision, and it keeps a maintained alternative available as a swap-in.
- Is it safe to render user-supplied HTML to PDF with this package?
- Rendering untrusted HTML is a classic SSRF and local-file-inclusion surface, and this package provides no maintained upstream hardening you can rely on. Sanitize markup with a strict allowlist, block remote URLs and file paths, disable JavaScript, and run conversion in a sandboxed process or container. Any security controls are yours to write and test.
- What PHP and Symfony versions does this bundle require?
- The declared PHP and Symfony constraints are not verified here, so inspect composer.json before assuming compatibility. Resolve the graph in a throwaway branch against your real lockfile, and treat any need to loosen platform requirements as a stop signal. Also confirm font, locale, and CJK dependencies exist in the deployment image, not just on a developer laptop.