Skip to content

Commit

Permalink
Merge pull request #2345 from LibreSign/feature/pdftk-to-arm64
Browse files Browse the repository at this point in the history
Add support to arm64
  • Loading branch information
vitormattos committed Feb 22, 2024
2 parents 95e8861 + 69d481b commit 3d5684f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/Service/ConfigureCheckService.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public function checkPdftk(): array {
$pdftkPath = $this->appConfig->getAppValue('pdftk_path');
if ($pdftkPath) {
if (file_exists($pdftkPath)) {
\exec($pdftkPath . " --version 2>&1", $version);
$javaPath = $this->appConfig->getAppValue('java_path');
\exec($javaPath . ' -jar ' . $pdftkPath . " --version 2>&1", $version);
if (isset($version[0])) {
preg_match('/pdftk port to java (?<version>.*) a Handy Tool/', $version[0], $matches);
if (isset($matches['version'])) {
Expand Down
10 changes: 4 additions & 6 deletions lib/Service/InstallService.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,19 +450,17 @@ public function installPdftk(?bool $async = false): void {
}

try {
$file = $this->getFolder()->getFile('pdftk');
$file = $this->getFolder()->getFile('pdftk.jar');
} catch (\Throwable $th) {
$file = $this->getFolder()->newFile('pdftk');
$file = $this->getFolder()->newFile('pdftk.jar');
}
$fullPath = $this->getDataDir() . DIRECTORY_SEPARATOR . $this->getInternalPathOfFile($file);
$url = 'https://gitlab.com/api/v4/projects/5024297/packages/generic/pdftk-java/v' . self::PDFTK_VERSION . '/pdftk';
$url = 'https://gitlab.com/api/v4/projects/5024297/packages/generic/pdftk-java/v' . self::PDFTK_VERSION . '/pdftk-all.jar';
/** WHEN UPDATE version: generate this hash handmade and update here */
$hash = 'dc5abe9885b26c616821ba1f24f03195';
$hash = '59a28bed53b428595d165d52988bf4cf';

$this->download($url, 'pdftk', $fullPath, $hash);

chmod($fullPath, 0700);

$this->appConfig->setAppValue('pdftk_path', $fullPath);
$this->removeDownloadProgress();
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Service/SignFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,11 @@ private function getPdfToSign(FileEntity $fileData, File $originalFile): File {
$dest = $this->tempManager->getTemporaryFile('signed.pdf');
file_put_contents($dest, $originalFile->getContent());

$javaPath = $this->appConfig->getAppValue('java_path');
$pdftkPath = $this->appConfig->getAppValue('pdftk_path');
$pdf = new Pdf();
$command = new Command();
$command->setCommand($pdftkPath);
$command->setCommand($javaPath . ' -jar ' . $pdftkPath);
$pdf->setCommand($command);
$pdf->addFile($dest);
$buffer = $pdf->stamp($background)
Expand Down

0 comments on commit 3d5684f

Please sign in to comment.