Download the PHP package manuxi/sulu-pdf-bundle without Composer

On this page you can find all versions of the php package manuxi/sulu-pdf-bundle. 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 sulu-pdf-bundle

SuluPdfBundle

php workflow symfony workflow License: MIT GitHub Tag Supports Sulu 3.0 or later

🇩🇪 Deutsche Version

PDF download for Sulu 3 content. The bundle renders the public page of an article, event or page, reduces it to its content and sets that into a designed PDF layout (logo, brand color, font, page numbers, QR code to the online version, optional company data). Nothing has to be built twice: every block template you already have keeps working, because the PDF is made from the rendered HTML.

How it works

  1. GET /pdf/{resourceKey}/{id}?locale=de looks up the profile for the resource key (articles, events, pages, ...). No profile or PDF switched off: 404.
  2. The public page is rendered through a sub-request.
  3. The rules of the profile (CSS selectors) pick title, header data, hero image, lead and main content. Scripts, forms, buttons, icons and carousel chrome are dropped, lazy images get their real URL, figures and galleries are rebuilt as tables (dompdf cannot lay out block images inside figure reliably).
  4. The content is set into @SuluPdf/document.html.twig and converted with dompdf. Logo, rule and footer with the page count are drawn on every page.

Requirements

Installation

Register the bundle in config/bundles.php (Symfony Flex does this for you):

Import the route, config/routes/sulu_pdf.yaml:

Link to the PDF in a template:

Configuration

config/packages/sulu_pdf.yaml, all keys are optional:

Paths are absolute or relative to the project directory.

Profiles

A profile says for one kind of content whether a PDF exists, with which options, and where the parts of its page are.

Articles (automatic)

Recommended: the switches in the excerpt tab (excerpt.articles: true, see below). Their default rules match the article templates of the reference theme (.article-main, .article-header, ...), other themes override them as shown above.

Legacy: with manuxi/sulu-article-configuration-bundle 1.4.x (and without excerpt.articles) the profile articles reads that bundle's own switches (tab "Configuration"). Version 2.0 of the article configuration bundle no longer has these fields, so with 2.x use excerpt.articles.

Switch in the excerpt tab (pages, articles, events)

adds a PDF section to the excerpt tab of that content, as its last section (download on/off, image captions, last-modified date, link/QR code, company data; articles also have the author box), and registers the profile (pages, articles, events) that reads these values. The switches use Sulu's own hook for extra excerpt fields (sulu_content.content_excerpt_form), so they are saved in the content's excerpt data: per language, and with the draft/publish workflow like any other content. Only the published version decides whether the download exists.

To show a link only where a PDF exists:

Profiles from config

Every profile with a resource_key in sulu_pdf.profiles offers a PDF for all resources of that key, with the options given there (show_captions, show_author, show_modified, show_online_link, company_data).

Profiles in PHP

Implement Manuxi\SuluPdfBundle\Profile\PdfProfileInterface and tag the service sulu_pdf.profile:

A profile can additionally implement Manuxi\SuluPdfBundle\Profile\PdfMetaProviderInterface (getMeta(string $id, string $locale): array) to print header lines from the content's own data, such as a date or a venue, in front of the entries the meta rule finds.

Rules

CSS selectors; single-part rules are searched inside root, the first match wins.

Rule Default Meaning
root body container that holds the header data
title h1 title (also removed from the content, the layout prints it)
overline, subtitle, lead - optional header texts (removed from the content when found inside it)
badges, meta - every match becomes one badge / one meta entry (removed from the content when found inside it)
hero - container of the hero image (printed once at the top)
main main the content; falls back to <main>, then <body>
gallery - container of a gallery: its pictures are printed in two columns
author - author box, removed when "author" is switched off
remove - more elements to drop; adds to the built-in list (nav, footer, scripts, ...)
exclude_figures - figures that keep their markup

Company data

The bundle has no company data of its own. Implement Manuxi\SuluPdfBundle\Service\CompanyDataProviderInterface (name, street, zip, city, phone, email, url), for example reading your organisation snippet, and set it as company_data_provider. The option company_data puts it into the footer of every page or into the closing box.

Customizing the layout

Override @SuluPdf/document.html.twig with templates/bundles/SuluPdfBundle/document.html.twig. dompdf understands CSS 2.1 only (no flexbox, grid, custom properties), so the layout is plain on purpose.

Good to know

Tests

License

MIT


All versions of sulu-pdf-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-dom Version *
ext-intl Version *
bacon/bacon-qr-code Version ^3.0
dompdf/dompdf Version ^3.1
doctrine/dbal Version ^3.6 || ^4.0
sulu/sulu Version ^3.0
symfony/css-selector Version ^6.4 || ^7.0
symfony/framework-bundle Version ^6.4 || ^7.0
symfony/string Version ^6.4 || ^7.0
symfony/twig-bundle Version ^6.4 || ^7.0
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 manuxi/sulu-pdf-bundle contains the following files

Loading the files please wait ...