sort out rotated pdfs
authorAlan <alan@roojs.com>
Tue, 22 Aug 2023 03:11:30 +0000 (11:11 +0800)
committerAlan <alan@roojs.com>
Tue, 22 Aug 2023 03:11:30 +0000 (11:11 +0800)
File/Convert/Solution/pdftocairo.php
HTML/FlexyFramework.php

index 274143e..86abd14 100644 (file)
@@ -64,20 +64,37 @@ class File_Convert_Solution_pdftocairo extends File_Convert_Solution
         $this->debug("PDFINFO: $STRINGS");
         // needs strings if starngs chars are in there..
         $cmd = $PDFINFO . ' '. escapeshellarg($fn) . " | $STRINGS | $GREP 'Page size'";
+        
+        
          
 //        var_dump($cmd);exit;
         $info = trim( $this->exec($cmd));
         $match = array();
         // very presumtiuos...
-       
-       
+        $cmd = $PDFINFO . ' '. escapeshellarg($fn) . " | $STRINGS | $GREP 'Page rot'";
+        $rinfo = trim( $this->exec($cmd));
+        
         if (!preg_match("/([0-9.]+)[^0-9]+([0-9.]+)/",$info, $match)) {
             $this->cmd .= " could not find 0-0 in the return string";
             return false;
         }
+        $rot = 0;
+        $rmatch = 0;
+        if (preg_match("/([0-9.]+)/",$rinfo, $rmatch)) {
+            $rot  = $rmatch[1];
+            
+        } 
+        if (in_array((int)$rot, array(90,270))) {
+             $match[0] = $match[1];
+            $match[1] = $match[2];
+            $match[2] = $match[0];
+        }
         
         $yscale =  floor( ($match[2] / $match[1]) * $xscale) * 3;
         $xscale = floor($xscale) * 3;
+        
+        
+        
         $pg = ($pg === false) ? 1 : $pg;
         
         
index 78c8274..a7ab325 100755 (executable)
@@ -214,6 +214,9 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
         $rootDir = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
         
         $cls = $proj.'_Config';
+        
+        
+        
          if (file_exists($rootDir . '/'.str_replace('_','/', $cls). '.php')) {
             require_once str_replace('_','/', $cls). '.php';
             $c = new $cls();