Skip to content

Commit

Permalink
Merge pull request #9 from 42coders/master
Browse files Browse the repository at this point in the history
Enabled PdfSeparate functionality. Added file suffix option.
  • Loading branch information
ncjoes committed Feb 12, 2019
2 parents a9ea2de + 95f9a80 commit 635cd7b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/PopplerPhp/PdfSeparate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,28 @@

namespace NcJoes\PopplerPhp;

use NcJoes\PopplerPhp\Constants as C;
use NcJoes\PopplerPhp\PopplerOptions\CairoOptions;
use NcJoes\PopplerPhp\PopplerOptions\HelpFlags;
use NcJoes\PopplerPhp\PopplerOptions\PageRangeOptions;


class PdfSeparate extends PopplerUtil
{
/**
* PdfSeparate constructor.
*
* @param string $pdfFile
* @param array $options
*/
public function __construct($pdfFile = '', array $options = [])
{
$this->bin_file = C::PDF_SEPARATE;

return parent::__construct($pdfFile, $options);
}


public function utilOptions()
{
// TODO: Implement utilOptions() method.
Expand All @@ -35,4 +55,16 @@ public function outputExtension()
{
return '.pdf';
}

/**
* @return string
*/
public function generate()
{
$this->output_file_extension = $this->outputExtension();

return $this->shellExec();
}


}
16 changes: 15 additions & 1 deletion src/PopplerPhp/PopplerUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ abstract class PopplerUtil
{
protected $bin_file;
protected $output_file_extension;
protected $output_file_suffix = '';
protected $require_output_dir = true;
private $binary_dir;
private $flags = [];
Expand Down Expand Up @@ -311,7 +312,7 @@ private function makeShellCommand()

$output_path = H::parseDirName($directory.C::DS.$this->getOutputFilenamePrefix());

$command[] = $q.$output_path.$this->output_file_extension.$q;
$command[] = $q . $output_path . $this->output_file_suffix . $this->output_file_extension . $q;
}

return implode(' ', $command);
Expand Down Expand Up @@ -378,6 +379,19 @@ public function setOutputFilenamePrefix($name)
throw new PopplerPhpException("Filename must be an alphanumeric string");
}

/**
* @param $name
*
* @return $this
* @throws PopplerPhpException
*/
public function setOutputFilenameSuffix($suffix = '')
{
$this->output_file_suffix = $suffix;
return $this;
}


/**
* @return mixed
*/
Expand Down

0 comments on commit 635cd7b

Please sign in to comment.