if ($time === 'latest' && !file_exists($file)) {
$versions = self::getLinksVersions($book_id);
foreach ($versions as $version => $m) {
- try {
- copy(Files::firstThatExists($dir . '/' . $version . '.links3.gz', $dir . '/' . $version . '.links.gz'), $dir . '/latest.links3.gz');
- copy(Files::firstThatExists($dir . '/' . $version . '.meta3.gz', $dir . '/' . $version . '.meta.gz'), $dir . '/latest.meta3.gz');
- break;
- } catch (\Exception $e) {
-
+ $lf = Files::firstThatExists($dir . '/' . $version . '.links3.gz', $dir . '/' . $version . '.links.gz');
+ $mf = Files::firstThatExists($dir . '/' . $version . '.meta3.gz', $dir . '/' . $version . '.meta.gz');
+ if (!file_exists($lf) || !file_exists($mf)) {
+ continue;
}
+ copy($lf, $dir . '/latest.links3.gz');
+ copy($mf, $dir . '/latest.meta3.gz');
+ break;
}
}
if (!file_exists($file)) {
FluidbookDocumentUpload::updateProgression($this->uploadID, $this->document->id, __('Début du traitement du document'), 1.25);
$this->document->processUpload($this->uploadID, $sync);
Links::addLinksFromPDF($this->fluidbook_id);
- } catch (\Exception $e) {
+ } catch (\Throwable $e) {
error_log($e);
+ FluidbookDocumentUpload::updateProgression($this->uploadID, $this->document->id, __('Une erreur s\'est produite :error', ['error' => $e->getMessage()]), -1);
}
}
use Cubist\Util\Gzip;
use Cubist\Util\Math;
use Illuminate\Support\Facades\Cache;
+
// __('!!Paramètres des fluidbooks')
class FluidbookDocument extends ToolboxModel
{
}
-
public function checkInfos($force = false)
{
if ($force || null === $this->pdf_data) {
$infos = $this->_getInfos();
+
$this->pages = $infos->pages;
$this->pdf_data = $infos->pdf_data;
$this->bookmarks = $infos->bookmarks;
public function cutDocument($mode)
{
+
+
$fwstk = new FWSTK();
$fwstk->setArg('--input ' . $this->getPDFSource('fixed'));
$fwstk->setArg('--cut ' . $mode);
public function trimDocument()
{
+
$fwstk = new FWSTK();
$fwstk->setArg('--input ' . $this->getPDFSource('fixed'));
$fwstk->setArg('--trim');
public function lnCrop()
{
- $root = $this->path();
- `cd $root;ln -s fixed.pdf crop.pdf`;
+ link($this->getPDFSource('crop'), $this->getPDFSource('fixed'));
}
protected function isCropped()
if ($this->autocrop == 'trim') {
$this->trimDocument();
}
+
return false;
}
}
}
- if ($first == $last && $last == $second) {
- $ratio = $first[0] / $first[1];
- $this->autocut = false;
- if ($ratio <= 1) {
- $this->manualcut = false;
- } elseif ($ratio >= 6) {
- $this->manualcut = 'L8';
- } elseif ($ratio >= 3) {
- $this->manualcut = 'L4';
- } elseif ($ratio >= 2) {
- $this->manualcut = 'L3';
- } else {
- $this->manualcut = '14-23';
- }
- return;
- }
$this->manualcut = false;
if (self::compareSizes($last, $first) && Math::compare($first[0] * 2, $second[0], 0.9)) {
$this->autocut = '1-23-4';