|
@@ -148,8 +148,8 @@ async function downloadUrl(url) {
|
|
|
*/
|
|
|
export async function docxToPdf(docxPath, outputPath,options) {
|
|
|
let mergeFiles = options?.mergeFiles || []
|
|
|
- let filePathList = []
|
|
|
let merge = false;
|
|
|
+ let mergeFileMap = {};
|
|
|
if(mergeFiles?.length){
|
|
|
let plist = []
|
|
|
for (let index = 0; index < mergeFiles.length; index++) {
|
|
@@ -159,7 +159,8 @@ async function downloadUrl(url) {
|
|
|
filePath = await downloadUrl(mergeFiles[index]);
|
|
|
}catch(err){}
|
|
|
if(filePath){
|
|
|
- filePathList.push(filePath)
|
|
|
+ mergeFileMap[index] = filePath // 按原有顺序整理
|
|
|
+ // filePathList.push(filePath)
|
|
|
}
|
|
|
return
|
|
|
})())
|
|
@@ -167,6 +168,8 @@ async function downloadUrl(url) {
|
|
|
await Promise.all(plist);
|
|
|
merge = true;
|
|
|
}
|
|
|
+ let filePathList = mergeFiles.map((item,index)=>mergeFileMap[index]).filter(item=>item)
|
|
|
+
|
|
|
console.log("DOWNLOADED:",filePathList)
|
|
|
try {
|
|
|
let docxBuffer = fs.readFileSync(docxPath);
|