Download the PHP package jsignpdf/jsignpdf-php without Composer
On this page you can find all versions of the php package jsignpdf/jsignpdf-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jsignpdf/jsignpdf-php
More information about jsignpdf/jsignpdf-php
Files in jsignpdf/jsignpdf-php
Informations about the package jsignpdf-php
jsignpdf-php
This package is only wrapper of JSignPdf to use in PHP
Installation:
Examples
With Java Installed:
With standalone Java:
setJavaPath() takes only the path to the java executable. Applications
that need JVM options or environment variables — for example a self-managed
JSignPdf install that needs -Duser.home and JSIGNPDF_HOME — set them
separately:
With JSignPDF bin:
With specific Java or JSignPdf version:
Without JSignPDF bin:
File signed as base64:
Change temp directory:
Change parameters of JSignPDF:
An option that takes a value is written as option => value, and a flag as an
item without a key:
This is what tells the package which item is an option and which one is its value, so a value that looks like an option is never mistaken for one:
setJSignParameters() replaces the current parameters; the package escapes
every value for you. Use addJSignParameters() to add more options without
reading the current ones first:
Existing signature fields
JSignPdf 3.2 can inspect existing signature fields in a PDF. Only the PDF is required for inspection; a certificate and signing password are not needed.
Each signature field exposes its name, page, rectangle coordinates and whether
it is signed or hidden. isBlank() is the opposite of isSigned(), and
hasVisibleRectangle() reports whether the field has a non-zero rectangle.
To sign an existing blank signature field, select it by name before signing:
The value passed to setSignatureField() is passed directly to JSignPdf.
Names containing spaces or Unicode characters are supported. JSignPdf also
supports its own field selectors such as auto and #1; when a field has one
of those literal names, JSignPdf gives the field name precedence.
Passwords
Besides the certificate password of setPassword(), JSignPdf takes a password
for the private key, for encrypted documents and for the timestamping server.
None of them is passed on the command line, where any user of the machine could
read it from ps or /proc/<pid>/cmdline: the package sends every one of them
to JSignPdf through stdin.
Passing one of those options to setJSignParameters() or addJSignParameters() works too, and the value is taken out of the command line just the same:
A password option always takes its value with it: ['-tsp'] alone, or the
certificate password as ['-ksp' => '...'] — which belongs to setPassword() —
is refused with an InvalidArgumentException instead of reaching the command
line.
JSignPdf reads one password per line from stdin, so a password cannot contain a
line break: every setter above, and the parameters, reject one with an
InvalidArgumentException. Any other value is supported, spaces, shell
metacharacters and non-ASCII characters included.
JSignPdf 3.x
This package targets JSignPdf 3.x, which needs a Java 21+ runtime. JSignPdf 2.x
is no longer supported: the certificate password is now sent to JSignPdf
through stdin, and 2.x has no option to read it from there. Pointing
setJSignPdfDownloadUrl() or setJSignPdfPath() at a 2.x release stops
working.
Two changes of JSignPdf 3.1 are worth knowing about:
- the default hash algorithm is now SHA-256, which requires at least a PDF-1.6;
- the CLI appends the signature by default, and the append mode cannot upgrade the PDF version.
Together they make signing a PDF older than 1.6 fail with the default
parameters. To sign such a file, either turn off the append mode with
--overwrite or pick an algorithm the PDF version supports:
The -a flag is kept by JSignPdf 3.1 as a no-op.
Docker Environment
The repository ships a minimal Docker setup (Dockerfile and compose.yml) with the extensions
the test suite needs.
Checks, the same ones the CI runs:
Usage example
To sign a PDF end to end. It downloads the JRE and JSignPdf into tmp/ on the first run:
Credits
All versions of jsignpdf-php with dependencies
ext-openssl Version *
ext-json Version *