2016-12-22 4 views
0

私はCloudConvert NodeJSパッケージを使用しています。私は、リモートサーバーからPDFを取得し、テンプレートから動的にdocxを生成するプロセスを持っています。私はCloudConvertを使ってこれらの2つのpdfを結合しようとしていますが、いつでも返される文書はdocxが2回繰り返されるだけです。CloudConvert DocxとPDFを組み合わせる

私は、CloudConvertがdocxだけでなく、PDFとDocxの両方を要求していることを確認しました。私はDocxを別のPDFに置き換えると、2つのPDFをうまく組み合わせることができますが、ドキュメントにはサポートされていると書かれていても、両者の組み合わせはうまくいかないようです。

これは私のコードですが、基本的に私のローカルドキュメントを含むように修正されたコード例です。いくつかのパスを簡略化してドメイン情報を削除しましたが、それ以外は実装しています。

cloudconvert.createProcess({ 
    "mode": "combine", 
    "outputformat": "pdf" 
}, function(err, process) { 
    if (err) { 
     console.error('CloudConvert Process failed: ' + err); 
    }        

    process.start({ 
     "mode": "combine", 
     "input": "download", 
     "files": [ 
      '*domain*/packingslips/'+transaction.object_id+'.docx', 
      '*domain*/shippinglabels/'+transaction.object_id+'.pdf' 
     ], 
     "outputformat": "pdf", 
     "wait": true 
    }, function(err, process){ 
     if (err) { 
      console.error('CloudConvert Process failed: ' + err); 
     } 

     process.wait(function(err, process){ 
      if (err) { 
       console.error('CloudConvert Process failed: ' + err); 
      } else { 
       console.log('Done: ' + process.data.message);  
       process.download(fs.createWriteStream('/integration/combinedpdfs/'+transaction.object_id+'.pdf'), null, function (err, process) { 
        if (err) { 
         console.error('CloudConvert Process download failed: ' + err); 
        } else { 
         console.log('Downloaded to ' + '/integration/combinedpdfs/'+transaction.object_id+'.pdf'); 
        } 
       }); 
      }          
     }) 
    }); 
}); 

答えて

1

各入力ファイルには固有のファイル名が必要です。 filenameパラメーターを使用して入力名を無効にすることができます。あなたの場合:

process.start({ 
    "mode": "combine", 
    "input": "download", 
    "files": [ 
     {"file": '*domain*/packingslips/'+transaction.object_id+'.docx', "filename": "template.docx"}, 
     {"file": '*domain*/shippinglabels/'+transaction.object_id+'.pdf', "filename": "other.pdf"} 
    ], 
    "outputformat": "pdf", 
    "wait": true 
}, ...)