Kaynağa Gözat

docx 添加模版

visuddhinanda 1 yıl önce
ebeveyn
işleme
215ca401ac
1 değiştirilmiş dosya ile 7 ekleme ve 3 silme
  1. 7 3
      app/Tools/ExportDownload.php

+ 7 - 3
app/Tools/ExportDownload.php

@@ -147,7 +147,7 @@ class ExportDownload
         }
         }
 
 
 
 
-        $dir = "tmp/export/{$type}/".$this->format."/".$this->zipFilename."/";
+        $dir = "tmp/export/{$type}/".$this->format."/";
         $mdFilename = $dir.$outputFilename.'.md';
         $mdFilename = $dir.$outputFilename.'.md';
         Storage::disk('local')->put($mdFilename, $fileDate);
         Storage::disk('local')->put($mdFilename, $fileDate);
         Log::debug('markdown saved',['filename'=>$mdFilename]);
         Log::debug('markdown saved',['filename'=>$mdFilename]);
@@ -161,7 +161,12 @@ class ExportDownload
             $absoluteOutputPath = Storage::disk('local')->path($filename);
             $absoluteOutputPath = Storage::disk('local')->path($filename);
             //$command = "pandoc pandoc1.md --reference-doc tpl.docx -o pandoc1.docx";
             //$command = "pandoc pandoc1.md --reference-doc tpl.docx -o pandoc1.docx";
             $command = ['pandoc', $absoluteMdPath, '-o', $absoluteOutputPath];
             $command = ['pandoc', $absoluteMdPath, '-o', $absoluteOutputPath];
-            Log::debug('pandoc start',['command'=>$command]);
+            if($this->format === 'docx'){
+                 $tplFile = resource_path("template/docx/paper.docx");
+                 array_push($command,'--reference-doc');
+                 array_push($command,$tplFile);
+            }
+            Log::debug('pandoc start',['command'=>$command,'format'=>$this->format]);
             $process = new Process($command);
             $process = new Process($command);
             $process->run();
             $process->run();
 
 
@@ -173,7 +178,6 @@ class ExportDownload
             Log::debug('pandoc end',['command'=>$command]);
             Log::debug('pandoc end',['command'=>$command]);
         }
         }
 
 
-
         $zipDir = storage_path('app/export/zip');
         $zipDir = storage_path('app/export/zip');
         if(!is_dir($zipDir)){
         if(!is_dir($zipDir)){
             $res = mkdir($zipDir,0755,true);
             $res = mkdir($zipDir,0755,true);