use Cubist\Util\Graphics\PDF;
use Cubist\Util\Text;
use Fluidbook\Tools\Compiler\CompilerInterface;
+use Fluidbook\Tools\SVG\SVGTools;
class ZoomLink extends NormalLink {
protected $maxzoom_default = 2;
$cache = $compiler->getCacheDir("zoomarea/" . $cachedir);
- $leftArea = ['x' => $x, 'y' => $y, 'width' => $w, 'height' => $h];
+
+ $leftHeight = min($h, $compiler->getHeightForLinks() - $y);
+ $leftWidth = min($w, $compiler->getWidthForLinks() - $x);
+
+ $leftArea = ['x' => $x, 'y' => $y, 'width' => $leftWidth, 'height' => $leftHeight];
+
$leftfile = PDF::extractArea($pdfpath,
$extractPage,
$leftArea,
$both = $cache . hash('sha256', $leftfile . $rightfile) . '.' . $ext;
if (!file_exists($both)) {
- Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');
+ if ($ext === 'svg') {
+ SVGTools::append($leftfile, $rightfile, $both, 'h');
+ } else {
+ Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');
+ }
}
if (!file_exists($both)) {
throw new \Exception('Error glueing ' . $leftfile . ' and ' . $rightfile);
$cli->dd();
}
}
+
+ public static function append($first, $second, $dest, $direction = 'h') {
+ $cli = new CommandLine('python3');
+ $cli->setArg(null, '/usr/local/svg_stack/svg_stack.py');
+ $cli->setArg('direction', $direction);
+ $cli->setArg(null, $first);
+ $cli->setArg(null, $second);
+ $cli->execute();
+ file_put_contents($dest, $cli->getOutput());
+ }
}