如何在没有作曲家的情况下使用 PHP 个库(具有 FPDI 保护的 FPDI)
How to use PHP libraries whithout composer (FPDI with FPDI protection)
我使用 FPDI 而没有作曲家,所以我的文件如下所示:
...
use \setasign\Fpdi;
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdi2/src/autoload.php');
// initiate FPDI
$pdf = new Fpdi\Fpdi();
...
我想添加 FPDI Protection 来保护我刚刚生成的 PDF
但是在他们的自述文件中,它只显示了使用 composer 时要遵循的过程
use setasign\FpdiProtection\FpdiProtection;
// setup the autoload function
require_once('vendor/autoload.php');
$pdf = new FpdiProtection();
$ownerPassword = $pdf->setProtection(
FpdiProtection::PERM_PRINT | FpdiProtection::PERM_COPY,
'the user password',
'the owner password'
);
如何使用 FPDI 保护使 FPDI 未初始化?不懂怎么办..
已记录 here:
If you do not use composer, just require the autoload.php in the /src folder:
require_once('src/autoload.php');
If you have a PSR-4 autoloader implemented, just register the src path as follows:
$loader = new \Example\Psr4AutoloaderClass;
$loader->register();
$loader->addNamespace('setasign\FpdiProtection', 'path/to/src/');
所以在你的情况下,只需要来自 FPDI 和 FPDI 保护的 autoload.php 个文件:
use setasign\FpdiProtection\FpdiProtection;
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdi2/src/autoload.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdi_protection/src/autoload.php');
$pdf = new FpdiProtection();
...
我使用 FPDI 而没有作曲家,所以我的文件如下所示:
...
use \setasign\Fpdi;
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdi2/src/autoload.php');
// initiate FPDI
$pdf = new Fpdi\Fpdi();
...
我想添加 FPDI Protection 来保护我刚刚生成的 PDF
但是在他们的自述文件中,它只显示了使用 composer 时要遵循的过程
use setasign\FpdiProtection\FpdiProtection;
// setup the autoload function
require_once('vendor/autoload.php');
$pdf = new FpdiProtection();
$ownerPassword = $pdf->setProtection(
FpdiProtection::PERM_PRINT | FpdiProtection::PERM_COPY,
'the user password',
'the owner password'
);
如何使用 FPDI 保护使 FPDI 未初始化?不懂怎么办..
已记录 here:
If you do not use composer, just require the autoload.php in the /src folder:
require_once('src/autoload.php');
If you have a PSR-4 autoloader implemented, just register the src path as follows:
$loader = new \Example\Psr4AutoloaderClass; $loader->register(); $loader->addNamespace('setasign\FpdiProtection', 'path/to/src/');
所以在你的情况下,只需要来自 FPDI 和 FPDI 保护的 autoload.php 个文件:
use setasign\FpdiProtection\FpdiProtection;
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdi2/src/autoload.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/fpdi_protection/src/autoload.php');
$pdf = new FpdiProtection();
...