Skip to content

Commit 8f29d1f

Browse files
authored
Merge pull request #11 from JSignPdf/feature/java-standalone
java standalone
2 parents c50be3b + 1a8fc0f commit 8f29d1f

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ With Java Installed:
2929
$param->setIsUseJavaInstalled(true);
3030
```
3131

32+
With standalone Java:
33+
```php
34+
$param->setJavaPath('/path/to/bin/java');
35+
```
36+
3237
With JSignPDF bin:
3338
```php
3439
$param->setjSignPdfJarPath('/path/to/jsignpdf');

src/Sign/JSignParam.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class JSignParam
1313
private $pathPdfSigned;
1414
private $JSignParameters = "-a -kst PKCS12";
1515
private $isUseJavaInstalled = false;
16+
private $javaPath = '';
1617
private $tempPath;
1718
private $tempName;
1819
private $isOutputTypeBase64 = false;
@@ -111,6 +112,15 @@ public function setIsUseJavaInstalled(bool $isUseJavaInstalled)
111112
return $this;
112113
}
113114

115+
public function setJavaPath($javaPath): self {
116+
$this->javaPath = $javaPath;
117+
return $this;
118+
}
119+
120+
public function getJavaPath(): string {
121+
return $this->javaPath;
122+
}
123+
114124
public function setjSignPdfJarPath($jSignPdfJarPath)
115125
{
116126
$this->jSignPdfJarPath = $jSignPdfJarPath;

src/Sign/JSignService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ private function javaCommand(JSignParam $params)
101101
if ($params->isUseJavaInstalled()) {
102102
return 'java';
103103
}
104+
if ($params->getJavaPath()) {
105+
return $params->getJavaPath();
106+
}
104107
if (!class_exists('JSignPDF\JSignPDFBin\JavaCommandService')) {
105108
throw new Exception("JSignPDF not found, install manually or run composer require jsignpdf/jsignpdf-bin", 1);
106109
}

0 commit comments

Comments
 (0)