html2pdf mit composer hinzugefügt

This commit is contained in:
aschwarz 2023-02-16 09:19:46 +01:00
parent 3dcc93a65d
commit d1ab7f3763
613 changed files with 134681 additions and 0 deletions

5
composer.json Normal file
View File

@ -0,0 +1,5 @@
{
"require": {
"spipu/html2pdf": "^5.2"
}
}

148
composer.lock generated Normal file
View File

@ -0,0 +1,148 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "adc3c21f0c2f3a68b1c345a61a27b0d5",
"packages": [
{
"name": "spipu/html2pdf",
"version": "v5.2.7",
"source": {
"type": "git",
"url": "https://github.com/spipu/html2pdf.git",
"reference": "b0f477711de3052041072897510e690975aa37ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spipu/html2pdf/zipball/b0f477711de3052041072897510e690975aa37ce",
"reference": "b0f477711de3052041072897510e690975aa37ce",
"shasum": ""
},
"require": {
"ext-gd": "*",
"ext-mbstring": "*",
"php": "^5.6 || ^7.0 || ^8.0",
"tecnickcom/tcpdf": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^9.0"
},
"suggest": {
"ext-gd": "Allows to embed images into the PDF",
"fagundes/zff-html2pdf": "if you need to integrate Html2Pdf with Zend Framework 2 (zf2)"
},
"type": "library",
"autoload": {
"psr-4": {
"Spipu\\Html2Pdf\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"OSL-3.0"
],
"authors": [
{
"name": "Spipu",
"homepage": "https://github.com/spipu",
"role": "Developer"
}
],
"description": "Html2Pdf is a HTML to PDF converter written in PHP5 (it uses TCPDF). OFFICIAL PACKAGE",
"homepage": "http://html2pdf.fr/",
"keywords": [
"html",
"html2pdf",
"pdf"
],
"support": {
"issues": "https://github.com/spipu/html2pdf/issues",
"source": "https://github.com/spipu/html2pdf/tree/v5.2.7"
},
"time": "2023-02-02T15:50:45+00:00"
},
{
"name": "tecnickcom/tcpdf",
"version": "6.6.2",
"source": {
"type": "git",
"url": "https://github.com/tecnickcom/TCPDF.git",
"reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/e3cffc9bcbc76e89e167e9eb0bbda0cab7518459",
"reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"classmap": [
"config",
"include",
"tcpdf.php",
"tcpdf_parser.php",
"tcpdf_import.php",
"tcpdf_barcodes_1d.php",
"tcpdf_barcodes_2d.php",
"include/tcpdf_colors.php",
"include/tcpdf_filters.php",
"include/tcpdf_font_data.php",
"include/tcpdf_fonts.php",
"include/tcpdf_images.php",
"include/tcpdf_static.php",
"include/barcodes/datamatrix.php",
"include/barcodes/pdf417.php",
"include/barcodes/qrcode.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-only"
],
"authors": [
{
"name": "Nicola Asuni",
"email": "info@tecnick.com",
"role": "lead"
}
],
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
"homepage": "http://www.tcpdf.org/",
"keywords": [
"PDFD32000-2008",
"TCPDF",
"barcodes",
"datamatrix",
"pdf",
"pdf417",
"qrcode"
],
"support": {
"issues": "https://github.com/tecnickcom/TCPDF/issues",
"source": "https://github.com/tecnickcom/TCPDF/tree/6.6.2"
},
"funding": [
{
"url": "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20tcpdf%20project",
"type": "custom"
}
],
"time": "2022-12-17T10:28:59+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.1.0"
}

7
vendor/autoload.php vendored Normal file
View File

@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit345046f5e84ab2074080e9ee6bf6cdf8::getLoader();

572
vendor/composer/ClassLoader.php vendored Normal file
View File

@ -0,0 +1,572 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
/** @var ?string */
private $vendorDir;
// PSR-4
/**
* @var array[]
* @psalm-var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, array<int, string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* @var array[]
* @psalm-var array<string, array<string, string[]>>
*/
private $prefixesPsr0 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var string[]
* @psalm-var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var bool[]
* @psalm-var array<string, bool>
*/
private $missingClasses = array();
/** @var ?string */
private $apcuPrefix;
/**
* @var self[]
*/
private static $registeredLoaders = array();
/**
* @param ?string $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}
/**
* @return string[]
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
}
/**
* @return array[]
* @psalm-return array<string, array<int, string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return string[] Array of classname => path
* @psalm-var array<string, string>
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
*
* @return void
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
return null;
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
*
* @return self[]
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
* @private
*/
function includeFile($file)
{
include $file;
}

337
vendor/composer/InstalledVersions.php vendored Normal file
View File

@ -0,0 +1,337 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
/**
* This class is copied in every Composer installed project and available to all
*
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*/
class InstalledVersions
{
private static $installed;
private static $canGetVendors;
private static $installedByVendor = array();
/**
* Returns a list of all package names which are present, either by being installed, replaced or provided
*
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
/**
* Returns a list of all package names with a specific type e.g. 'library'
*
* @param string $type
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackagesByType($type)
{
$packagesByType = array();
foreach (self::getInstalled() as $installed) {
foreach ($installed['versions'] as $name => $package) {
if (isset($package['type']) && $package['type'] === $type) {
$packagesByType[] = $name;
}
}
}
return $packagesByType;
}
/**
* Checks whether the given package is installed
*
* This also returns true if the package name is provided or replaced by another package
*
* @param string $packageName
* @param bool $includeDevRequirements
* @return bool
*/
public static function isInstalled($packageName, $includeDevRequirements = true)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
}
}
return false;
}
/**
* Checks whether the given package satisfies a version constraint
*
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
*
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
*
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
* @param string $packageName
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
* @return bool
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
/**
* Returns a version constraint representing all the range(s) which are installed for a given package
*
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
* whether a given version of a package is installed, and not just whether it exists
*
* @param string $packageName
* @return string Version constraint usable with composer/semver
*/
public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}
return $installed['versions'][$packageName]['version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return $installed['versions'][$packageName]['pretty_version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
*/
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}
return $installed['versions'][$packageName]['reference'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
*/
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @return array
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
*/
public static function getRootPackage()
{
$installed = self::getInstalled();
return $installed[0]['root'];
}
/**
* Returns the raw installed.php data for custom implementations
*
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
* @return array[]
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
*/
public static function getRawData()
{
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = include __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
return self::$installed;
}
/**
* Returns the raw data of all installed.php which are currently loaded for custom implementations
*
* @return array[]
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
public static function getAllRawData()
{
return self::getInstalled();
}
/**
* Lets you reload the static array from another file
*
* This is only useful for complex integrations in which a project needs to use
* this class but then also needs to execute another project's autoloader in process,
* and wants to ensure both projects have access to their version of installed.php.
*
* A typical case would be PHPUnit, where it would need to make sure it reads all
* the data it needs from this class, then call reload() with
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
* the project in which it runs can then also use this class safely, without
* interference between PHPUnit's dependencies and the project's dependencies.
*
* @param array[] $data A vendor/composer/installed.php data set
* @return void
*
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
*/
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}
$installed = array();
if (self::$canGetVendors) {
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
$installed[] = self::$installed;
return $installed;
}
}

21
vendor/composer/LICENSE vendored Normal file
View File

@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

24
vendor/composer/autoload_classmap.php vendored Normal file
View File

@ -0,0 +1,24 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'Datamatrix' => $vendorDir . '/tecnickcom/tcpdf/include/barcodes/datamatrix.php',
'PDF417' => $vendorDir . '/tecnickcom/tcpdf/include/barcodes/pdf417.php',
'QRcode' => $vendorDir . '/tecnickcom/tcpdf/include/barcodes/qrcode.php',
'TCPDF' => $vendorDir . '/tecnickcom/tcpdf/tcpdf.php',
'TCPDF2DBarcode' => $vendorDir . '/tecnickcom/tcpdf/tcpdf_barcodes_2d.php',
'TCPDFBarcode' => $vendorDir . '/tecnickcom/tcpdf/tcpdf_barcodes_1d.php',
'TCPDF_COLORS' => $vendorDir . '/tecnickcom/tcpdf/include/tcpdf_colors.php',
'TCPDF_FILTERS' => $vendorDir . '/tecnickcom/tcpdf/include/tcpdf_filters.php',
'TCPDF_FONTS' => $vendorDir . '/tecnickcom/tcpdf/include/tcpdf_fonts.php',
'TCPDF_FONT_DATA' => $vendorDir . '/tecnickcom/tcpdf/include/tcpdf_font_data.php',
'TCPDF_IMAGES' => $vendorDir . '/tecnickcom/tcpdf/include/tcpdf_images.php',
'TCPDF_IMPORT' => $vendorDir . '/tecnickcom/tcpdf/tcpdf_import.php',
'TCPDF_PARSER' => $vendorDir . '/tecnickcom/tcpdf/tcpdf_parser.php',
'TCPDF_STATIC' => $vendorDir . '/tecnickcom/tcpdf/include/tcpdf_static.php',
);

View File

@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

10
vendor/composer/autoload_psr4.php vendored Normal file
View File

@ -0,0 +1,10 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Spipu\\Html2Pdf\\' => array($vendorDir . '/spipu/html2pdf/src'),
);

57
vendor/composer/autoload_real.php vendored Normal file
View File

@ -0,0 +1,57 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit345046f5e84ab2074080e9ee6bf6cdf8
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit345046f5e84ab2074080e9ee6bf6cdf8', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit345046f5e84ab2074080e9ee6bf6cdf8', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit345046f5e84ab2074080e9ee6bf6cdf8::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}

50
vendor/composer/autoload_static.php vendored Normal file
View File

@ -0,0 +1,50 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit345046f5e84ab2074080e9ee6bf6cdf8
{
public static $prefixLengthsPsr4 = array (
'S' =>
array (
'Spipu\\Html2Pdf\\' => 15,
),
);
public static $prefixDirsPsr4 = array (
'Spipu\\Html2Pdf\\' =>
array (
0 => __DIR__ . '/..' . '/spipu/html2pdf/src',
),
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'Datamatrix' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/barcodes/datamatrix.php',
'PDF417' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/barcodes/pdf417.php',
'QRcode' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/barcodes/qrcode.php',
'TCPDF' => __DIR__ . '/..' . '/tecnickcom/tcpdf/tcpdf.php',
'TCPDF2DBarcode' => __DIR__ . '/..' . '/tecnickcom/tcpdf/tcpdf_barcodes_2d.php',
'TCPDFBarcode' => __DIR__ . '/..' . '/tecnickcom/tcpdf/tcpdf_barcodes_1d.php',
'TCPDF_COLORS' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/tcpdf_colors.php',
'TCPDF_FILTERS' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/tcpdf_filters.php',
'TCPDF_FONTS' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/tcpdf_fonts.php',
'TCPDF_FONT_DATA' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/tcpdf_font_data.php',
'TCPDF_IMAGES' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/tcpdf_images.php',
'TCPDF_IMPORT' => __DIR__ . '/..' . '/tecnickcom/tcpdf/tcpdf_import.php',
'TCPDF_PARSER' => __DIR__ . '/..' . '/tecnickcom/tcpdf/tcpdf_parser.php',
'TCPDF_STATIC' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/tcpdf_static.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit345046f5e84ab2074080e9ee6bf6cdf8::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit345046f5e84ab2074080e9ee6bf6cdf8::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit345046f5e84ab2074080e9ee6bf6cdf8::$classMap;
}, null, ClassLoader::class);
}
}

141
vendor/composer/installed.json vendored Normal file
View File

@ -0,0 +1,141 @@
{
"packages": [
{
"name": "spipu/html2pdf",
"version": "v5.2.7",
"version_normalized": "5.2.7.0",
"source": {
"type": "git",
"url": "https://github.com/spipu/html2pdf.git",
"reference": "b0f477711de3052041072897510e690975aa37ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spipu/html2pdf/zipball/b0f477711de3052041072897510e690975aa37ce",
"reference": "b0f477711de3052041072897510e690975aa37ce",
"shasum": ""
},
"require": {
"ext-gd": "*",
"ext-mbstring": "*",
"php": "^5.6 || ^7.0 || ^8.0",
"tecnickcom/tcpdf": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^9.0"
},
"suggest": {
"ext-gd": "Allows to embed images into the PDF",
"fagundes/zff-html2pdf": "if you need to integrate Html2Pdf with Zend Framework 2 (zf2)"
},
"time": "2023-02-02T15:50:45+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Spipu\\Html2Pdf\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"OSL-3.0"
],
"authors": [
{
"name": "Spipu",
"homepage": "https://github.com/spipu",
"role": "Developer"
}
],
"description": "Html2Pdf is a HTML to PDF converter written in PHP5 (it uses TCPDF). OFFICIAL PACKAGE",
"homepage": "http://html2pdf.fr/",
"keywords": [
"html",
"html2pdf",
"pdf"
],
"support": {
"issues": "https://github.com/spipu/html2pdf/issues",
"source": "https://github.com/spipu/html2pdf/tree/v5.2.7"
},
"install-path": "../spipu/html2pdf"
},
{
"name": "tecnickcom/tcpdf",
"version": "6.6.2",
"version_normalized": "6.6.2.0",
"source": {
"type": "git",
"url": "https://github.com/tecnickcom/TCPDF.git",
"reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/e3cffc9bcbc76e89e167e9eb0bbda0cab7518459",
"reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2022-12-17T10:28:59+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"classmap": [
"config",
"include",
"tcpdf.php",
"tcpdf_parser.php",
"tcpdf_import.php",
"tcpdf_barcodes_1d.php",
"tcpdf_barcodes_2d.php",
"include/tcpdf_colors.php",
"include/tcpdf_filters.php",
"include/tcpdf_font_data.php",
"include/tcpdf_fonts.php",
"include/tcpdf_images.php",
"include/tcpdf_static.php",
"include/barcodes/datamatrix.php",
"include/barcodes/pdf417.php",
"include/barcodes/qrcode.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-only"
],
"authors": [
{
"name": "Nicola Asuni",
"email": "info@tecnick.com",
"role": "lead"
}
],
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
"homepage": "http://www.tcpdf.org/",
"keywords": [
"PDFD32000-2008",
"TCPDF",
"barcodes",
"datamatrix",
"pdf",
"pdf417",
"qrcode"
],
"support": {
"issues": "https://github.com/tecnickcom/TCPDF/issues",
"source": "https://github.com/tecnickcom/TCPDF/tree/6.6.2"
},
"funding": [
{
"url": "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20tcpdf%20project",
"type": "custom"
}
],
"install-path": "../tecnickcom/tcpdf"
}
],
"dev": true,
"dev-package-names": []
}

41
vendor/composer/installed.php vendored Normal file
View File

@ -0,0 +1,41 @@
<?php return array(
'root' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '3dcc93a65d2fed8151724e67d6ed82c078d25823',
'name' => '__root__',
'dev' => true,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '3dcc93a65d2fed8151724e67d6ed82c078d25823',
'dev_requirement' => false,
),
'spipu/html2pdf' => array(
'pretty_version' => 'v5.2.7',
'version' => '5.2.7.0',
'type' => 'library',
'install_path' => __DIR__ . '/../spipu/html2pdf',
'aliases' => array(),
'reference' => 'b0f477711de3052041072897510e690975aa37ce',
'dev_requirement' => false,
),
'tecnickcom/tcpdf' => array(
'pretty_version' => '6.6.2',
'version' => '6.6.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/../tecnickcom/tcpdf',
'aliases' => array(),
'reference' => 'e3cffc9bcbc76e89e167e9eb0bbda0cab7518459',
'dev_requirement' => false,
),
),
);

26
vendor/composer/platform_check.php vendored Normal file
View File

@ -0,0 +1,26 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 50600)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}

21
vendor/spipu/html2pdf/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# Eclipse
/.settings/
/.buildpath
/.project
/nbproject
# PHPStorm
/.idea
# Examples
/test/*.pdf
# PhpUnit
/build/
/.phpunit.result.cache
# Composer
/bin/
/vendor/
/composer.lock
/composer.phar

16
vendor/spipu/html2pdf/.travis.yml vendored Normal file
View File

@ -0,0 +1,16 @@
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
before_script:
- composer selfupdate
- composer install --dev --prefer-dist

540
vendor/spipu/html2pdf/CHANGELOG.md vendored Normal file
View File

@ -0,0 +1,540 @@
# Change Log
All notable changes to this project will be documented in this file.
## [5.2.7](https://github.com/spipu/html2pdf/compare/v5.2.6...v5.2.7) - 2023-02-02
* fix phunit compatibility
## [5.2.6](https://github.com/spipu/html2pdf/compare/v5.2.5...v5.2.6) - 2023-01-28
* add support of PHP 8.1 and PHP 8.2
* add phpunit 9 compatibility - thanks to @jausions
* remove useless files
## [5.2.5](https://github.com/spipu/html2pdf/compare/v5.2.4...v5.2.5) - 2022-04-04
* fix security on scheme of css and image paths for windows paths
## [5.2.4](https://github.com/spipu/html2pdf/compare/v5.2.3...v5.2.4) - 2021-12-16
* revert fix multibyte aware substr when setting newline position - it causes pbs on some specific cases
* security #CVE-2021-45394 - add security on scheme of css and image paths - thanks to Clément Amic and Antoine Gicquel from [Synacktiv](https://www.synacktiv.com/)
## [5.2.3](https://github.com/spipu/html2pdf/compare/v5.2.2...v5.2.3) - 2021-10-19
* add support for BASE64 encoded images also for backimg tag in page - thanks to @berengan
* fix issue on write2DBarcode parameters - thanks to @Sarigue
* fix svg path parser - thanks to @CWBudde - issue #618
* fix html attribute parser - thanks to @Tofandel
* fix multibyte aware substr when setting newline position - thanks to @AndyTWF
* add php8 compatibility and fix tcpdf compatibilty - thanks to @humancopy
## [5.2.2](https://github.com/spipu/html2pdf/compare/v5.2.1...v5.2.2) - 2020-03-22
* allow usage of [[page_cu]] in css class names - thanks to @marbetschar - see example 15
* add support for BASE64 encoded images - thanks to @darius-heavy
* add Chinese local file - thanks to @Jaggle
* add powershell test script
* bump supported version from 5.4-7.2 to 5.6-7.4 - thanks to @coffeemedia
* fix issue on \_drawRectangle where array offset was being accessed on value of type null - thanks to @coffeemedia
* fix issue on lower-roman style - thanks to @jigneshsolanki
* fix issue on composer autoload warning - thanks to @adrienfr
## [5.2.1](https://github.com/spipu/html2pdf/compare/v5.2.0...v5.2.1) - 2018-10-26
* add `cert` tag - thanks to @LittleBigFox
* add `balloon` example - issue #385
* change the name of all the examples from `exemple` to `example`
* fix tag parser - css style corruption
* fix issue on relative margin calculation
* fix issue on border radius calculation
* fix issue on page background image width - issue #394
* fix issue on qrcode value with multi lines - issue #390
* fix issue on colspan usage when all the columns don't really exist - issue #360
* fix documentation - thanks to @noxlux and @tpohchai
## [5.2.0](https://github.com/spipu/html2pdf/compare/v5.1.0...v5.2.0) - 2018-07-31
* change the name of `CoreExtension` to `Core\HtmlExtension`
* change the namespace of all the html tags from `Tag\` to `Tag\Html`
* change all the svg tag from internal methods to new external tags
* add the extension `Core\SvgExtension`
* add locale fi - thanks to @RWAP
* add `$marginTop` parameter on the `createIndex` method - issue #333
* add `xx-large` to `xx-small` font-size management - issue #320
* add `colgoup` html tag - issue #306
* fix locale pt - thanks to @marcoshenzel
* fix issue on testing the filename when asking for string output
* fix issue - clean locale before PDF generation - thanks to @quimcalpe
* fix issue on radio/checkbow width - thanks to @Ohda
* fix issue on line number when using style tag - issue #338
* fix issue on svg draw path - relative move was not implemented
* fix issue on svg draw path when Z directive is not separate from the next directive - issue #308
* fix issue on justify text with an inline html tag at the end of a line - issue #258
* fix better doc
## [5.1.0](https://github.com/spipu/html2pdf/compare/v5.0.1...v5.1.0) - 2018-01-23
* add support of css `page-break-before:always` and `page-break-after:always` on `DIV` tag, based on PR #190 and PR #204
* add no-html mode for debug output
* add php 7.2 compatibility
* add some unit tests, better coverage
* fix lots of bad method names and minor improvements, from PR #147
* fix bad cleaning after output or exception
* fix bad format detecting on `page` tag - issue #260
* fix changelog file
## [5.0.1](https://github.com/spipu/html2pdf/compare/v5.0.0...v5.0.1) - 2017-06-15
* fix issue #200 pb with absolute path when saving the pdf file on server
## [5.0.0](https://github.com/spipu/html2pdf/compare/v4.6.1...v5.0.0) - 2017-06-15
**BREAK COMPATIBILITY**
This new version is not compatible with the 4.x.x version.
Lots of classes / methods have been renamed, moved, deleted, exploded.
* change licence to OSL-3.0
* change PHP minimum compatibility to 5.4
* change Using Namespaces
* change all the classes have moved
* change all the classes have been renamed
* change new tag structure : one class per tag
* change output method does not allow bool value on `$dest` parameter anymore
* change output method has been renamed from `Output` to `output`
* change values for the footer`attribute` of the `page` tag
* add PHP 7.0 and 7.1 compatibility
* add improve string handling for UTF8
* add better exception management
* add unit testing
* add support 'start' attribute for ordered list
* add russian language https://github.com/spipu/html2pdf/pull/131
* add Dimension-Parameter on barcode (for PDF417, Datamatrix = 2D) https://github.com/spipu/html2pdf/pull/127
* add `pdfa` parameter on Html2Pdf constructor https://github.com/spipu/html2pdf/pull/122
* add new documentation folder `./doc/`
* add new attribute to page tag `hidefooter` which accepts a list of pages that gonna skip footer https://github.com/spipu/html2pdf/issues/162
* add protection on the fallback image if it does not exist
* add protection on thead and tfoot tags: they must contain at least one tr tag
* add norwegian locale
* fix a infinite loop case when reading a svg path
* fix issue from https://github.com/spipu/html2pdf/pull/177
* fix issue from https://github.com/spipu/html2pdf/pull/163
* fix bug on div position https://github.com/spipu/html2pdf/issues/73
* fix margin-bottom on table https://github.com/spipu/html2pdf/issues/108
* fix position of fallback image
* fix li bullet points altered by uppercase styles
* fix save PDF file on server https://github.com/spipu/html2pdf/issues/164
* remove old barcode type compatibility
## [4.6.1](https://github.com/spipu/html2pdf/compare/v4.6.0...v4.6.1) - 2016-04-05
* fix css font-family lowercase check on inherit value
## [4.6.0](https://github.com/spipu/html2pdf/compare/v4.5.1...v4.6.0) - 2016-03-30
* add Support 'start' attribute for ordered list
* add Enable RTL languages support
* add fallback support for images
## [4.5.1](https://github.com/spipu/html2pdf/compare/v4.5.0...v4.5.1) - 2016-03-03
* Support the "inherit" value for font-family
* Allow the HTML font tag to define a color attribute
* Support for max-width and max-height attributes for images
* Fix "border: 0" being displayed
## [4.5.0](https://github.com/spipu/html2pdf/compare/v4.4.0...v4.5.0) - 2015-12-18
* add tag 'end_last_page' with property 'end_height'. Update example 5 to use it
* better composer.json file
* update TCPDF from 5.0.002 to v6.2.12 => important changes. See the TCPDF changelogs
## [4.4.0](https://github.com/spipu/html2pdf/compare/v4.03...v4.4.0) - 2015-12-11
* includes a new attribute to page tag 'hideheader' which accepts a list of pages that gonna skip header.
* some doc fixes, rephrasing and removing french words
* add composer management
* Update autoload type
* README more readable
* add automatic generation of pdf test files
* script ./test/generate.sh
* You must have the html2pdf folder in http:/localhost/html2pdf/
* fix: Set default font from PDF_FONT_NAME_MAIN constant from TCPDF, if available
* fix: Make space-collapsing regexp Unicode-aware
* fix: some pbs on examples to generate them automatically
## 4.03 - 2011-05-27
* correction de l'exemple "form.php" : vulnérabilité cross-site scripting corrigée
* correction sur la gestion des retours à la ligne automatique
* correction sur le calcul de la hauteur des balises H1->H6
* amélioration de la gestion des exceptions
## 4.02 - 2011-04-29
* ATTENTION : beaucoup de changements dans la structure du projet. version 3.xx abandonnée
* uniformisation des fichiers du projet (standard Zend)
* conversion des fichiers de langue en CSV, déplacement dans le répertoire "locale". création d'une classe spécifique à la gestion des locales
* amélioration de la gestion de certaines erreurs
* modification du nom de toutes les sous classes
* déplacement de toutes les sous classes
* modification du nom de toutes les méthodes protected
* correction sur la gestion des tables
* correction sur la lecture des path des SVG
* premiere version de text-align:justify
* correction sur la gestion de la balise BLOCKQUOTE
* correction sur la gestion de la balise P
* gestion des styles CSS pour les balises TEXTAREA, SELECT, INPUT
* ajout de la propriété pagegroup="new" sur la balise PAGE
* correction pour la balise INPUT de type radio : checked au lieu de selected
## 3.30 / 4.01 - 2010-05-07
* correction sur la gestion des textes
* correction sur le parseur HTML
* correction sur la gestion de border-collapse
* correction sur la gestion des TDs, H1->H6
* ajout des balises fieldset et legend (cf exemple 4)
* ajout de la langue CS
* nombreuses améliorations
* v4.01 uniquement : Utilisation de TCPDF 5.0.002
* v4.01 uniquement : Utilisation des QR-code de TCPDF, il n'y a plus besoin d'une librairie externe
* v4.01 uniquement : Utilisation des exceptions PHP pour les erreurs. Tous les exemples ont été mis à jour en consequence
* (merci à Pavel Kochman pour ses sugestions et ses ajouts)
## 4.00 - 2010-03-17
* modification des barcodes. ATTENTION : bar_w et bar_h n'existent plus !
* correction sur la gestion de page_footer
* correction sur la gestion des html entities
* correction sur le positionnement des textes
* correction sur le positionnement des tableaux
* nombreuses corrections sur les positionnements, les couleurs, ...
* amélioration de la partie SVG (balise G, ...)
* amélioration sur createIndex
* harmonisation des noms des méthodes
* correction sur la gestion des textes
* v4.00 uniquement : Html2Pdf est maintenant écrit en PHP5 et basé sur TCPDF (=> unicode, utf8, ...)
* v4.00 uniquement : utilisation de TCPDF pour les formulaires et les barcodes
* v4.00 uniquement : amélioration de la partie SVG (alpha)
## 3.28 - 2010-01-18
* ajout de la gestion de la balise label
* correction pour compatibilité PHP4
## 3.27 - 2010-01-11
* correction sur page_header et page_footer
* ajout de la possibilité de pouvoir mettre l'index automatique dans la page que l'on veut
* correction sur la gestion du canal alpha pour les PNGs
* correction sur la gestion des border-radius (cf exemple radius) conforme au CSS3
* correction sur la gestion du background-color
* correction sur la gestion de thead, tfoot, et tbody
* ajout du dessin verctoriel (cf exemples draw, tigre, sapin)
* ajout de la propriété label="none/label" pour la balise barcode
* nombreux petits correctifs
## 3.26 - 2009-11-16
* correction pour support des images générés en CGI
* ajout de la gestion du canal alpha pour les PNGs (nécessite GD2)
* ajout de la méthode setDefaultFont permettant de spécifier une fonte par défaut
* ajout de la propriété format pour la balise page (cf exemple 4)
* amélioration de la gestion des couleurs css RGB (cf exemple 2)
* ajout de la gestion des couleurs css CMYK (cf exemple 2)
* ajout de la propriété css overflow:hidden pour la balise div (cf exemple 2)
* correction sur page_header et page_footer
* ajout de la possibilité de pouvoir directement convertir le résultat d'une vraie page HTML
* nombreux petits correctifs sur les styles
## 3.25 - 2009-10-07
* correctif sur le calcul des tableaux dans le page_footer
* correctif sur l'interprétation des espaces entre certaines balises
* correction sur la gestion des balises H1, H2, H3, H4, H5, H6
* correction sur la gestion de la balise table
* support des balises xhtml du type span
* ajout des balises COL (cf exemple 5), DEL, INS, et QRCODE (cf exemple 13)
* ajout de la propriété css text-transform
* ajout de la propriété css rotate (uniquement sur les DIV, cf exemple 8)
* ne plus rendre obligatoire l'existence d'une image (nouvelle méthode setTestIsImage)
* ajout d'un mode DEBUG - les anciennes fonction d'analyse des ressources ont été supprimées
* ajout de la méthode setEncoding
* ajout de la langue danoise DA (merci à Daniel K.)
## 3.24 - 2009-08-05
* correction sur le calcul de la largeur des divs
* modification pour compatibilité avec la localisation PHP
* modification pour compatibilité avec PHP 5.3.0
## 3.23 - 2009-07-30
* correction sur le calcul des DIVs
* correction sur l'interpretation de certains styles CSS
* correction de la fonction de creation d'index automatique CreateIndex
* ATTENTION : la methode d'appel de CreateIndex a changé. Regardez l'exemple About !!!!
## 3.22a (2009-06-16
* redistribution de Html2Pdf sous la licence LGPL !!! (au lieu de GPL)
## 3.22 - 2009-06-08
* correction sur le background-color
* refonte totale de la gestion de text-align. les valeurs center et right marchent maintenant meme en cas de contenu riche
## 3.21 - 2009-05-05
* ajout de la propriété css FLOAT pour la balise IMG
* correction sur la gestion des TFOOT
* correction sur le positionnement des images
## 3.20 - 2009-04-06
* ajout de la gestion des margins pour la balise DIV
* ajout de la gestion de la propriete css LINE-HEIGHT
* correction sur l'interpretation de la valeur de certains styles CSS (background-image, background-position, ...)
* correction sur la reconnaissance des balises thead et tfoot
* correction sur la balise select
* correction sur les fichiers de langue (merci à Sinan)
## 3.19 - 2009-03-11
* optimisation du parseur HTML - merci à Jezelinside
* ajout de la balise TFOOT
* amélioration de la gestion des tableaux : les contenus des balises THEAD et TFOOT sont maintenant répétés sur chaque page.
* ajout de la balise spécifique BOOKMARK afin de créer des "marques-page"
* possibilité de rajouter un index automatique en fin de fichier
* ajout de la langue turque TR (merci à Hidayet)
* amélioration de la méthode Output. Elle est maintenant également utilisable comme celle de FPDF
## 3.18 - 2009-02-22
* correction sur les sauts de page automatique pour les balises TABLE, UL, OL
* correction sur l'interpretation des styles pour la balise HR
* correction sur l'interpretation du style border-collapse pour la balise TABLE
* prise en compte de margin:auto pour les tables et les divs
* les commentaires dans les CSS sont acceptés
## 3.17 - 2008-12-30
* ajout de la gestion des balises INPUT (text, radio, checkbox, button, hidden, ...), SELECT, OPTION, TEXTAREA (cf exemple 14)
* ajout de la possibilité de mettre des scripts dans le pdf (cf exemples JS)
* correction sur le saut de page automatique pour les images
* correction sur les sauts de lignes automatiques pour certaines balises (UL, P, ...)
* ajout de la langue NL (merci à Roland)
## 3.16 - 2008-12-09
* ajout de la gestion de list-style: none (cf exemple 13)
* correction dans la gestion des fontes ajoutées à fpdf (via la méthode AddFont)
* nombreuses corrections sur le calcul des largeurs des éléments table, div, hr, td, th
* ajout de l'exemple about.php
* (pour info, les PDF générés à partir des exemples sont maintenant dans le répertoire /exemples/pdf/, et sont supprimables)
## 3.15 - 2008-12-01
* correction sur l'identification des styles en cas de valeurs multiples dans la propriete class
* prise en compte de border-radius pour la limite des backgrounds (color et image)
* ajout des proprietes CSS border-top-*, border-right-*, border-bottom-*, border-left-*
* ajout de la propriété CSS list-style-image (cf exemple 12)
* pour la balise table, ajout de l'interprétation de align="center" et align="right" (cf exemple 1)
* correction dans le positionnement des images
* correction de quelques bugs
* ajout d'une fonction d'analyse des ressources getTimerDebug (cf début du fichier html2pdf.class.php)
## 3.14 - 2008-11-17
* ajout d'une langue (pt : Brazilian Portuguese language) et amelioration de la methode vueHTML (merci à Rodrigo)
* correction du positionnement du contenu des DIVs. gestion des proprietes valign et align
* ajout de la propriete CSS border-collapse (cf exemple 0)
* ajout de la propriete CSS border-radius (cf exemple 1)
* correction de quelques bugs
## 3.13 - 2008-09-24
* reecriture de la balise hr, avec prise en compte des styles (cf exemple 0)
* ajout de la propriete backcolor pour la balise page (cf exemple 9)
* ajout des proprietes backleft et backright pour la balise page afin de pouvoir changer les marges des pages (cf exemple 8)
* nombreuses corrections sur les balises et les styles
## 3.12 - 2008-09-16
* ajout des balises ol, ul, li (cf exemple 12)
* correction sur le calcul de la taille des td en cas de colspan et rowspan
* ajout de la méthode setTestTdInOnePage afin de pouvoir desactiver le test sur la taille des TD (cf exemple 11)
* correction de quelques bugs
## 3.11 - 2008-08-29
* ajout des balises div, p, pre, s
* gestion des styles CSS position (relative, absolute), left, top, right, bottom (cf exemple 10)
* meilleur gestion des border : border-style, border-color, border-width (cf exemple 10)
* possibilité d'indiquer les marges par défault, via le constructeur (cf exemple 2)
## 3.10a - 2008-08-26
* correction pour compatibilité php4 / php5
## 3.10 - 2008-08-25
* ajout des liens internes (cf exemple 7)
* gestion complete des background : image, repeat, position, color (cf exemple 1)
* gestion de underline, overline, linethrough (cf exemple 2)
* correction de quelques bugs
## 3.09
* mise à jour vers fpdf version 1.6, ajout de barcode, correction de l'affichage de certains caractères spéciaux
* correction du calcul de la hauteur de ligne de la balise br
* detection en cas de contenu trop grand dans un TD
* amélioration de la balise page (ajout de l'attribue pageset, avec les valeurs new et old)
* ajout de FPDF_PROTECTION, accesible via $pdf->pdf->SetProtection(...)
## 3.08
* version opérationnelle de page_header
* ajout de page_footer
* correction des borders des tableaux
## 3.07
* correction de l'interpretation de cellspacing,
* amélioration de la balise page_header
## 3.06
* première gestion de la balise page_header
* correction des dimensions des tableaux
## 3.05
* ajout de la propriété vertical-align
* ajout de la gestion des fichiers de langue
## 3.04
* correction du saut de page automatique pour les tableaux
* Ajout de propriétés à la balise PAGE
## 3.03
* correction de bugs au niveau de la gestion des images PHP par FPDF
* meilleure gestion des erreurs
## 3.02
* ajout de la gestion des noms des couleurs
* correction de la gestion des images générées par php
* correction de quelques bugs
## 3.01
* correction de quelques bugs
* ajout d'une protection pour les balises non existantes
## 3.00
* refonte totale du calcul des tableaux
* Prise en compte des colspan et rowspan
*
## 2.85
* ajout de la propriété cellspacing
* nouvelle gestion des padding des tableaux
## 2.80
* ajout des types de border dotted et dasheds
## 2.75
* ajout des top, left, right, bottom pour padding et border
## 2.70
* correction de la balise HR, ajout de la propriété padding pour les table, th, td
* correction des dimensions, les unités px, mm, in, pt sont enfin réellement reproduites, correction de font-size, border, ...
* ajout d'une propriété à la balise page : footer
* correction dans l'affichage et le calcul des tables
## 2.55
* vérification de la validité du code (ouverture / fermeture)
* ajout des unités mm, in, pt
## 2.50
* correction de nobreak
* correction des marges
* ajout de nombreuses balises
## 2.40
* refonte totale de l'identification des styles CSS (Les héritages marchent)
## 2.39
* corrections diverses
* ajout de certaines propriétés (bgcolor, ...)
## 2.38
* meilleur identification des propriétés border et color
## 2.37
* nombreuses corrections :
* balise A
* couleur de fond
* retour à la ligne
* gestion des images dans un texte
## 2.36
* ajout de la balises STRONG
* ajout de la balise EM
## 2.35
* amélioration de la gestion des feuilles de style
## 2.31
* correction de quelques bugs
## 2.30
* première version opérationnel des feuilles de style
## 2.25
* ajout de la balise LINK pour le type text/css
## 2.20
* premier jet de la gestion des feuilles de style, ajout de la balise STYLE
## 2.15
* n'interpréte plus l'HTML en commentaire
## 2.10
* ajout des balises H1 -> H6
## 2.01
* correction de quelques bugs
## 2.00
* première version diffusée

54
vendor/spipu/html2pdf/LICENSE.md vendored Normal file
View File

@ -0,0 +1,54 @@
Open Software License v. 3.0 (OSL-3.0)
======================================
This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
Licensed under the Open Software License version 3.0
1. **Grant of Copyright License.** Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
1. to reproduce the Original Work in copies, either alone or as part of a collective work;
2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
4. to perform the Original Work publicly; and
5. to display the Original Work publicly.
2. **Grant** of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
3. **Grant** of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
4. **Exclusions From License Grant.** Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
5. **External Deployment.** The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
6. **Attribution Rights.** You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
7. **Warranty of Provenance and Disclaimer of Warranty.** Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
8. **Limitation of Liability.** Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
9. **Acceptance and Termination.** If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
10. **Termination for Patent Action.** This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
11. **Jurisdiction, Venue and Governing Law.** Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
12. **Attorneys' Fees.** In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
13. **Miscellaneous.** If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
14. **Definition of "You" in This License.** "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
15. **Right to Use.** You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
16. **Modification of This License.** This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions:
1. You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License;
2. You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License;
3. You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

48
vendor/spipu/html2pdf/README.md vendored Normal file
View File

@ -0,0 +1,48 @@
# Html2Pdf
Html2Pdf is a HTML to PDF converter written in PHP, and compatible with PHP **5.6** to **8.2**.
It allows the conversion of valid HTML in PDF format, to generate documents like invoices, documentation, ...
You have to write a code of HTML for Html2Pdf, and not try to convert directly an already existing html page.
Specific tags have been implemented, to adapt the html standard to a PDF usage.
You must use Composer to install this library.
It uses TCPDF for the PDF part.
## Requirements
Html2Pdf works with PHP >5.6 and Composer.
You will also need at least the following php extensions:
* gd
* mbstring
## Documentation
You will find the install documentation [here](./doc/install.md).
You will find all the documentation [here](./doc/README.md).
You will find lots of examples [here](./examples/).
## Donate
You can support this project by making a [donation](http://html2pdf.fr/en/donate).
## Change log
See the [./CHANGELOG.md](./CHANGELOG.md) file.
## Help & Support
For questions and bug reports, please use the GitHub issues page.
## License
This program is distributed under the OSL License. For more information see the [./LICENSE.md](./LICENSE.md) file.
Copyright 2008-2018 by Laurent Minguet

View File

@ -0,0 +1,22 @@
<?php
namespace Spipu\Html2Pdf\Tests;
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Tests\CrossVersionCompatibility\AbstractTestCase;
/**
* Class AbstractTest
*/
abstract class AbstractTest extends AbstractTestCase
{
/**
* Get the object to test
*
* @return Html2Pdf
*/
protected function getObject()
{
return $this->html2pdf;
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class AbstractTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\AbstractTestCase
{
}
} else {
abstract class AbstractTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\AbstractTestCase
{
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class CssConverterTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\CssConverterTestCase
{
}
} else {
abstract class CssConverterTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\CssConverterTestCase
{
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class ExceptionFormatterTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\ExceptionFormatterTestCase
{
}
} else {
abstract class ExceptionFormatterTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\ExceptionFormatterTestCase
{
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class HtmlTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\HtmlTestCase
{
}
} else {
abstract class HtmlTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\HtmlTestCase
{
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;
use Spipu\Html2Pdf\Html2Pdf;
abstract class AbstractTestCase extends \PHPUnit_Framework_TestCase
{
/**
* @var Html2Pdf
*/
protected $html2pdf;
/**
* Executed before each test
*/
protected function setUp()
{
$this->html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', [0, 0, 0, 0]);
$this->html2pdf->pdf->SetTitle('PhpUnit Test');
}
/**
* Executed after each test
*/
protected function tearDown()
{
$this->html2pdf->clean();
$this->html2pdf = null;
}
public function expectException($exception)
{
if (method_exists(\PHPUnit_Framework_TestCase::class, 'setExpectedException')) {
$this->setExpectedException($exception);
}
}
public function expectExceptionMessage($message, $exception = null)
{
if (method_exists(\PHPUnit_Framework_TestCase::class, 'expectExceptionMessage')) {
parent::expectExceptionMessage($message);
} elseif (method_exists(\PHPUnit_Framework_TestCase::class, 'setExpectedException')) {
$this->setExpectedException($exception, $message);
}
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;
use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\CssConverter;
abstract class CssConverterTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var CssConverter
*/
protected $cssConverter;
protected function setUp()
{
$this->cssConverter = new CssConverter();
}
}

View File

@ -0,0 +1,19 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;
use PHPUnit_Framework_TestCase;
abstract class ExceptionFormatterTestCase extends PHPUnit_Framework_TestCase
{
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;
use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\Parsing\Html;
abstract class HtmlTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var Html
*/
protected $object;
protected function setUp()
{
$textParser = $this->getMockBuilder('Spipu\Html2Pdf\Parsing\TextParser')
->disableOriginalConstructor()
->setMethods(['prepareTxt'])
->getMock();
$textParser
->expects($this->any())
->method('prepareTxt')
->will($this->returnCallback([$this, 'mockPrepareTxt']));
$this->object = new Html($textParser);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;
use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\CssConverter;
use Spipu\Html2Pdf\SvgDrawer;
abstract class SvgDrawerTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var SvgDrawer
*/
protected $svgDrawer;
protected function setUp()
{
$myPdf = $this->createMock('Spipu\Html2Pdf\MyPdf');
$cssConverter = new CssConverter();
$this->svgDrawer = new SvgDrawer($myPdf, $cssConverter);
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;
use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\Parsing\TagParser;
abstract class TagParserTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var TagParser
*/
protected $parser;
protected function setUp()
{
$textParser = $this->getMockBuilder('Spipu\Html2Pdf\Parsing\TextParser')
->disableOriginalConstructor()
->setMethods(['prepareTxt'])
->getMock();
$textParser
->expects($this->any())
->method('prepareTxt')
->will($this->returnCallback([$this, 'mockPrepareTxt']));
$this->parser = new TagParser($textParser);
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;
use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\Parsing\TextParser;
abstract class TextParserTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var TextParser
*/
protected $parser;
protected function setUp()
{
$this->parser = new TextParser();
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;
use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\Html2Pdf;
abstract class AbstractTestCase extends TestCase
{
use AssertContains;
/**
* @var Html2Pdf
*/
protected $html2pdf;
/**
* Executed before each test
*/
protected function setUp(): void
{
$this->html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', [0, 0, 0, 0]);
$this->html2pdf->pdf->SetTitle('PhpUnit Test');
}
/**
* Executed after each test
*/
protected function tearDown(): void
{
$this->html2pdf->clean();
$this->html2pdf = null;
}
public function expectExceptionMessage($message, $exception = null): void
{
// Yes, we ignore $exception
parent::expectExceptionMessage($message);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;
trait AssertContains
{
public static function assertContains($needle, $haystack, string $message = ''): void
{
if (is_string($haystack)) {
parent::assertStringContainsString($needle, $haystack, $message);
} else {
parent::assertContains($needle, $haystack, $message);
}
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;
use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\CssConverter;
abstract class CssConverterTestCase extends TestCase
{
/**
* @var CssConverter
*/
protected $cssConverter;
public function setUp(): void
{
$this->cssConverter = new CssConverter();
}
}

View File

@ -0,0 +1,20 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;
use PHPUnit\Framework\TestCase;
abstract class ExceptionFormatterTestCase extends TestCase
{
use AssertContains;
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;
use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\Parsing\Html;
abstract class HtmlTestCase extends TestCase
{
/**
* @var Html
*/
protected $object;
protected function setUp(): void
{
$textParser = $this->getMockBuilder('Spipu\Html2Pdf\Parsing\TextParser')
->disableOriginalConstructor()
->setMethods(['prepareTxt'])
->getMock();
$textParser
->expects($this->any())
->method('prepareTxt')
->willReturnCallback([$this, 'mockPrepareTxt']);
$this->object = new Html($textParser);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;
use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\CssConverter;
use Spipu\Html2Pdf\SvgDrawer;
abstract class SvgDrawerTestCase extends TestCase
{
/**
* @var SvgDrawer
*/
protected $svgDrawer;
public function setUp(): void
{
$myPdf = $this->createMock('Spipu\Html2Pdf\MyPdf');
$cssConverter = new CssConverter();
$this->svgDrawer = new SvgDrawer($myPdf, $cssConverter);
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;
use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\Parsing\TagParser;
abstract class TagParserTestCase extends TestCase
{
/**
* @var TagParser
*/
protected $parser;
protected function setUp(): void
{
$textParser = $this->getMockBuilder('Spipu\Html2Pdf\Parsing\TextParser')
->disableOriginalConstructor()
->setMethods(['prepareTxt'])
->getMock();
$textParser
->expects($this->any())
->method('prepareTxt')
->willReturnCallback([$this, 'mockPrepareTxt']);
$this->parser = new TagParser($textParser);
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;
use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\Parsing\TextParser;
abstract class TextParserTestCase extends TestCase
{
/**
* @var TextParser
*/
protected $parser;
protected function setUp(): void
{
$this->parser = new TextParser();
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class SvgDrawerTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\SvgDrawerTestCase
{
}
} else {
abstract class SvgDrawerTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\SvgDrawerTestCase
{
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class TagParserTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\TagParserTestCase
{
}
} else {
abstract class TagParserTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\TagParserTestCase
{
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class TextParserTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\TextParserTestCase
{
}
} else {
abstract class TextParserTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\TextParserTestCase
{
}
}

View File

@ -0,0 +1,13 @@
<?php
require_once __DIR__ . '/../../vendor/autoload.php';
if (!class_exists('PHPUnit_Framework_TestCase') && version_compare(phpversion(), '7.1') >= 0) {
class PHPUnit_Framework_TestCase extends PHPUnit\Framework\TestCase
{
}
define('HTML2PDF_PHPUNIT_VERSION', 9);
} else {
define('HTML2PDF_PHPUNIT_VERSION', 5);
}

View File

@ -0,0 +1,107 @@
<?php
namespace Spipu\Html2Pdf\Tests;
use Spipu\Html2Pdf\Tests\CrossVersionCompatibility\CssConverterTestCase;
/**
* Class CssConverterTest
*/
class CssConverterTest extends CssConverterTestCase
{
/**
* @param string $css
* @param string $old
* @param array $expected
*
* @dataProvider convertToMMProvider
*/
public function testConvertToMM($css, $old, $expected)
{
$result = $this->cssConverter->convertToMM($css, $old);
$this->assertEquals($expected, $result);
}
public function convertToMMProvider()
{
return array(
array('100mm', null, 100),
array('100px', null, 25.4 / 96. * 100),
array('100', null, 25.4 / 96. * 100),
array('100pt', null, 25.4 / 72. * 100),
array('100in', null, 25.4 * 100),
array('10%', 100, 10),
array('100cm', null, null),
);
}
/**
* @param string $css
* @param array $expected
*
* @dataProvider convertToRadiusProvider
*/
public function testConvertToRadius($css, $expected)
{
$result = $this->cssConverter->convertToRadius($css);
$this->assertEquals(count($expected), count($result));
for ($i = 0; $i < count($result); $i++) {
$this->assertEquals($expected[$i], $result[$i]);
}
}
public function convertToRadiusProvider()
{
return array(
array('100mm', array(100)),
array('100mm 10mm', array(100, 10)),
array('100mm 10mm ', array(100, 10)),
array('100mm 10cm 10mm', array(100, 10)),
array('1mm 2mm 3mm 4mm', array(1, 2, 3, 4)),
);
}
/**
* @param string $css
* @param boolean $expectedRes
* @param array $expectedColor
*
* @dataProvider convertToColorProvider
*/
public function testConvertToColor($css, $expectedRes, $expectedColor)
{
$res = true;
$resultColor = $this->cssConverter->convertToColor($css, $res);
$this->assertEquals($expectedRes, $res);
$this->assertEquals(count($expectedColor), count($resultColor));
for ($i = 0; $i < count($resultColor); $i++) {
if (is_null($expectedColor[$i])) {
$this->assertNull($resultColor[$i]);
} else {
$this->assertEquals($expectedColor[$i], $resultColor[$i]);
}
}
}
public function convertToColorProvider()
{
return array(
array('transparent', true, array(null, null, null)),
array('aliceblue', true, array( 240, 248, 255)),
array('#F0A050', true, array( 240, 160, 80)),
array('#FA5', true, array( 255, 170, 85)),
array('rgb( 50, 100, 150)', true, array( 50, 100, 150)),
array('rgb( 10%, 20%, 30%)', true, array(25.5, 51, 76.5)),
array('rgb( 0.2, 0.4, 0.6)', true, array( 51, 102, 153)),
array('cmyk(255, 255, 255, 255)', true, array( 100, 100, 100, 100)),
array('cmyk(10%, 20%, 30%, 40%)', true, array( 10, 20, 30, 40)),
array('cmyk(0.2, 0.4, 0.6, 0.8)', true, array( 20, 40, 60, 80)),
array('blakc', false, array( 0, 0, 0)),
);
}
}

View File

@ -0,0 +1,70 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Debug;
use Spipu\Html2Pdf\Debug\Debug;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class DebugTest
*/
class DebugTest extends AbstractTest
{
/**
* test Debug Mode, Automatic
*
* @return void
*/
public function testAutomatic()
{
$html = '<p>First Tag</p>';
$html.= '<div>Second Tag</div>';
$html.= '<b>Third Tag</b>';
ob_start();
$object = $this->getObject();
$object->setModeDebug();
$object->writeHTML($html);
$pdfResult = $object->output('test.pdf', 'S');
$debugResult = ob_get_clean();
$this->assertSame('', $pdfResult);
$this->assertNotEmpty($debugResult);
}
/**
* test Debug Mode, manual
*
* @return void
*/
public function testManual()
{
$html = '<p>First Tag</p>';
$html.= '<div>Second Tag</div>';
$html.= '<b>Third Tag</b>';
// Prepare debug object, without html output
$debug = new Debug(false);
ob_start();
$object = $this->getObject();
$object->setModeDebug($debug);
$object->writeHTML($html);
$pdfResult = $object->output('test.pdf', 'S');
$debugResult = ob_get_clean();
$this->assertSame('', $pdfResult);
$this->assertNotEmpty($debugResult);
}
}

View File

@ -0,0 +1,336 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests;
use PHPUnit_Framework_TestCase;
/**
* Class ExamplesTest
*/
class ExamplesTest extends PHPUnit_Framework_TestCase
{
/**
* Launch a example
*
* @param string $example code of the example
*
* @return void
* @throws \Exception
*/
protected function launchExample($example)
{
$filename = dirname(dirname(__FILE__)).'/examples/'.$example.'.php';
if (!is_file($filename)) {
throw new \Exception('The filename of the example ['.$example.'] does not exist!');
}
$folder = dirname($filename);
// get the content of the file
$content = file_get_contents($filename);
// keep only the example
$parts = explode('try {', $content);
$parts = explode('} catch', $parts[1]);
$content = $parts[0];
// replace the good path
$content = str_replace('dirname(__FILE__)', "'$folder'", $content);
// add the class to use
$content = 'use Spipu\Html2Pdf\Html2Pdf; '.$content;
// get the output
$regexp = '/\$html2pdf->output\(([^\)]*)\);/';
$replace = 'return $html2pdf->output(\'test.pdf\', \'S\');';
$content = preg_replace($regexp, $replace, $content);
// execute
$currentDir = getcwd();
chdir($folder);
$result = eval($content);
chdir($currentDir);
// test
$this->assertNotEmpty($result);
}
/**
* test: about
*
* @return void
*/
public function testAbout()
{
$this->launchExample('about');
}
/**
* test: bookmark
*
* @return void
*/
public function testBookmark()
{
$this->launchExample('bookmark');
}
/**
* test: bookmark
*
* @return void
*/
public function testBalloon()
{
$this->launchExample('balloon');
}
/**
* test: example01
*
* @return void
*/
public function testExample01()
{
$this->launchExample('example01');
}
/**
* test: example02
*
* @return void
*/
public function testExample02()
{
$this->launchExample('example02');
}
/**
* test: example03
*
* @return void
*/
public function testExample03()
{
$this->launchExample('example03');
}
/**
* test: example04
*
* @return void
*/
public function testExample04()
{
$this->launchExample('example04');
}
/**
* test: example05
*
* @return void
*/
public function testExample05()
{
$this->launchExample('example05');
}
/**
* test: example06
*
* @return void
*/
public function testExample06()
{
$this->launchExample('example06');
}
/**
* test: example07
*
* @return void
*/
public function testExample07()
{
$this->launchExample('example07');
}
/**
* test: example08
*
* @return void
*/
public function testExample08()
{
$this->launchExample('example08');
}
/**
* test: example10
*
* @return void
*/
public function testExample10()
{
$this->launchExample('example10');
}
/**
* test: example11
*
* @return void
*/
public function testExample11()
{
$this->launchExample('example11');
}
/**
* test: example12
*
* @return void
*/
public function testExample12()
{
$this->launchExample('example12');
}
/**
* test: example13
*
* @return void
*/
public function testExample13()
{
$this->launchExample('example13');
}
/**
* test: example14
*
* @return void
*/
public function testExample14()
{
$this->launchExample('example14');
}
/**
* test: example15
*
* @return void
*/
public function testExample15()
{
$this->launchExample('example15');
}
/**
* test: forms
*
* @return void
*/
public function testForms()
{
$this->launchExample('forms');
}
/**
* test: groups
*
* @return void
*/
public function testGroups()
{
$this->launchExample('groups');
}
/**
* test: qrcode
*
* @return void
*/
public function testQrcode()
{
$this->launchExample('qrcode');
}
/**
* test: radius
*
* @return void
*/
public function testRadius()
{
$this->launchExample('radius');
}
/**
* test: regle
*
* @return void
*/
public function testMeasure()
{
$this->launchExample('measure');
}
/**
* test: svg
*
* @return void
*/
public function testSvg()
{
$this->launchExample('svg');
}
/**
* test: svg_tiger
*
* @return void
*/
public function testSvgTiger()
{
$this->launchExample('svg_tiger');
}
/**
* test: svg_tree
*
* @return void
*/
public function testSvgTree()
{
$this->launchExample('svg_tree');
}
/**
* test: ticket
*
* @return void
*/
public function testTicket()
{
$this->launchExample('ticket');
}
/**
* test: utf8
*
* @return void
*/
public function testUtf8()
{
$this->launchExample('utf8');
}
}

View File

@ -0,0 +1,117 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Exception;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Exception\ImageException;
use Spipu\Html2Pdf\Exception\LongSentenceException;
use Spipu\Html2Pdf\Tests\CrossVersionCompatibility\ExceptionFormatterTestCase;
/**
* Class ExceptionFormaterTest
*/
class ExceptionFormatterTest extends ExceptionFormatterTestCase
{
/**
* Test the formatter / generic exception
*/
public function testGeneric()
{
$exception = new Html2PdfException('My Message');
$formatter = new ExceptionFormatter($exception);
$messages = [
$formatter->getMessage(),
$formatter->getHtmlMessage()
];
foreach ($messages as $message) {
$this->assertContains('Html2Pdf Error ['.Html2PdfException::ERROR_CODE.']', $message);
$this->assertContains('My Message', $message);
}
}
/**
* Test the formatter / parsing exception
*/
public function testParsing()
{
$exception = new HtmlParsingException('My Message');
$exception->setInvalidTag('my_tag');
$exception->setHtmlLine(42);
$formatter = new ExceptionFormatter($exception);
$messages = [
$formatter->getMessage(),
$formatter->getHtmlMessage()
];
foreach ($messages as $message) {
$this->assertContains('Html2Pdf Error ['.HtmlParsingException::ERROR_CODE.']', $message);
$this->assertContains('My Message', $message);
$this->assertContains('my_tag', $message);
$this->assertContains('42', $message);
}
}
/**
* Test the formatter / image exception
*/
public function testImage()
{
$exception = new ImageException('My Message');
$exception->setImage('my_image.png');
$formatter = new ExceptionFormatter($exception);
$messages = [
$formatter->getMessage(),
$formatter->getHtmlMessage()
];
foreach ($messages as $message) {
$this->assertContains('Html2Pdf Error ['.ImageException::ERROR_CODE.']', $message);
$this->assertContains('My Message', $message);
$this->assertContains('my_image.png', $message);
}
}
/**
* Test the formatter / long sentence exception
*/
public function testLongSentence()
{
$exception = new LongSentenceException('My Message');
$exception->setSentence('my sentence');
$exception->setLength(142);
$exception->setWidthBox(242);
$formatter = new ExceptionFormatter($exception);
$messages = [
$formatter->getMessage(),
$formatter->getHtmlMessage()
];
foreach ($messages as $message) {
$this->assertContains('Html2Pdf Error ['.LongSentenceException::ERROR_CODE.']', $message);
$this->assertContains('My Message', $message);
$this->assertContains('my sentence', $message);
$this->assertContains('142', $message);
$this->assertContains('242', $message);
}
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Exception;
use Spipu\Html2Pdf\Exception\LongSentenceException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class DebugTest
*/
class LongSentenceExceptionTest extends AbstractTest
{
/**
* test LongSentence Exception
*
* @return void
*/
public function testBug()
{
$this->expectException(LongSentenceException::class);
$sentence = 'This is a sentence.';
$bigSentence = $sentence;
for ($k=0; $k<110; $k++) {
$bigSentence.= ' '.$sentence;
}
$html = '<page backleft="0" backright="200mm"style="font-size: 1mm">'.$bigSentence.'</page>';
$object = $this->getObject();
$object->setSentenceMaxLines(100);
$object->writeHTML($html);
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace Spipu\Html2Pdf\Tests;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tag\AbstractTag;
/**
* Class Html2PdfTest
*/
class Html2PdfTest extends AbstractTest
{
public function testExtensionTag()
{
$tag = new testTag();
$extension = $this->createMock('Spipu\Html2Pdf\Extension\ExtensionInterface');
$extension->expects($this->any())->method('getName')->willReturn('test');
$extension->expects($this->any())->method('getTags')->willReturn(array($tag));
$object = $this->getObject();
$object->addExtension($extension);
$object->writeHTML('<div><test_tag>Hello</test_tag></div>');
$this->assertTrue(true);
}
public function testSecurityGood()
{
$object = $this->getObject();
$object->setTestIsImage(false);
$object->writeHTML('<div><img src="https://www.spipu.net/res/logo_spipu.gif" alt="" /></div>');
$object->writeHTML('<div><img src="/temp/test.jpg" alt="" /></div>');
$object->writeHTML('<div><img src="c:/temp/test.jpg" alt="" /></div>');
// Ensures we assert something
$this->assertTrue(true);
}
public function testSecurityKo()
{
$this->expectException(HtmlParsingException::class);
$this->expectExceptionMessage('Unauthorized path scheme', HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<div><img src="phar://test.com/php.phar" alt="" /></div>');
}
}
class testTag extends AbstractTag
{
public function getName()
{
return 'test_tag';
}
public function open($properties)
{
}
public function close($properties)
{
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Image;
use Spipu\Html2Pdf\Exception\ImageException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class BackgroundErrorTest
*/
class BackgroundErrorTest extends AbstractTest
{
/**
* test: The image src is unknown
*
* @return void
*/
public function testCase()
{
$this->expectException(ImageException::class);
$image = '/res/wrong.png';
try {
$object = $this->getObject();
$object->writeHTML('<div style="background-image: url('.$image.')">Hello World</div>');
$object->output('test.pdf', 'S');
} catch (ImageException $e) {
$this->assertSame($image, $e->getImage());
throw $e;
}
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Image;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class BackgroundOkTest
*/
class BackgroundOkTest extends AbstractTest
{
/**
* test: The image src is unknown
*
* @return void
*/
public function testCase()
{
$object = $this->getObject();
$object->writeHTML('<div style="background-image: url('.dirname(__FILE__).'/res/logo.png)">Hello World</div>');
$result = $object->output('test.pdf', 'S');
$this->assertContains('PhpUnit Test', $result);
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Image;
use Spipu\Html2Pdf\Exception\ImageException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class SrcErrorTest
*/
class SrcErrorTest extends AbstractTest
{
/**
* test: The image src is unknown
*
* @return void
*/
public function testCase()
{
$this->expectException(ImageException::class);
$image = '/res/wrong.png';
try {
$object = $this->getObject();
$object->writeHTML('Hello World <img src="'.$image.'" />');
$object->output('test.pdf', 'S');
} catch (ImageException $e) {
$this->assertSame($image, $e->getImage());
throw $e;
}
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Image;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class SrcOkTest
*/
class SrcOkTest extends AbstractTest
{
/**
* test: The image src is unknown
*
* @return void
*/
public function testCase()
{
$object = $this->getObject();
$object->writeHTML('Hello World <img src="'.dirname(__FILE__).'/res/logo.png" />');
$result = $object->output('test.pdf', 'S');
$this->assertContains('PhpUnit Test', $result);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,74 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests;
use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\Locale;
use Spipu\Html2Pdf\Exception\LocaleException;
/**
* Class LocaleTest
*/
class LocaleTest extends PHPUnit_Framework_TestCase
{
/**
* test bad code
*
* @return void
*/
public function testBadCode()
{
$this->expectException(LocaleException::class);
Locale::clean();
try {
Locale::load('$aa');
} catch (LocaleException $e) {
$this->assertSame('$aa', $e->getLocalCode());
throw $e;
}
}
/**
* test unknown code
*
* @return void
*/
public function testUnknownCode()
{
$this->expectException(LocaleException::class);
Locale::clean();
try {
Locale::load('aa');
} catch (LocaleException $e) {
$this->assertSame('aa', $e->getLocalCode());
throw $e;
}
}
/**
* test good code
*
* @return void
*/
public function testGoodCode()
{
Locale::clean();
Locale::load('en');
$this->assertSame('Page [[page_cu]]/[[page_nb]]', Locale::get('pdf04'));
$this->assertSame('bad_return', Locale::get('bad_code', 'bad_return'));
Locale::clean();
$this->assertSame('bad_return', Locale::get('pdf04', 'bad_return'));
}
}

View File

@ -0,0 +1,66 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Output;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class FileNameOkTest
*/
class FileNameOkTest extends AbstractTest
{
/**
* test: the file extension must be PDF - OK
*
* @return void
*/
public function testOk()
{
$object = $this->getObject();
$object->writeHTML('Hello World');
ob_start();
$object->output('test.pdf');
$result = ob_get_clean();
$this->assertContains('PhpUnit Test', $result);
}
/**
* test: the file extension is ignored if output string
*
* @return void
*/
public function testIgnore()
{
$object = $this->getObject();
$object->writeHTML('Hello World');
$result = $object->output('test.bad', 'S');
$this->assertContains('PhpUnit Test', $result);
}
/**
* test: the file extension must be PDF - Error
*
* @return void
*/
public function testError()
{
$this->expectException(Html2PdfException::class);
$object = $this->getObject();
$object->writeHTML('<p>Hello World</p>');
$object->output('test.bad');
}
}

View File

@ -0,0 +1,73 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Parsing;
use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\Parsing\HtmlLexer;
/**
* Class HtmlLexerTest
*/
class HtmlLexerTest extends PHPUnit_Framework_TestCase
{
/**
* Test: tokenize
*
* @param string $html html to test
* @param array $expectedTokens expected token
*
* @dataProvider tokenizeProvider
*/
public function testTokenize($html, $expectedTokens)
{
$lexer = new HtmlLexer();
$tokens = $lexer->tokenize($html);
$this->assertEquals(count($expectedTokens), count($tokens));
for ($i = 0; $i < count($tokens); $i++) {
$this->assertEquals($expectedTokens[$i][0], $tokens[$i]->getType());
$this->assertEquals($expectedTokens[$i][1], $tokens[$i]->getData());
$this->assertEquals($expectedTokens[$i][2], $tokens[$i]->getLine());
}
}
/**
* provider: tokenize
*
* @return array
*/
public function tokenizeProvider()
{
return array(
array(
'<p>test</p>',
array(
array('code', '<p>', 1),
array('txt', 'test', -1),
array('code', '</p>', 1),
)
),
array(
"<a><!-- comment -->\n<b><c>test",
array(
array('code', '<a>', 1),
array('txt', "\n", -1),
array('code', '<b>', 2),
array('code', '<c>', 2),
array('txt', "test", -1),
)
)
);
}
}

View File

@ -0,0 +1,61 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Parsing;
use Spipu\Html2Pdf\Tests\CrossVersionCompatibility\HtmlTestCase;
/**
* Class HtmlTest
*/
class HtmlTest extends HtmlTestCase
{
/**
* mock of prepareTxt method
*
* @param $txt
* @param bool $spaces
* @return mixed
*/
public function mockPrepareTxt($txt, $spaces = true)
{
return $txt;
}
/**
* Test the prepareHtml method
*/
public function testPrepareHtml()
{
$result = $this->object->prepareHtml('Hello [[date_y]]-[[date_m]]-[[date_d]] World');
$this->assertSame('Hello '.date('Y-m-d').' World', $result);
$result = $this->object->prepareHtml('Hello [[date_h]]:[[date_i]]:[[date_s]] World');
$this->assertSame('Hello '.date('H:i:s').' World', $result);
$html = '
<html>
<head>
<style type="text">.my-class { color: red; }</style>
<link type="text/css" href="my-style.css"/>
</head>
<body class="my-class"><p>Hello World</p></body>
</html>';
$expected='<style type="text">.my-class { color: red; }</style>'.
'<link type="text/css" href="my-style.css"/>'.
'<page class="my-class"><p>Hello World</p></page>';
$result = $this->object->prepareHtml($html);
$this->assertSame($expected, $result);
}
}

View File

@ -0,0 +1,100 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Parsing;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class ParsingTest
*/
class ParsingTest extends AbstractTest
{
/**
* test: The tag is unknown
*
* @return void
*/
public function testUnknownTag()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<bad_tag>Hello World</bad_tag>');
$object->output('test.pdf', 'S');
}
/**
* test: Too many tag closures found
*
* @return void
*/
public function testTooManyClosuresFound()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<i><u>Hello</u></i></b>');
$object->output('test.pdf', 'S');
}
/**
* test: Tags are closed in a wrong order
*
* @return void
*/
public function testWrongClosedOrder()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<b><u><i>Hello</u></i></b>');
$object->output('test.pdf', 'S');
}
/**
* test: The following tag has not been closed
*
* @return void
*/
public function testNotClosed()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<b><i>Hello</i>');
$object->output('test.pdf', 'S');
}
/**
* test: The following tags have not been closed
*
* @return void
*/
public function testNotClosedMore()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<b><u><i>Hello</i>');
$object->output('test.pdf', 'S');
}
/**
* test: The HTML tag code provided is invalid
*
* @return void
*/
public function testInvalidCode()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<az1-r_h>Hello</az1-r_h>');
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,203 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Parsing;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Parsing\Node;
use Spipu\Html2Pdf\Tests\CrossVersionCompatibility\TagParserTestCase;
/**
* Class TagParserTest
*/
class TagParserTest extends TagParserTestCase
{
/**
* mock of prepareTxt method
*
* @param $txt
* @param bool $spaces
* @return mixed
*/
public function mockPrepareTxt($txt, $spaces = true)
{
return $txt;
}
/**
* @param string $code
* @param array $expected
*
* @dataProvider tagAttributesProvider
*/
public function testExtractTagAttributes($code, $expected)
{
$result = $this->parser->extractTagAttributes($code);
$this->assertEquals($expected, $result);
}
/**
* @return array
*/
public function tagAttributesProvider()
{
return array(
array('attr=value', array('attr' => 'value')),
array('attr="value"', array('attr' => 'value')),
array('attr=\'value\'', array('attr' => 'value')),
array('attr="value with spaces"', array('attr' => 'value with spaces')),
array('attr="value with \'quotes"', array('attr' => 'value with \'quotes')),
array('my attr="value"', array('attr' => 'value')),
array('attr1=val1 attr2="value2"', array('attr1' => 'val1', 'attr2' => 'value2')),
);
}
/**
* Test if a bad tag is detected
*/
public function testAnalyzeTagBadTag()
{
$this->expectException(HtmlParsingException::class);
$this->parser->analyzeTag('test');
}
/**
* Test basic open, close, autoclose tags
*/
public function testBasicTags()
{
$result = $this->parser->analyzeTag('<my_tag/>');
$this->assertTrue($result instanceof Node);
$this->assertSame('my_tag', $result->getName());
$this->assertSame(true, $result->isAutoClose());
$this->assertSame(false, $result->isClose());
$result->setLine(10);
$this->assertSame(10, $result->getLine());
$result->setParam('attr', 'value');
$this->assertSame('value', $result->getParam('attr'));
$result = $this->parser->analyzeTag('<my_tag>');
$this->assertSame('my_tag', $result->getName());
$this->assertSame(false, $result->isAutoClose());
$this->assertSame(false, $result->isClose());
$this->assertSame(['style' => [], 'num' => 0], $result->getParams());
$this->assertSame('default', $result->getParam('attr', 'default'));
$result = $this->parser->analyzeTag('</my_tag>');
$this->assertSame('my_tag', $result->getName());
$this->assertSame(false, $result->isAutoClose());
$this->assertSame(true, $result->isClose());
}
/**
* Test styles
*/
public function testAnalyzeAttributes()
{
$result = $this->parser->analyzeTag('<img src="my_src" alt="my alt"/>');
$this->assertSame('my_src', $result->getParam('src'));
$this->assertSame('my alt', $result->getParam('alt'));
$result = $this->parser->analyzeTag('<a href="my_src" title="my title"/>');
$this->assertSame('my_src', $result->getParam('href'));
$this->assertSame('my title', $result->getParam('title'));
$result = $this->parser->analyzeTag('<input type="text" value="my value" class="my_class" />');
$this->assertSame('text', $result->getParam('type'));
$this->assertSame('my value', $result->getParam('value'));
$this->assertSame('my_class', $result->getParam('class'));
$result = $this->parser->analyzeTag('<my_tag width="10" height="20" align="center" valign="bottom" bgcolor="red">');
$this->assertSame('10px', $result->getStyle('width'));
$this->assertSame('20px', $result->getStyle('height'));
$this->assertSame('center', $result->getStyle('text-align'));
$this->assertSame('bottom', $result->getStyle('vertical-align'));
$this->assertSame('red', $result->getStyle('background'));
$result = $this->parser->analyzeTag('<img align="right">');
$this->assertSame('right', $result->getStyle('float'));
$result = $this->parser->analyzeTag('<table cellpadding="1" cellspacing="2">');
$this->assertSame('1px', $result->getParam('cellpadding'));
$this->assertSame('2px', $result->getParam('cellspacing'));
$result = $this->parser->analyzeTag('<td rowspan="0" colspan="2px">');
$this->assertSame(1, $result->getParam('rowspan'));
$this->assertSame(2, $result->getParam('colspan'));
$result = $this->parser->analyzeTag('<my_tag color="red">');
$this->assertSame('red', $result->getParam('color'));
$this->assertSame(null, $result->getStyle('color'));
$result = $this->parser->analyzeTag('<font color="red">');
$this->assertSame(null, $result->getParam('color'));
$this->assertSame('red', $result->getStyle('color'));
}
/**
* Test borders
*/
public function testBorders()
{
$result = $this->parser->analyzeTag('<div border="1" bordercolor="red" />');
$this->assertSame('div', $result->getName());
$this->assertSame('solid 1px red', $result->getParam('border'));
$this->assertSame('solid 1px red', $result->getStyle('border'));
$result = $this->parser->analyzeTag('<div border="0" bordercolor="red" />');
$this->assertSame('div', $result->getName());
$this->assertSame('none', $result->getParam('border'));
$this->assertSame('none', $result->getStyle('border'));
}
/**
* Test levels
*/
public function testLevels()
{
$result = $this->parser->analyzeTag('<basic_tag>');
$this->assertSame(0, $result->getParam('num'));
$result = $this->parser->analyzeTag('<table>');
$this->assertSame(1, $result->getParam('num'));
$result = $this->parser->analyzeTag('<ol>');
$this->assertSame(2, $result->getParam('num'));
$result = $this->parser->analyzeTag('<ul>');
$this->assertSame(3, $result->getParam('num'));
$result = $this->parser->analyzeTag('</ul>');
$this->assertSame('ul', $result->getName());
$this->assertSame(3, $result->getParam('num'));
$result = $this->parser->analyzeTag('</ol>');
$this->assertSame(2, $result->getParam('num'));
$result = $this->parser->analyzeTag('</table>');
$this->assertSame(1, $result->getParam('num'));
$result = $this->parser->analyzeTag('<basic_tag>');
$this->assertSame(0, $result->getParam('num'));
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Parsing;
use Spipu\Html2Pdf\Tests\CrossVersionCompatibility\TextParserTestCase;
/**
* Class TextParserTest
*/
class TextParserTest extends TextParserTestCase
{
/**
* Test if it works
*/
public function testOk()
{
$result = $this->parser->prepareTxt('hello world', false);
$this->assertSame('hello world', $result);
$result = $this->parser->prepareTxt('hello world', true);
$this->assertSame('hello world', $result);
$result = $this->parser->prepareTxt('hello 10&euro; world');
$this->assertSame('hello 10€ world', $result);
$result = $this->parser->prepareTxt('hello &lt; world');
$this->assertSame('hello < world', $result);
}
}

View File

@ -0,0 +1,34 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Parsing;
use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\Parsing\Token;
/**
* Class TokenTest
*/
class TokenTest extends PHPUnit_Framework_TestCase
{
/**
* Test if it works
*/
public function testOk()
{
$token = new Token('hello', 'world', 45);
$this->assertSame('hello', $token->getType());
$this->assertSame('world', $token->getData());
$this->assertSame(45, $token->getLine());
}
}

View File

@ -0,0 +1,280 @@
<?php
namespace Spipu\Html2Pdf\Tests;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\CrossVersionCompatibility\SvgDrawerTestCase;
/**
* Class SvgDrawerTest
*/
class SvgDrawerTest extends SvgDrawerTestCase
{
/**
* Test IsDrawing Exception
*/
public function testIsDrawingException()
{
$this->expectException(HtmlParsingException::class);
$properties = [
'x' => 0,
'y' => 0,
'w' => '100mm',
'h' => '100mm',
];
$this->svgDrawer->startDrawing($properties);
$this->svgDrawer->startDrawing($properties);
}
/**
* Test IsDrawing
*/
public function testIsDrawingOk()
{
$properties = [
'x' => 0,
'y' => 0,
'w' => 100,
'h' => 100,
];
$this->assertFalse($this->svgDrawer->isDrawing());
$this->svgDrawer->startDrawing($properties);
$this->assertTrue($this->svgDrawer->isDrawing());
$this->svgDrawer->stopDrawing();
$this->assertFalse($this->svgDrawer->isDrawing());
}
/**
* Test properties
*/
public function testProperties()
{
$properties = [
'x' => 1,
'y' => 2,
'w' => 3,
'h' => 4,
];
$this->svgDrawer->startDrawing($properties);
$this->assertSame(1, $this->svgDrawer->getProperty('x'));
$this->assertSame(2, $this->svgDrawer->getProperty('y'));
$this->assertSame(3, $this->svgDrawer->getProperty('w'));
$this->assertSame(4, $this->svgDrawer->getProperty('h'));
}
/**
* Test: tokenize
*
* @param mixed $transform
* @param mixed $expected
*
* @dataProvider transformProvider
*/
public function testTransform($transform, $expected)
{
$properties = [
'x' => 0,
'y' => 0,
'w' => 100,
'h' => 100,
];
$this->svgDrawer->startDrawing($properties);
$result = $this->svgDrawer->prepareTransform($transform);
$this->assertArraySame($expected, $result);
}
/**
* @param array $expected
* @param array $result
*/
protected function assertArraySame($expected, $result)
{
if (is_array($expected)) {
foreach ($expected as $key => $value) {
$expected[$key] = round($value, 5);
}
}
if (is_array($result)) {
foreach ($result as $key => $value) {
$result[$key] = round($value, 5);
}
}
$this->assertSame($expected, $result);
}
/**
* provider: tokenize
*
* @return array
*/
public function transformProvider()
{
return array(
array(
false,
null
),
array(
'no instruction',
null
),
array(
'foo(1,2)',
null
),
array(
'before scale( 0.1 , 0.2 ) after',
[
0.1, 0.,
0., 0.2,
0., 0.
]
),
array(
'scale(0.1,0.2)',
[
0.1, 0.,
0., 0.2,
0., 0.
]
),
array(
'scale(0.1)',
[
0.1, 0.,
0., 0.1,
0., 0.
]
),
array(
'scale(,)',
[
1., 0.,
0., 1.,
0., 0.
]
),
array(
'scale()',
[
1., 0.,
0., 1.,
0., 0.
]
),
array(
'translate()',
[
1., 0.,
0., 1.,
0., 0.
]
),
array(
'translate(10mm)',
[
1., 0.,
0., 1.,
10., 0.
]
),
array(
'translate(10mm, 20mm)',
[
1., 0.,
0., 1.,
10., 20.
]
),
array(
'rotate()',
[
1., 0.,
0., 1.,
0., 0.
]
),
array(
'rotate(90)',
[
0., 1.,
-1., 0.,
0., 0.
]
),
array(
'rotate(180)',
[
-1., 0.,
0., -1.,
0., 0.
]
),
array(
'rotate(180, 10mm, 10mm)',
[
-1., 0.,
0., -1.,
-20., -20.
]
),
array(
'skewx()',
[
1., 0.,
0., 1.,
0., 0.
]
),
array(
'skewx(45)',
[
1., 0.,
1., 1.,
0., 0.
]
),
array(
'skewy()',
[
1., 0.,
0., 1.,
0., 0.
]
),
array(
'skewy(45)',
[
1., 1.,
0., 1.,
0., 0.
]
),
array(
'matrix()',
[
0., 0.,
0., 0.,
0., 0.
]
),
array(
'matrix(1,2,3,4,5%,6%)',
[
1., 2.,
3., 4.,
5., 6.
]
),
);
}
}

View File

@ -0,0 +1,98 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Div Tag test
*/
class DivTest extends AbstractTest
{
/**
* test No Break
*
* @return void
*/
public function testNoBreak()
{
$html = '<p>First Tag</p>';
$html.= '<div>Second Tag</div>';
$html.= '<p>Third Tag</p>';
$object = $this->getObject();
$object->writeHTML($html);
$result = $object->output('test.pdf', 'S');
$this->assertNotEmpty($result);
$this->assertSame(1, $object->getNbPages());
}
/**
* test Break Before
*
* @return void
*/
public function testBreakBefore()
{
$html = '<p>First Tag</p>';
$html.= '<div style="page-break-before:always">Second Tag</div>';
$html.= '<p>Third Tag</p>';
$object = $this->getObject();
$object->writeHTML($html);
$result = $object->output('test.pdf', 'S');
$this->assertNotEmpty($result);
$this->assertSame(2, $object->getNbPages());
}
/**
* test Break After
*
* @return void
*/
public function testBreakAfter()
{
$html = '<p>First Tag</p>';
$html.= '<div style="page-break-after:always">Second Tag</div>';
$html.= '<p>Third Tag</p>';
$object = $this->getObject();
$object->writeHTML($html);
$result = $object->output('test.pdf', 'S');
$this->assertNotEmpty($result);
$this->assertSame(2, $object->getNbPages());
}
/**
* test Break before and After
*
* @return void
*/
public function testBreakBeforeAndAfter()
{
$html = '<p>First Tag</p>';
$html.= '<div style="page-break-before:always; page-break-after:always">Second Tag</div>';
$html.= '<p>Third Tag</p>';
$object = $this->getObject();
$object->writeHTML($html);
$result = $object->output('test.pdf', 'S');
$this->assertNotEmpty($result);
$this->assertSame(3, $object->getNbPages());
}
}

View File

@ -0,0 +1,76 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class Thead must not be empty
*/
class MustHaveTagsTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testOk()
{
$html = '<table>';
$html.= '<thead><tr><td>Hello</td></tr></thead>';
$html.= '<tbody><tr><td>World</td></tr></tbody>';
$html.= '</table>';
$object = $this->getObject();
$object->writeHTML($html);
$result = $object->output('test.pdf', 'S');
$this->assertNotEmpty($result);
}
/**
* test
*
* @return void
*/
public function testNotEmptyThead()
{
$this->expectException(\Spipu\Html2Pdf\Exception\HtmlParsingException::class);
$html = '<table>';
$html.= '<thead></thead>';
$html.= '<tbody><tr><td>World</td></tr></tbody>';
$html.= '</table>';
$object = $this->getObject();
$object->writeHTML($html);
$object->output('test.pdf', 'S');
}
/**
* test
*
* @return void
*/
public function testNotEmptyTfoot()
{
$this->expectException(\Spipu\Html2Pdf\Exception\HtmlParsingException::class);
$html = '<table>';
$html.= '<tfoot></tfoot>';
$html.= '<tbody><tr><td>World</td></tr></tbody>';
$html.= '</table>';
$object = $this->getObject();
$object->writeHTML($html);
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag\Svg;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class CircleErrorTest
*/
class CircleErrorTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<circle />');
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag\Svg;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class EllipseErrorTest
*/
class EllipseErrorTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<ellipse />');
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag\Svg;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class GErrorTest
*/
class GErrorTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<g />');
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag\Svg;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class LineErrorTest
*/
class LineErrorTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<line />');
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag\Svg;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class PathErrorTest
*/
class PathErrorTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<path />');
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag\Svg;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class PathInvalidTest
*/
class PathInvalidTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(HtmlParsingException::class);
$html = '
<page>
<draw style="width:150mm; height:100mm;">
<path style="fill:#770000; stroke:#AA0033;" d="n 20mm,40mm a16mm,8mm 0,0,0 16mm,8mm" />
</draw>
</page>';
$object = $this->getObject();
$object->writeHTML($html);
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag\Svg;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class PolygonErrorTest
*/
class PolygonErrorTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<polygon />');
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag\Svg;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class PolylineErrorTest
*/
class PolylineErrorTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<polyline />');
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag\Svg;
use Spipu\Html2Pdf\Exception\HtmlParsingException;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class RectErrorTest
*/
class RectErrorTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(HtmlParsingException::class);
$object = $this->getObject();
$object->writeHTML('<rect />');
$object->output('test.pdf', 'S');
}
}

View File

@ -0,0 +1,40 @@
<?php
/**
* Html2Pdf Library - Tests
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
namespace Spipu\Html2Pdf\Tests\Tag;
use Spipu\Html2Pdf\Tests\AbstractTest;
/**
* Class TdTooLongTest
*/
class TdTooLongTest extends AbstractTest
{
/**
* test
*
* @return void
*/
public function testCase()
{
$this->expectException(\Spipu\Html2Pdf\Exception\TableException::class);
$sentence = 'Hello World ! ';
$sentences = '';
for ($k=0; $k<100; $k++) {
$sentences.= $sentence;
}
$object = $this->getObject();
$object->writeHTML('<table><tr><td style="width: 28mm">'.$sentences.'</td></tr></table>');
$object->output('test.pdf', 'S');
}
}

38
vendor/spipu/html2pdf/composer.json vendored Normal file
View File

@ -0,0 +1,38 @@
{
"name": "spipu/html2pdf",
"type": "library",
"description": "Html2Pdf is a HTML to PDF converter written in PHP5 (it uses TCPDF). OFFICIAL PACKAGE",
"keywords": ["html", "pdf", "html2pdf"],
"homepage": "http://html2pdf.fr/",
"license": "OSL-3.0",
"authors": [
{
"name": "Spipu",
"homepage": "https://github.com/spipu",
"role": "Developer"
}
],
"require": {
"php": "^5.6 || ^7.0 || ^8.0",
"ext-mbstring": "*",
"ext-gd": "*",
"tecnickcom/tcpdf": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^9.0"
},
"suggest": {
"fagundes/zff-html2pdf": "if you need to integrate Html2Pdf with Zend Framework 2 (zf2)",
"ext-gd": "Allows to embed images into the PDF"
},
"autoload": {
"psr-4": {
"Spipu\\Html2Pdf\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Spipu\\Html2Pdf\\Tests\\": "Tests/"
}
}
}

68
vendor/spipu/html2pdf/doc/README.md vendored Normal file
View File

@ -0,0 +1,68 @@
# Html2Pdf Documentation
## Documentation
* [How to Install Html2Pdf](./install.md)
* [Basic Usage](./basic.md)
* [Page and Margin](./page.md)
* [Output](./output.md)
* [Barcode](./barcode.md)
* [Bookmark](./bookmark.md)
* [Font](./font.md)
* [SVG](./svg.md)
* [Electronic Signature](./cert.md)
* [Extensions](./extension.md)
* [Exceptions](./exception.md)
* [Useful Methods](./methods.md)
* [Tcpdf Methods](./tcpdf_methods.md)
## Recommandations
* It is very important to provide valid HTML 4.01 to the converter, but only what is in the `<body>`.
* Use the `<page>` tag. Does not use the `<html>` or `<body>` tag.
* for borders: it is advised that they are like `solid 1mm #000000`
* for padding, they are applicable only on tags `table`, `th`, `td`, `div`, `li`
* A default font can be specified, if the requested font does not exist or if no font is specified: `$html2pdf->setDefaultFont('Arial');`
* The possibility to protect your PDF is present, CF Example 7.
* Some tests can be enabled (true) or disabled (false):
* `setTestIsImage` method: test that images must exist
* `setTestTdInOnePage` method: test that the contents of TDs fit on one page
* A DEBUG mode to know the resources used is present. It is activated by adding the following command just after the contructor (see Example 0): `$html2pdf->setModeDebug();`
* Some specific tags have been introduced:
* `<page></page>` (CF Example 7)
* Determines the orientation, margins left, right, top and bottom, the background image and the background color of a page, its size and position, the footer.
* It is also possible to keep the header and footer of the previous pages, through the attribut `pageset="old"` (see Example 3 & 4)
* `<page_header></page_header>` (CF Example 3)
* `<page_footer></page_footer>` (CF Example 3)
* `<nobreak></nobreak>`
* Used to force the display of a section on the same page.
* If this section does not fit into the rest of the page, a page break is done before.
* `<barcode></barcode>` (CF Examples 0 & 9)
* Can insert barcodes in pdfs, CF Examples 0 and 9.
* the possible types of codebar are alls of TCPDF.
* `<qrcode></qrcode>` (CF Example 13)
* can insert QRcode 2D barcodes
* (QR Code is registered trademark of DENSO WAVE INCORPORATED)
* `<bookmark></bookmark>` (CF Examples 7 & About)
* Can insert bookmark in pdfs, CF Example 7 and About.
* It is also possible to automatically create an index at the end of document (CF Example About)
* `<end_last_page end_height="30mm"></end_last_page>` (CF Example 5)
* css property `rotate`:
* Values : 0, 90, 180, 270
* Works only on div (cf example 8)

89
vendor/spipu/html2pdf/doc/barcode.md vendored Normal file
View File

@ -0,0 +1,89 @@
# BarCode
[back](./README.md)
## tag barcode
You can add barcode, by directly inserting the `<barcode>` tag in the HTML to convert :
```html
<barcode dimension="1D" type="EAN13" value="45" label="label" style="width:30mm; height:6mm; color: #770000; font-size: 4mm"></barcode>
```
### attributes
Attribute| Default | Description
---------|---------|-------------
dimension | 1D | create a 1D or 2D barcode
type| C39 | type of barcode to use
value| 0 | value to convert into barcode
label| label | indicates that the label must be present below the bar code (label) or not (none) (not required)
style| | sets the color for the bar, its width and height (without the label) and the size of the label if it is displayed (not required)
### 1D types
For 1D bar-codes, the possible values for `type` attribute are:
Type| Description
----|------------
C39| CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
C39+| CODE 39 with checksum
C39E| CODE 39 EXTENDED
C39E+| CODE 39 EXTENDED + CHECKSUM
C93| CODE 93 - USS-93
S25| Standard 2 of 5
S25+| Standard 2 of 5 + CHECKSUM
I25| Interleaved 2 of 5
I25+| Interleaved 2 of 5 + CHECKSUM
C128| CODE 128
C128A| CODE 128 A
C128B| CODE 128 B
C128C| CODE 128 C
EAN2| 2-Digits UPC-Based Extension
EAN5| 5-Digits UPC-Based Extension
EAN8| EAN 8
EAN13| EAN 13
UPCA| UPC-A
UPCE| UPC-E
MSI| MSI (Variation of Plessey code)
MSI+| MSI + CHECKSUM (modulo 11)
POSTNET| POSTNET
PLANET| PLANET
RMS4CC| RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
KIX| KIX (Klant index - Customer index)
IMB| IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
IMBPRE| IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200- pre-processed
CODABAR| CODABAR
CODE11| CODE 11
PHARMA| PHARMACODE
PHARMA2T| PHARMACODE TWO-TRACKS
### 2D types
For 2D barcodes, the possible values for `type` attribute are:
Type| Description
----|------------
DATAMATRIX| DATAMATRIX (ISO/IEC 16022)
PDF417| PDF417 (ISO/IEC 15438:2006)
QRCODE| QR-CODE
RAW| RAW MODE
RAW2| RAW MODE
## tag qrcode
You can directly add bar-codes to two-dimensional QR-Code, by inserting the tag QRcode directly in the HTML to convert:
```html
<qrcode value="Value to Coder" ec="H" style="width: 50mm; background-color: white; color: black;"></qrcode>
```
### attributes
Attribute| Default | Description
---------|---------|-------------
value| | value to convert into barcode
ec| H | level of error correction (L, M, Q, H)
style| | sets the width, color, background-color, and border of the qrcode
[back](./README.md)

75
vendor/spipu/html2pdf/doc/basic.md vendored Normal file
View File

@ -0,0 +1,75 @@
# Basic Usage
[back](./README.md)
## PHP Constructor
The main class of this library is `\Spipu\Html2Pdf\Html2Pdf`.
The PHP constructor takes the following parameters:
Variable | Default value |Description
---------|---------------|--------------
$orientation | P | The default page orientation, can be P (portrait) or L (landscape)
$format | A4 | The default page format used for pages. The list of the available value are [here](https://github.com/tecnickcom/TCPDF/blob/485956db63b5a225760e80fa2278bdb22eca4650/include/tcpdf_static.php#L2129). You can also give a array with 2 values the width and the height in mm.
$lang | fr | Language to use, for some minor translations. The list of the available languages are [here](https://github.com/spipu/html2pdf/tree/master/src/locale)
$unicode | true | means that the input HTML string is unicode
$encoding |UTF-8 | charset encoding of the input HTML string
$margins | array(5, 5, 5, 8) | Main margins of the page (left, top, right, bottom) in mm
$pdfa | false | If TRUE set the document to PDF/A mode
In most of the case, you will just use the 3 first parameters :
```php
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
```
## Convert the HTML
The main method to use is `writeHTML`.
It takes one parameter : the HTML in string format that you want to convert into PDF.
```php
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first test');
```
You can call it more than one time, if you want to split the conversion in order to use less memory. It will continue on the same page, directly at the end of the last converted part.
```php
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first text');
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my second text');
```
If you want to separate on a new page, you can use the specific HTML tag `page`.
```php
$html2pdf->writeHTML('<page><h1>HelloWorld</h1>This is my first page</page>');
$html2pdf->writeHTML('<page><h1>HelloWorld</h1>This is my second page</page>');
```
You can find more information about this specific tag on the [page](page.md) documentation.
## Get the PDF
The main method to use is `output`.
It takes two not required parameters. You can find more information on the [output](output.md) documentation.
If you do not give any parameters, it will send the PDF file to the browser, to display it.
```php
$html2pdf->output();
```
## Full Example
Here is the full code for a helloworld example:
```php
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first page');
$html2pdf->output();
```
[back](./README.md)

228
vendor/spipu/html2pdf/doc/bookmark.md vendored Normal file
View File

@ -0,0 +1,228 @@
# Bookmark
[back](./README.md)
## tag bookmark
You can add automatic bookmark, by directly inserting the `<bookmark>` tag in the HTML to convert :
```html
<bookmark title="My Title" level="0" ></bookmark>
```
### attributes
Attribute| Default | Description
---------|---------|-------------
title | | Title of the bookmark
level | 0 | Level of the bookmark, must be a positive integer. Level 0 is the main level
## Page Index
You can insert an index (summary) of all bookmarks automatically, using the following function :
```php
$html2pdf->createIndex($titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName, $marginTop);
```
### parameters
Parameter| Default | Description
---------|---------|-------------
$title | Index | index title
$sizeTitle | 20 | font size of the index title, in mm
$sizeBookmark | 15 | font size of the index, in mm
$bookmarkTitle | true | add a bookmark for the index, at his beginning
$displayPage | true | display the page numbers
$onPage | null | if null : at the end of the document on a new page, else on the $onPage page
$fontName | null | font name to use. If null, use helvetica
$marginTop | null | margin top to use on the index page
**IMPORTANT**:
If you want the summary index on a specific page (using $onPage) you must have anticipated this page during the creation of HTML (see example below).
Furthermore, if the summary index takes more than one page, you must have provided the necessary number of pages...
## Example with automatic index on last page
```html
<style type="text/css">
<!--
table.page_header {width: 100%; border: none; background-color: #DDDDFF; border-bottom: solid 1mm #AAAADD; padding: 2mm }
table.page_footer {width: 100%; border: none; background-color: #DDDDFF; border-top: solid 1mm #AAAADD; padding: 2mm}
h1 {color: #000033}
h2 {color: #000055}
h3 {color: #000077}
div.standard
{
padding-left: 5mm;
}
-->
</style>
<page backtop="14mm" backbottom="14mm" backleft="10mm" backright="10mm" style="font-size: 12pt">
<page_header>
<table class="page_header">
<tr>
<td style="width: 100%; text-align: left">
Example of using bookmarks
</td>
</tr>
</table>
</page_header>
<page_footer>
<table class="page_footer">
<tr>
<td style="width: 100%; text-align: right">
page [[page_cu]]/[[page_nb]]
</td>
</tr>
</table>
</page_footer>
<bookmark title="Chapter 1" level="0" ></bookmark><h1>Chapter 1</h1>
<div class="standard">
Contents of Chapter 1
</div>
</page>
<page pageset="old">
<bookmark title="Chapter 2" level="0" ></bookmark><h1>Chapter 2</h1>
<div class="standard">
Intro to Chapter 2
<bookmark title="Chapter 2.1" level="1" ></bookmark><h2>Chapter 2.1</h2>
<div class="standard">
Contents of Chapter 2.1
</div>
<bookmark title="Chapter 2.2" level="1" ></bookmark><h2>Chapter 2.2</h2>
<div class="standard">
Contents of Chapter 2.2
</div>
<bookmark title="Chapter 2.3" level="1" ></bookmark><h2>Chapter 2.3</h2>
<div class="standard">
Contents of Chapter 2.3
</div>
</div>
</page>
<page pageset="old">
<bookmark title="Chapter 3" level="0" ></bookmark><h1>Chapter 3</h1>
<div class="standard">
Intro to Chapter 3
<bookmark title="Chapter 3.1" level="1" ></bookmark><h2>Chapter 3.1</h2>
<div class="standard">
Contents of Chapter 3.1
</div>
<bookmark title="Chapter 3.2" level="1" ></bookmark><h2>Chapter 3.2</h2>
<div class="standard">
Intro to Chapter 3.2
<bookmark title="Chapter 3.2.1" level="2" ></bookmark><h3>Chapter 3.2.1</h3>
<div class="standard">
Contents of Chapter 3.2.1
</div>
<bookmark title="Chapter 3.2.2" level="2" ></bookmark><h3>Chapter 3.2.2</h3>
<div class="standard">
Contents of Chapter 3.2.2
</div>
</div>
</div>
</page>
```
```php
$html2pdf = new Spipu\Html2Pdf\Html2Pdf('P','A4','en');
$html2pdf->writeHTML($html);
$html2pdf->createIndex('Summary', 25, 12, true, true);
$html2pdf->output();
```
## Example with automatic index on specific page
```html
<style type="text/css">
<!--
table.page_header {width: 100%; border: none; background-color: #DDDDFF; border-bottom: solid 1mm #AAAADD; padding: 2mm }
table.page_footer {width: 100%; border: none; background-color: #DDDDFF; border-top: solid 1mm #AAAADD; padding: 2mm}
h1 {color: #000033}
h2 {color: #000055}
h3 {color: #000077}
div.standard
{
padding-left: 5mm;
}
-->
</style>
<page backtop="14mm" backbottom="14mm" backleft="10mm" backright="10mm" style="font-size: 12pt">
<page_header>
<table class="page_header">
<tr>
<td style="width: 100%; text-align: left">
Example of using bookmarks
</td>
</tr>
</table>
</page_header>
<page_footer>
<table class="page_footer">
<tr>
<td style="width: 100%; text-align: right">
page [[page_cu]]/[[page_nb]]
</td>
</tr>
</table>
</page_footer>
<bookmark title="Summary" level="0" ></bookmark>
</page>
<page pageset="old">
<bookmark title="Chapter 1" level="0" ></bookmark><h1>Chapter 1</h1>
<div class="standard">
Contents of Chapter 1
</div>
</page>
<page pageset="old">
<bookmark title="Chapter 2" level="0" ></bookmark><h1>Chapter 2</h1>
<div class="standard">
Intro to Chapter 2
<bookmark title="Chapter 2.1" level="1" ></bookmark><h2>Chapter 2.1</h2>
<div class="standard">
Contents of Chapter 2.1
</div>
<bookmark title="Chapter 2.2" level="1" ></bookmark><h2>Chapter 2.2</h2>
<div class="standard">
Contents of Chapter 2.2
</div>
<bookmark title="Chapter 2.3" level="1" ></bookmark><h2>Chapter 2.3</h2>
<div class="standard">
Contents of Chapter 2.3
</div>
</div>
</page>
<page pageset="old">
<bookmark title="Chapter 3" level="0" ></bookmark><h1>Chapter 3</h1>
<div class="standard">
Intro to Chapter 3
<bookmark title="Chapter 3.1" level="1" ></bookmark><h2>Chapter 3.1</h2>
<div class="standard">
Contents of Chapter 3.1
</div>
<bookmark title="Chapter 3.2" level="1" ></bookmark><h2>Chapter 3.2</h2>
<div class="standard">
Intro to Chapter 3.2
<bookmark title="Chapter 3.2.1" level="2" ></bookmark><h3>Chapter 3.2.1</h3>
<div class="standard">
Contents of Chapter 3.2.1
</div>
<bookmark title="Chapter 3.2.2" level="2" ></bookmark><h3>Chapter 3.2.2</h3>
<div class="standard">
Contents of Chapter 3.2.2
</div>
</div>
</div>
</page>
```
```php
$html2pdf = new Spipu\Html2Pdf\Html2Pdf('P','A4','en');
$html2pdf->writeHTML($html);
$html2pdf->createIndex('Summary', 25, 12, false, true, 1);
$html2pdf->output();
```
[back](./README.md)

32
vendor/spipu/html2pdf/doc/cert.md vendored Normal file
View File

@ -0,0 +1,32 @@
# Electronic Signature
[back](./README.md)
You can add an electronic signature to the PDF, by using the following specific html TAG:
```
<cert
src="/path/to/cert.pem"
privkey="/path/to/priv.pem"
name="sender_name"
location="sender_location"
reason="sender_reason"
contactinfo="sender_contact"
>
/** html **/
</cert>
```
Attribute | Description | Example 1 | Example 2
------------|-----------------------------------|---------------------|-------------------
src | Path to the Cert | /www/certs/my.pem | /www/certs/my.crt
privkey | Private key of the Cert if needed | /www/certs/priv.pem | nothing
name | Name of the Cert | My.org Cert |
location | Country of the Cert | France |
reason | Purpose of the Cert | Invoice validation |
contactinfo | EMail of organisation's contact | contact@my.org |
/** HTML **/
part could be any HTML formatted string, img, etc...
[back](./README.md)

48
vendor/spipu/html2pdf/doc/exception.md vendored Normal file
View File

@ -0,0 +1,48 @@
# Exception
[back](./README.md)
## Exceptions
All the specific Html2Pdf exceptions are under the namespace `\Spipu\Html2Pdf\Exception`;
Exception|Error Code|Additional Info|Description
---------|----------|---------------|-----------
Html2PdfException | 0 | | Occurs for every generic error during the process
HtmlParsingException | 1 | <ul><li>getInvalidTag</li><li>getHtmlLine</li></ul> | Occurs if the html is no valid
ImageException | 2 | <ul><li>getImage</li></ul> | Occurs if the asked image does not exist
LongSentenceException | 3 | <ul><li>getSentence</li><li>getWidthBox</li><li>getLength</li></ul> | Occurs is a sentence is too long and does not fit in the current box
TableException | 4 | | Occurs if the content of a TD does not fit on only one page
## Exception Format
An exception formatter can be used to display the exceptions: `\Spipu\Html2Pdf\Exception\ExceptionFormatter`.
It takes the current exception as a parameter of the constructor.
It provides 2 methods
* getMessage()
* getHtmlMessage();
Usage example:
```php
try {
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
$html2pdf = new Html2Pdf('P', 'A4', 'fr');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($htmlContent);
$html2pdf->output();
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}
```
[back](./README.md)

141
vendor/spipu/html2pdf/doc/extension.md vendored Normal file
View File

@ -0,0 +1,141 @@
# Extensions and Tags
[back](./README.md)
## Html Tags
All the existing tags are under the namespace `\Spipu\Html2Pdf\Tag`.
A tag must implement the interface `\Spipu\Html2Pdf\Tag\TagInterface`.
A tag can extends the abstract class `\Spipu\Html2Pdf\Tag\AbstractTag` to implement some generic methods.
Here is a tag example that will do nothing:
```php
<?php
namespace Example\Html2Pdf\Tag;
use \Spipu\Html2Pdf\Tag\AbstractTag;
/**
* Tag Example
*/
class Example extends AbstractTag
{
/**
* get the name of the tag
*
* @return string
*/
public function getName()
{
return 'example';
}
/**
* Open the HTML tag
*
* @param array $properties properties of the HTML tag
*
* @return boolean
*/
public function open($properties)
{
// there is nothing to do here
return true;
}
/**
* Close the HTML tag
*
* @param array $properties properties of the HTML tag
*
* @return boolean
*/
public function close($properties)
{
// there is nothing to do here
return true;
}
}
```
Then, you will be able to use the `<example>` html tag.
Look at all the existing tags in the `/src/Tag` folder to see examples.
## Extensions
In order to add your new tags to Html2Pdf, you must a extension.
An extension must implement the interface `\Spipu\Html2Pdf\Extension\ExtensionInterface`.
You must implement the `getTags` method that will return a list of tag objects.
```php
<?php
/**
* Extension Example
*/
namespace Example\Html2Pdf\Extension;
use \Spipu\Html2Pdf\Extension\ExtensionInterface;
/**
* Class MyExtension
*/
class MyExtension implements ExtensionInterface
{
/**
* @var array
*/
private $tagDefinitions = array();
/**
* {@inheritDoc}
*/
public function getName()
{
return 'example_extension';
}
/**
* {@inheritDoc}
*/
public function getTags()
{
if (empty($this->tagDefinitions)) {
$this->tagDefinitions = array(
new \Example\Html2Pdf\Tag\Example(),
new \Example\Html2Pdf\Tag\Other(),
);
}
return $this->tagDefinitions;
}
}
```
Then, you can add your extension to Html2Pdf with the following method:
```php
$html2pdf->addExtension(new \Example\Html2Pdf\Extension\MyExtension());
```
The following core extensions are automatically added to Html2pdf:
* `\Spipu\Html2Pdf\Extension\Core\HtmlExtension`
* `\Spipu\Html2Pdf\Extension\Core\SvgExtension`
It contains all the native tags.
## Overriding
If an extension has the same name that an already added extension, it will replace the first one.
If tag has the same name that an already added tag throw an extension, it will replace the first one.
[back](./README.md)

44
vendor/spipu/html2pdf/doc/font.md vendored Normal file
View File

@ -0,0 +1,44 @@
# Font
[back](./README.md)
## Creating new Font
To create new font, you should use this tutorial from TCPDF:
https://tcpdf.org/docs/fonts/
## Adding new font
To use this new font, you must add it to Html2Pdf, by using the following method:
```php
$html2pdf->addFont($family, $style, $file);
```
The parameters are:
Parameter| Default | Description
---------|---------|-------------
$family | | Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.
$style | | Font style. Possible values are (case insensitive):<ul><li>empty string: regular (default)</li><li>B: bold</li><li>I: italic</li><li>BI or IB: bold italic</li></ul>
$file | | The font definition file. By default, the name is built from the family and style, in lower case with no spaces.
If you want to add font for normal and for bold style, you must call the `addFont` method twice, one for each font file.
**WARNING**:
In 4em parameter constructor of Html2pdf, you must specify whether you use a Unicode font (true) or an old font (false).
## Using new font
You have just to se the new font family name in your css.
## Setting the default font
You can set the default font to use with the following method:
```php
$html2pdf->setDefaultFont($default);
```
[back](./README.md)

49
vendor/spipu/html2pdf/doc/install.md vendored Normal file
View File

@ -0,0 +1,49 @@
# How to Install Html2Pdf
[back](./README.md)
## Composer and Packagist
You have to use Composer to install Html2Pdf.
If you do not know what is Composer:
* You can find the documentation on https://getcomposer.org/doc/
* You can find all the available packages on https://packagist.org/
* For example, you can find Html2Pdf: https://packagist.org/packages/spipu/html2pdf
## Install
You just have to launch the following command on the root folder of your project:
```bash
composer require spipu/html2pdf
```
If you do not want to use composer, you will need to:
* manually clone the html2pdf repository
* manually clone all the repositories of the used dependencies
* manage manually the PS4 autoload
But it is not the recommaned way to instal Html2Pdf. No help will be provided in this case.
### First Test
Here is a HelloWorld example, that you can put on the root folder of your project.
```php
require __DIR__.'/vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
$html2pdf = new Html2Pdf();
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first test');
$html2pdf->output();
```
Html2Pdf use the PSR-4 autoloader of Composer. You have just to require it. Never require manually the classes, it will not work at all. You must use the Composer functionnalities.
Then, you have just to use the main class `Spipu\Html2Pdf\Html2Pdf`, with the 2 main methods `writeHTML` and `output`.
[back](./README.md)

65
vendor/spipu/html2pdf/doc/methods.md vendored Normal file
View File

@ -0,0 +1,65 @@
# Useful Methods
[back](./README.md)
## Image Must Exist
By default, if you try to use an image that Html2Pdf can not read, it will throw an `ImageException`.
You can disable this test with the following method:
```php
$html2pdf->setTestIsImage(false);
```
If you disable the test, and if an image does not exist, it will display a 16x16 grey square instead.
## FallBack Image
If you disable the "Image Must Exist" test, you can specify a fallback image with the following method:
```php
$html2pdf->setFallbackImage($imageFilename);
```
## Can not split TD content
By default, the content of a TD should not exceed one page.
You can disable this protection with the following method:
```php
$html2pdf->setTestTdInOnePage(false);
```
**WARNING**:
If you disable this test, you may have big layouts problems on tables in multiple columns.
Rather than disabling this test it is better to break the TD content in smaller ones.
**We do not support the consequencies of disable this test.**
## Debug Mode
You can enable a debug mode by using the following method:
```php
$html2pdf->setModeDebug();
```
You can specify your own debugger. It must implement `\Spipu\Html2Pdf\Debug\DebugInterface`.
```php
$debug = new \Spipu\Html2Pdf\Debug\Debug();
$html2pdf->setModeDebug($debug);
```
## Version
You can get the current Html2Pdf version with the following methods:
```php
$html2pdf->getVersion();
$html2pdf->getVersionAsArray();
```
[back](./README.md)

50
vendor/spipu/html2pdf/doc/output.md vendored Normal file
View File

@ -0,0 +1,50 @@
# Output
[back](./README.md)
The main method to use is `output`.
It takes two not required parameters.
## Parameters
Parameter| Default | Description
---------|---------|-------------
$name | document.pdf | The name of the file when saved. Note that special characters are removed and blanks characters are replaced with the underscore character.
$dest | I | Destination where to send the document. It can take one of the following values:<ul><li>I: send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.</li><li>D: send to the browser and force a file download with the name given by name.</li><li>F: save to a local server file with the name given by name.</li><li>S: return the document as a string (name is ignored).</li><li>FI: equivalent to F + I option</li><li>FD: equivalent to F + D option</li><li>E: return the document as base64 mime multi-part email attachment (RFC 2045)</li></ul>
## Examples
### Send PDF to browser without specifying a name
```php
$html2pdf->output();
```
### Send the PDF document in browser with a specific name
```php
$html2pdf->output('my_doc.pdf');
```
### Forcing the download of PDF via web browser, with a specific name
```php
$html2pdf->output('my_doc.pdf', 'D');
```
### Write the contents of a PDF file on the server
```php
$html2pdf->output('/absolute/path/file_xxxx.pdf', 'F');
```
### Retrieve the contents of the PDF and then do whatever you want
```php
$pdfContent = $html2pdf->output('my_doc.pdf', 'S');
```
Then, you can send it by email, using a Bin Attachment document.
[back](./README.md)

138
vendor/spipu/html2pdf/doc/page.md vendored Normal file
View File

@ -0,0 +1,138 @@
# Page Management
[back](./README.md)
To facilitate the layout, three specific tags have been added:
* `<page>`
* `<page_header>`
* `<page_footer>`
They must be used as follow:
```html
<page>
<page_header>
...
</page_header>
<page_footer>
...
</page_footer>
...
</page>
```
You **must not** use `<body>` and `<html>` tags.
## Page tag
### Attributes
You can use the main following attributes:
Attribute| Default | Description
---------|---------|-------------
pageset | new | Specify if we want to use the previous page definition (old) or a new one (new)
pagegroup | old | Specify if we are in the same page group (old) or in a new one (new)
hideheader | | comma-separate page numbers on which we want to hide the header
hidefooter | | comma-separate page numbers on which we want to hide the footer
orientation | | Portrait (P) or Lanscape (L). By default, the orientation specified in the Html2Pdf constructor
format | | Format to use The list of the available values are [here](https://github.com/tecnickcom/TCPDF/blob/master/include/tcpdf_static.php#L2097). By default, the orientation specified in the Html2Pdf constructor
style | | css style
class | | css class
You can use the following attributes to manage page margin:
Attribute| Default | Description
---------|---------|-------------
backtop | 0 | value with unit (mm, px, pt, % )
backbottom | 0 | value with unit (mm, px, pt, % )
backleft | 0 | value with unit (mm, px, pt, % )
backright | 0 | value with unit (mm, px, pt, % )
You can use the following attributes to manage page background:
Attribute| Default | Description
---------|---------|-------------
backcolor | transparent | css color value
backimg | | url of the image to use
backimgx | center | x position of the image on the page background: left / center / right / value with unit (mm, px, pt, % )
backimgy | middle | y position of the image on the page background: top / middle / bottom / value with unit (mm, px, pt, % )
backimgw | 100% | width on the image on the page background: value with unit (mm, px, pt, % )
You can add a light footer by using the attribute footer. It takes coma-separated values:
Value| Description
-----|-------------
page | display the current page
date | display the generation date
time | display the generation time
form | display a disclamer about form compatibility
### explanation
It allows to define, for the entire html code included within the layout :
* margins left, right, top, bottom (backleft, backright, backtop, backbottom)
* background image, with its position and size (backimg, backimgx, backimgy, backimgw)
* the background color (backcolor)
* orientation (orientation) and format (format)
* simple automatic footer (footer)
* a header and a footer complex HTML (using tags page_header and page_footer).
It does not limit it-self to one final page of the PDF, but to a set of pages.
Any HTML code will be included automatically within the same layout.
It is possible to reuse the layout of the previous tag page using property pageset = “old.” This also automatically resume the header and the footer.
## Page Header tag
Its allows you to use complex HTML as the header of the current page.
Its definition must necessarily be located just after the opening of the `<page>` tag.
It can contain any valid HTML.
It is **REQUIRED** to specify the top margin, using the `backtop` attribute on the `<page>` tag.
You can use ̀`css` and `class` attribute on this specific tag.
## Page Footer tag
Its allows you to use complex HTML as the header of the current page.
Its definition must necessarily be located just after the opening of the `<page>` tag.
It can contain any valid HTML.
It is **REQUIRED** to specify the top margin, using the `backtop` attribute on the `<page>` tag.
You can use `css` and `class` attribute on this specific tag.
## Margin Explanation
Here's a little explanation of different margins:
```html
<page backtop="7mm" backbottom="7mm" backleft="10mm" backright="10mm">
<page_header>
Page Header
</page_header>
<page_footer>
Page Footer
</page_footer>
Page Content
</page>
```
```php
$pdf = new \Spipu\Html2Pdf\Html2Pdf('P','A4','en', false, 'UTF-8', array(mL, mT, mR, mB));
$pdf->writeHTML($htmlContent);
$pdf->Output();
```
![Margins](res/margins.jpg "Margins")
[back](./README.md)

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

53
vendor/spipu/html2pdf/doc/svg.md vendored Normal file
View File

@ -0,0 +1,53 @@
# SVG tags
[back](./README.md)
## Tag draw
A new html tag `<draw>` has been implemented.
It allows to insert a SVG image in your PDF.
The only allowed attributes are `css` and `class`.
Example:
```html
<page>
<draw style="margin: auto; width:150mm; height:100mm; background: #000000; border: solid 0.5mm #777777;">
<line style="stroke:#FF0000; stroke-width:1mm" x1="10mm" y1="10mm" x2="140mm" y2="10mm" >
<rect style="stroke:#770077; stroke-width:1mm; fill:#008888" x="15%" y="15%" w="70%" h="70%">
<ellipse style="stroke:#000077; stroke-width:1mm; fill:#888800" cx="50%" cy="50%" rx="30%" ry="30%">
<circle style="stroke:#0000AA; stroke-width:1mm; fill:#AAAA00" cx="50%" cy="50%" r="15%">
</draw><br>
<draw style="margin: auto; width:150mm; height:100mm; background: #000000; border: solid 0.5mm #777777;">
<path style="fill:#AAAA00; stroke:#0000AA; stroke-width:1mm" d="M20mm,10mm H130mm A10mm,10mm 0,0,0 140mm,20mm V80mm A10mm,10mm 0,0,0 130mm,90mm H20mm A10mm,10mm 0,0,0 10mm,80mm V20mm A10mm,10mm 0,0,0 20mm,10mm">
<path style="fill:#770000; stroke:#AA0033; stroke-width:0.5mm" d="M 20mm,40mm a16mm,8mm 0,0,0 16mm,8mm" />
<path style="fill:#770000; stroke:#00AA33; stroke-width:0.5mm" d="M 20mm,40mm l16mm,8mm" />
<path style="fill:#770000; stroke:#AA0033; stroke-width:0.5mm" d="M 40mm,40mm a16mm,8mm 0,0,1 16mm,8mm" />
<path style="fill:#770000; stroke:#00AA33; stroke-width:0.5mm" d="M 40mm,40mm l16mm,8mm" />
<path style="fill:#770000; stroke:#AA0033; stroke-width:0.5mm" d="M 80mm,40mm a16mm,8mm 0,1,0 16mm,8mm" />
<path style="fill:#770000; stroke:#00AA33; stroke-width:0.5mm" d="M 80mm,40mm l16mm,8mm" />
<path style="fill:#770000; stroke:#AA0033; stroke-width:0.5mm" d="M100mm,40mm a16mm,8mm 0,1,1 16mm,8mm" />
<path style="fill:#770000; stroke:#00AA33; stroke-width:0.5mm" d="M100mm,40mm l16mm,8mm" />
</draw><br>
<br>
</page>
```
## Allowed SVG tags
* LINE
* RECT
* CIRCLE
* ELLIPSE
* PATH
* POLYGON
* POLYLINE
* G
## SVG Documentation
See http://www.w3.org/TR/SVG11/expanded-toc.html
[back](./README.md)

View File

@ -0,0 +1,62 @@
# TCPDF Methods
[back](./README.md)
All the TCPDF methods can be used, by using the `pdf` property:
```php
$html2pdf->pdf->...
```
## Display Mode
You can change how your PDF document will be displayed, with the `SetDisplayMode` method:
```php
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($htmlContent);
$html2pdf->output();
```
The parameters are:
Parameter| Default | Description
---------|---------|-------------
$zoom | | The zoom to use. It can be one of the following string values or a number indicating the zooming factor to use. <ul><li>fullpage: displays the entire page on screen </li><li>fullwidth: uses maximum width of window</li><li>real: uses real size (equivalent to 100% zoom)</li><li>default: uses viewer default mode</li></ul>
$layout | SinglePage | The page layout. Possible values are:<ul><li>SinglePage Display one page at a time</li><li>OneColumn Display the pages in one column</li><li>TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left</li><li>TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right</li><li>TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left</li><li>TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right</li></ul>
$mode | UseNone | A name object specifying how the document should be displayed when opened:<ul><li>UseNone Neither document outline nor thumbnail images visible</li><li>UseOutlines Document outline visible</li><li>UseThumbs Thumbnail images visible</li><li>FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible</li><li>UseOC (PDF 1.5) Optional content group panel visible</li><li>UseAttachments (PDF 1.6) Attachments panel visible</li></ul>
## Document Information
You can change the document information, with the following methods:
```php
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
$html2pdf->pdf->SetAuthor('LAST-NAME Frist-Name');
$html2pdf->pdf->SetTitle('My Pdf Document');
$html2pdf->pdf->SetSubject('it will be about something important');
$html2pdf->pdf->SetKeywords('example, keywords, others');
$html2pdf->writeHTML($htmlContent);
$html2pdf->output();
```
## Document Protection
You can protect your PDF document, with the `setProtection` method:
```php
$html2pdf->pdf->SetProtection($permissions, $userPass, $ownerPass, $mode, $pubkeys);
```
The parameters are:
Parameter| Default | Description
---------|---------|-------------
$permissions | | the set of permissions (specify the ones you want to block):<ul><li>print : Print the document;</li><li>modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';</li><li>copy : Copy or otherwise extract text and graphics from the document;</li><li>annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);</li><li>fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;</li><li>extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);</li><li>assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;</li><li>print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.</li><li>owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.</li></ul>
$userPass | | user password. Empty by default.
$ownerPass | null | owner password. If not specified, a random value is used.
$mode | 0 | encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit.
$pubkeys | null| array of recipients containing public-key certificates ('c') and permissions ('p'). For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print')))
[back](./README.md)

View File

@ -0,0 +1,34 @@
<?php
/**
* Html2Pdf Library - example
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
$html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', array(0, 0, 0, 0));
$html2pdf->pdf->SetDisplayMode('fullpage');
ob_start();
include dirname(__FILE__).'/res/about.php';
$content = ob_get_clean();
$html2pdf->writeHTML($content);
$html2pdf->createIndex('Sommaire', 30, 12, false, true, 2, null, '10mm');
$html2pdf->output('about.pdf');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}

View File

@ -0,0 +1,31 @@
<?php
/**
* Html2Pdf Library - example
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
ob_start();
include dirname(__FILE__).'/res/balloon.php';
$content = ob_get_clean();
$html2pdf = new Html2Pdf('P', 'A4', 'fr');
$html2pdf->writeHTML($content);
$html2pdf->output('baloon.pdf');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}

View File

@ -0,0 +1,32 @@
<?php
/**
* Html2Pdf Library - example
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
ob_start();
include dirname(__FILE__).'/res/bookmark.php';
$content = ob_get_clean();
$html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', 0);
$html2pdf->writeHTML($content);
$html2pdf->createIndex('Sommaire', 25, 12, false, true, 1);
$html2pdf->output('bookmark.pdf');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}

View File

@ -0,0 +1,32 @@
<?php
/**
* Html2Pdf Library - example
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
ob_start();
include dirname(__FILE__).'/res/example00.php';
$content = ob_get_clean();
$html2pdf = new Html2Pdf('P', 'A4', 'fr');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($content);
$html2pdf->output('example00.pdf');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}

View File

@ -0,0 +1,31 @@
<?php
/**
* Html2Pdf Library - example
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
ob_start();
include dirname(__FILE__).'/res/example01.php';
$content = ob_get_clean();
$html2pdf = new Html2Pdf('P', 'A4', 'fr');
$html2pdf->writeHTML($content);
$html2pdf->output('example01.pdf');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}

View File

@ -0,0 +1,32 @@
<?php
/**
* Html2Pdf Library - example
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
ob_start();
include dirname(__FILE__).'/res/example02.php';
$content = ob_get_clean();
$html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', array(15, 5, 15, 5));
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content);
$html2pdf->output('example02.pdf');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}

View File

@ -0,0 +1,32 @@
<?php
/**
* Html2Pdf Library - example
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
ob_start();
include dirname(__FILE__).'/res/example03.php';
$content = ob_get_clean();
$html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', 3);
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content);
$html2pdf->output('example03.pdf');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}

View File

@ -0,0 +1,32 @@
<?php
/**
* Html2Pdf Library - example
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
ob_start();
include dirname(__FILE__).'/res/example04.php';
$content = ob_get_clean();
$html2pdf = new Html2Pdf('P', 'A4', 'fr');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content);
$html2pdf->output('example04.pdf');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}

View File

@ -0,0 +1,32 @@
<?php
/**
* Html2Pdf Library - example
*
* HTML => PDF converter
* distributed under the OSL-3.0 License
*
* @package Html2pdf
* @author Laurent MINGUET <webmaster@html2pdf.fr>
* @copyright 2017 Laurent MINGUET
*/
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
ob_start();
include dirname(__FILE__).'/res/example05.php';
$content = ob_get_clean();
$html2pdf = new Html2Pdf('P', 'A4', 'fr');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content);
$html2pdf->output('example05.pdf');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}

Some files were not shown because too many files have changed in this diff Show More