- How do I install rmscms/pdf in a Laravel application?
- Install it with Composer using composer require rmscms/pdf. In Laravel, the package's service provider and facade are typically discovered automatically; if your app does not use package discovery, register them as documented. Publish the configuration file with vendor:publish so project-wide PDF defaults can be stored in config. Then set your page size, orientation, and margins before generating documents.
- What is rmscms/pdf used for in a Laravel app?
- It is intended for Laravel and RMS CMS applications that need printable output, reports, invoices, exports, or downloadable documents. You can render Blade templates, HTML, or raw strings and return the result as a stream or download, or save it to disk. The fluent API keeps document setup readable inside controllers, services, or jobs.
- How do I create a PDF from a Blade view with rmscms/pdf?
- Pass the Blade view name and its data to the package's fluent API, then choose whether to stream, download, or save the generated PDF. The view is rendered through Laravel's normal view system, so layouts, partials, and Blade syntax work as expected. Keep PDF-specific CSS inline or in a dedicated stylesheet to avoid layout surprises.
- Can rmscms/pdf render raw HTML or plain strings?
- Yes. The package supports Blade views, HTML, and raw strings, so you can generate a PDF from markup produced by a CMS, an editor, or a reporting service. This is useful when the document is not backed by a Blade template or when HTML comes from stored content.
- How do I set page size, orientation, and margins in rmscms/pdf?
- Publish the package configuration and define default page size, orientation, and margins once for the application. The fluent API can then apply those defaults to each document, with per-document overrides where the package exposes them. Keeping defaults in config avoids repeating the same settings in every controller.
- How do I stream, download, or save a PDF to disk with rmscms/pdf?
- The package provides fluent output options for streaming the PDF to the browser, downloading it as a response, or saving it to disk. For saved files, use a Laravel storage disk and ensure the target directory is writable by the web server or queue worker. Streaming and downloading should return proper response headers so browsers handle the file correctly.
- Does rmscms/pdf support facades and dependency injection?
- Yes. rmscms/pdf integrates with Laravel's service container and provides facade and dependency-injection support. You can resolve the PDF service in a controller or inject it into a service class, which makes testing and composition easier. Use the facade for short controller actions and constructor injection for reusable services.
- Which Laravel and PHP versions does rmscms/pdf support?
- Laravel and PHP version support is defined by the package's Composer constraints, so check its composer.json or Packagist entry before upgrading. Because it relies on Laravel's service container, configuration, and view system, confirm compatibility with your framework major version. If you are on an older Laravel release, verify that the package's illuminate dependencies allow it.
- How should I test PDF generation with rmscms/pdf in Laravel?
- Test the surrounding Laravel flow by asserting the response status, content type, and download or stream headers, and use Storage::fake when the PDF is saved to disk. Render a small fixture Blade view so tests catch template and configuration errors without depending on complex production views. If you inject the PDF service, you can resolve it from the container in feature tests; check the package docs for any dedicated testing helpers.
- What are alternatives to rmscms/pdf, and what should I check for maintenance?
- Common alternatives include barryvdh/laravel-dompdf, mPDF, TCPDF, Snappy or wkhtmltopdf wrappers, and Browsershot for CSS or JavaScript-heavy layouts. Evaluate rmscms/pdf's maintenance by checking its Packagist release history, Composer constraints, open issues, and compatibility with your Laravel version. For production, also consider font support, memory use for large reports, binary dependencies, and where generated files are stored.