Download the PHP package kukux/pdf-template-builder without Composer

On this page you can find all versions of the php package kukux/pdf-template-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pdf-template-builder

PDF Template Builder

Latest Version on Packagist Total Downloads License

Installation

1. Require the package

2. Publish and run the migrations

Upgrading from an earlier version? Re-publish and migrate — add_settings_to_pdf_templates_table adds the settings column that stores page margins. The builder degrades gracefully until you do: margins simply aren't persisted.

3. Publish assets

The builder UI is a React SPA bundled with Vite. The package ships pre-built JS in resources/dist/. Publish to public/:

Re-run this command after each package update to get the latest bundle.

This publishes two files: pdf-builder.js and pdf.worker.min.js, pdf.js's worker. Both must be served from your public/ — the canvas loads the worker same-origin so it always matches the bundled pdf.js API. If your host page also bundles pdf.js (a file previewer, say), a mismatched worker on globalThis would otherwise be picked up and every background render would fail with "API version … does not match the Worker version …".

The worker is published as .js although its contents are an ES module. pdf.js spawns it with { type: 'module' }, so the browser decides by Content-Type, and stock nginx has no mime.types entry for .mjs — it would serve application/octet-stream, which a module worker refuses.

For maintainers / contributors — to rebuild the bundle from JSX source:

ⓘ Filament v3 / v4 / v5 auto-detection

The plugin ships two parallel Resource implementations and aliases the canonical class name to the right one based on the Filament major version installed in your project.

Detected Class actually loaded
Filament v3 (no Filament\Schemas\Schema class) Kukux\PdfTemplateBuilder\Filament\Resources\V3\PdfTemplateResource
Filament v4 / v5 (Filament\Schemas\Schema exists) Kukux\PdfTemplateBuilder\Filament\Resources\V4\PdfTemplateResource

Detection happens in PdfTemplateBuilderServiceProvider::register() via class_alias, before Filament's panel resolves any resource. You always reference the canonical Kukux\PdfTemplateBuilder\Filament\Resources\PdfTemplateResource::class — never the V3/V4 variants directly.

If you ever see Class "Kukux\…\PdfTemplateResource" not found after upgrading, run composer dump-autoload. PSR-4 lookup needs to miss so the alias can be consulted, and a stale optimized classmap can short-circuit that.

4. Register the plugin in your Filament panel

In your PanelProvider (e.g. app/Providers/Filament/AdminPanelProvider.php):

5. Register your models (optional but recommended)

Configure the Eloquent models whose fields will appear in the builder sidebar:

Alternatively, configure them in config/pdf-template-builder.php after publishing the config:

Descriptor keys

Key Required What it does
label yes Heading shown above the field palette
icon no Palette icon name
class no Eloquent class, used when rendering
fields yes The draggable bound fields
relations no Grouped sub-field lists
background no Canvas backdrop when no background PDF is uploaded

background is a URL the canvas loads behind the fields — typically a route in your app that renders the blank form the template stamps onto, so a designer never has to upload one by hand. It is used only when the template has no uploaded background of its own.

The token {used_in} in that URL is replaced with the template's used_in value, letting one descriptor serve several variants of the same document:

A template tagged used_in = "ics" then loads /forms/blank?type=ics. Serve a PDF or an image — the canvas renders PDFs with pdf.js.

Embedding the builder in your own page

The builder reads everything from window.__PDF_BUILDER__, so any Filament page can host it: render pdf-template-builder::pages.edit-pdf-template with your own $builderConfig. Beyond the keys the template editor passes, four make the canvas editable against something other than a template:

Key What it does
saveUrl Where a save PUTs, instead of the template endpoint. Same payload shape
resetUrl DELETEd by the pdf-builder:reset event, then the page reloads
allowedKeys Field keys the palette is limited to; relations are hidden
mode 'placement' hides the Elements and Settings tabs — boxes move, the template is not edited

Enforce allowedKeys at your saveUrl too. It narrows the UI, not the request.

Your page renders its own header buttons; they reach the builder through DOM events — pdf-builder:save, pdf-builder:reset, pdf-builder:shortcuts and pdf-builder:preview. Skip Preview unless the record being edited really is a PdfTemplate, since it resolves the id against the template endpoint.

6. (Optional) Customize sidebar navigation

You can place the "PDF Templates" entry inside a Filament navigation group and control its sort order:

Or via the published config (config/pdf-template-builder.php):

Heads up — avoid this error

This is thrown when config('pdf-template-builder.navigation_group') resolves to null. To prevent it:

  • If you published the config before v1.2.0, open config/pdf-template-builder.php and change 'navigation_group' => null to 'navigation_group' => '' (or to your preferred group name).
  • Or set PDF_TEMPLATE_NAVIGATION_GROUP="" in your .env rather than leaving it unset.
  • Or call ->navigationGroup('') explicitly when registering the plugin.

The same applies if you override the value at runtime — always pass a string, never null.

7. (Optional) Configure storage

By default PDF backgrounds are stored on the public disk under pdf-templates/backgrounds/. Override via the plugin or .env:

Or via the plugin:


What gets added to your app

Using the builder

The page chrome — breadcrumbs, heading and the Shortcuts / Preview / Save template buttons — is rendered by Filament, so it inherits your panel's theme. Those buttons drive the React canvas through DOM events (pdf-builder:save, pdf-builder:preview, pdf-builder:shortcuts), which keeps the click client-side: the document being edited lives in the browser, so there is nothing for a Livewire round-trip to act on.

Canvas

Gesture Result
Scroll / ⇧+scroll Move through the document / sideways
⌘ or Ctrl + scroll, or trackpad pinch Zoom, anchored at the pointer
Space-drag, or middle-drag Pan
Drag on empty space Marquee-select
⇧+click Add to or remove from the selection
Alt-drag Clone the selection
⇧ while resizing Keep the aspect ratio
Alt while resizing Resize from the centre
Alt while dragging Ignore snapping
Right-click Context menu (element or page)

Elements snap to each other, to the page edges and centre, and to the margin box. Toggle snapping, rulers, the grid and the margin guides from the canvas toolbar.

Pages

Add, duplicate, reorder and delete pages from the thumbnail rail, the canvas toolbar, the strip under each page, or the right-click menu. Deleting a page removes its elements and shifts later pages up; if the page isn't empty you're asked to confirm first, and ⌘Z undoes it either way.

Keyboard shortcuts

Press ? in the builder for the full list. The everyday ones:

Keys Action
⌘S Save template
⌘Z / ⌘⇧Z Undo / redo
⌘C, ⌘X, ⌘V, ⌘D Copy, cut, paste, duplicate
⌫ Delete selection
⌘A / Esc Select all on page / deselect
← ↑ → ↓ Nudge 1 pt (⇧ for 10 pt)
⌘] / ⌘[ Bring forward / send backward (⇧ for front / back)
⌘0 / ⌘1 / ⌘2 Fit page / 100% / fit width
⌘+ / ⌘− Zoom in / out
R / G / S Rulers / grid / snapping
PgUp / PgDn Previous / next page
⌘⇧N / ⌘⇧⌫ Add / delete page
⌘⇧P Preview PDF

On Windows and Linux, Ctrl replaces ⌘.

Generating PDFs

1. Install a PDF engine (optional but recommended)

The plugin auto-detects dompdf/dompdf and uses it for output. Without it, render() falls back to HTML (browser print → save as PDF still works).

2. Drop a "Generate PDF" button into any Filament page

On a ViewRecord / EditRecord page (header action):

As a row action on a Resource table:

Dynamic template selection:

3. Programmatic rendering

4. Field token resolution

Fields placed in the builder have a key like invoice.number or customer.email. At render time:

5. Choosing a PDF engine

The plugin ships three engines. Pick based on your needs:

Engine When to use Requires
HtmlEngine (default fallback) Quick preview; user prints to PDF from browser. —
DompdfEngine (auto-detected) Generic HTML→PDF. Good for templates with no background or simple backgrounds. composer require dompdf/dompdf
FpdiEngine You uploaded a designed PDF as the background and want the original PDF preserved exactly. Stamps fields directly onto the original page. composer require setasign/fpdi tecnickcom/tcpdf

Wire your choice on the plugin:

You can also implement Kukux\PdfTemplateBuilder\Rendering\Contracts\PdfEngine (or TemplateAwarePdfEngine for non-HTML pipelines like Browsershot) and register your own.

6. Running the test suite

The package ships with Pest tests covering routes, the field resolver, the HTML renderer, the filename pattern, and basic model persistence. Run them after every change.

7. Authorization

Templates use a default-permissive PdfTemplatePolicy. Override it in your AuthServiceProvider:


All versions of pdf-template-builder with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
filament/filament Version ^3.0 || ^4.0 || ^5.0
illuminate/contracts Version ^11.0 || ^12.0
illuminate/database Version ^11.0 || ^12.0
illuminate/http Version ^11.0 || ^12.0
illuminate/routing Version ^11.0 || ^12.0
illuminate/support Version ^11.0 || ^12.0
spatie/laravel-package-tools Version ^1.15
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kukux/pdf-template-builder contains the following files

Loading the files please wait ...