Global

Methods

(async) WHtml2docx(fpInHtml, fpOutDocx, optopt) → {Promise}

Description:
  • Html檔轉Docx檔

Source:
Example
import w from 'wsemi'
import WHtml2docx from './src/WHtml2docx.mjs'
//import WHtml2docx from 'w-html2docx/src/WHtml2docx.mjs'
//import WHtml2docx from 'w-html2docx'

async function test() {

    let fpIn = `./test/ztmp.html`
    let fpOut = `./test/ztmp.docx`
    let opt = {
        imgRatioWidthMax: 0.5,
    }

    let r = await WHtml2docx(fpIn, fpOut, opt)
    console.log(r)
    // => ok

    w.fsDeleteFile(fpOut)

}
test()
    .catch((err) => {
        console.log('catch', err)
    })
Parameters:
Name Type Attributes Default Description
fpInHtml String

輸入來源Html檔位置字串

fpOutDocx String

輸入轉出Docx檔位置字串

opt Object <optional>
{}

輸入設定物件,預設{}

Properties
Name Type Attributes Default Description
fpInTemp String <optional>
'./src/tmp.docx'

輸入Docx模板檔案位置字串,預設'./src/tmp.docx'

fontFamilies Array | String <optional>
['標楷體','Times New Roman']

輸入轉出Docx時強制更改字型陣列或字串,陣列順序為變更順序,若有要覆寫字型得放後面。預設['標楷體','Times New Roman']

imgRatioWidthMax String <optional>
1

輸入圖片最大寬度比例,值介於0至1,預設1

imgRatioHeightMax String <optional>
1

輸入圖片最大高度比例,值介於0至1,預設1

Returns:

回傳Promise,resolve回傳成功訊息,reject回傳錯誤訊息

Type
Promise