You are here

public static function FillPdf::checkPdftkPath in FillPDF 8.4

Same name and namespace in other branches
  1. 5.0.x src/Component/Utility/FillPdf.php \Drupal\fillpdf\Component\Utility\FillPdf::checkPdftkPath()

Tests the connection to a local pdftk installation.

Parameters

string $pdftk_path: (optional) A pdftk path differing from 'pdftk'. Defaults to ''.

Return value

bool TRUE if pdftk could be reached, otherwise FALSE.

4 calls to FillPdf::checkPdftkPath()
FillPdfSettingsForm::validateForm in src/Form/FillPdfSettingsForm.php
Form validation handler.
PdfParseTest::testParsePdftk in tests/src/Functional/PdfParseTest.php
Tests PDF population using a local install of pdftk.
PdfPopulationTest::testMergePdftk in tests/src/Functional/PdfPopulationTest.php
Tests PDF population using a local install of pdftk.
PdftkPdfBackend::parseFile in src/Plugin/PdfBackend/PdftkPdfBackend.php
Parse a PDF and return a list of its fields.

File

src/Component/Utility/FillPdf.php, line 28

Class

FillPdf
Class FillPdf.

Namespace

Drupal\fillpdf\Component\Utility

Code

public static function checkPdftkPath($pdftk_path = '') {

  // An empty value means we should leave it to the PATH.
  if (empty($pdftk_path)) {
    $pdftk_path = 'pdftk';
  }
  $process = new Process($pdftk_path);
  $process
    ->run();
  if (in_array($process
    ->getExitCode(), [
    126,
    127,
  ], TRUE)) {
    return FALSE;
  }
  return TRUE;
}