<?php
use Fluidbook\Farmer\ProcessFile;
-use Fluidbook\Farmer\ProcessFileNoMapping;
+use Fluidbook\Farmer\ProcessToolboxDocumentFile;
+use Fluidbook\Farmer\ProcessToolboxPDFFile;
require_once __DIR__ . "/vendor/autoload.php";
-if (isset($_POST['toolbox'])) {
- $class = ProcessFileNoMapping::class;
+if (!isset($_POST['pdf'])) {
+ if (isset($_POST['toolbox'])) {
+ $class = ProcessToolboxDocumentFile::class;
+ } else {
+ $class = ProcessFile::class;
+ }
+ $p = new $class($_POST['out'], $_POST['page'], $_POST['resolutionRatio'], $_POST['mobileRatio'], $_POST['format'], $_POST['resolution'], $_POST['withGraphics'], $_POST['withText'], $_POST['version'], $_POST['force']);
} else {
- $class = ProcessFile::class;
+ $p = new ProcessToolboxPDFFile($_POST['pdf'], $_POST['out'], $_POST['page'], $_POST['resolutionRatio'], $_POST['mobileRatio'], $_POST['format'], $_POST['resolution'], $_POST['withGraphics'], $_POST['withText'], $_POST['version'], $_POST['force']);
}
-$p = new $class($_POST['out'], $_POST['page'], $_POST['resolutionRatio'], $_POST['mobileRatio'], $_POST['format'], $_POST['resolution'], $_POST['withGraphics'], $_POST['withText'], $_POST['version'], $_POST['force']);
die($p->process());
\ No newline at end of file
}
}
+ public function getPdf(): string {
+ return Files::firstThatExists($this->getOut() . '/crop.pdf', $this->getOut() . '/fixed.pdf', $this->getOut() . '/original.pdf');
+ }
+
public function getSplittedPDFPage() {
$res = $this->getOut() . 'pdf/p' . $this->getPage() . '.pdf';
if (!file_exists($res)) {
- PDFTools::split(Files::firstThatExists($this->getOut() . '/crop.pdf', $this->getOut() . '/fixed.pdf', $this->getOut() . '/original.pdf'), $this->getOut() . '/pdf');
+ PDFTools::split($this->getPdf(), $this->getOut() . '/pdf');
}
return $res;
}
+++ /dev/null
-<?php
-
-namespace Fluidbook\Farmer;
-
-
-class ProcessFileNoMapping extends ProcessFile{
- public function getOut() {
- $this->getDistantOut();
- }
-
- public function process() {
- $this->getPath($this->isForce());
- }
-}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Fluidbook\Farmer;
+
+
+class ProcessToolboxDocumentFile extends ProcessFile{
+ public function getOut() {
+ $this->getDistantOut();
+ }
+
+ public function process() {
+ $this->getPath($this->isForce());
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Fluidbook\Farmer;
+
+
+class ProcessToolboxPDFFile extends ProcessToolboxDocumentFile {
+
+ /**
+ * @var string
+ */
+ protected $_pdf;
+
+ public function __construct($pdf, $out, $page, $resolutionRatio, $mobileRatio, $format = 'jpg', $resolution = 150, $withGraphics = true, $withTexts = true, $version = 'html', $force = false) {
+ $this->setPdf($pdf);
+ parent::__construct($out, $page, $resolutionRatio, $mobileRatio, $format, $resolution, $withGraphics, $withTexts, $version, $force);
+ }
+
+ /**
+ * @return string
+ */
+ public function getPdf(): string {
+ return $this->_pdf;
+ }
+
+ /**
+ * @param string $pdf
+ */
+ public function setPdf(string $pdf): void {
+ $this->_pdf = $pdf;
+ }
+}
\ No newline at end of file