hot4devs / document-signer
Add Signature to PDF Documents (https://gitlab.com/hot4devs/document-signer)
Installs: 71
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Forks: 0
pkg:composer/hot4devs/document-signer
Requires
- php: >=8.1
 - ext-openssl: *
 - insidesuki/utilities-file: ^6.4
 - setasign/fpdi-tcpdf: ^2.3
 - tecnickcom/tcpdf: ^6.8
 
Requires (Dev)
- phpunit/phpunit: 9.*
 - roave/security-advisories: dev-latest
 - symfony/var-dumper: ^6.4
 
README
DOCUMENT-SIGNER
Add signature to your documents
FEATURES
- Add crt, key signature to PDF documents
 - Sign PDF documents using FPDI adapter
 - Returns SignedDocument
 - Store document signed on disk
 - SignedDocument can be returned as base64
 - SignedDocument can be returned as string
 
USAGE
For PDF Documents
- Using factory (password needed; assume you have the crt and key files on same folder)
 
In this example use the following folder '/var/cert/valid':
// $name is the name of the crt and key file
$signedDocument = FpdiSigner::sign(
            setup: SignerSetting::setup(
                certPath: __DIR__ . '/var/cert',
                name: 'h4d',
                keyPassword: 'somepassowrd',
                documentPath: __DIR__ . '/var/document/example.pdf',
            )
        );
- Get SignedDocument AS base64
 
// as base64 $base64 = $signedDocument->toBase64();
- Get SignedDocument AS File
If first parameter ($path) is null, the file will be stored in the same folder of the original document
// to file // usign DestinationFolder
use Hot4devs\DocumentSigner\Document\DestinationFolder
$destinationFolder = DestinationFolder::create('/var/destinationPath'); $signedDocument->toFile(destination:$destinationFolder) ->fullPath(); // returns the full path of the file
-  Get SignedDocument AS string
// as string $string = $signedDocument->content();
 
**FULLCODE EXAMPLE**
use Hot4devs\DocumentSigner\Document\Contract\SignedDocument; use Hot4devs\DocumentSigner\Signer\Fpdi\FpdiSigner; use Hot4devs\DocumentSigner\Signer\SignerSetting;
$signedDocument = FpdiSigner::sign(
        setup: SignerSetting::setup(
            certPath: __DIR__ . '/var/cert',
            name: 'h4d',
            keyPassword: 'somepassowrd',
            documentPath: __DIR__ . '/var/document/example.pdf',
        )
    );
// save on same folder $signedDocument->toFile();
// returns /var/document/example_signed.pdf $fullPath = $signedDocument->fullPath();
**LIMITATIONS**
- Only works with PDF documents
- Only works with crt and key files
- Not add any image or mark