jspdf 的 addImage() 函数的确切参数列表及其描述是什么?

What is the exact list of parameters and their description for jspdf's addImage() function?

我在控制台看到jspdf库的addImage()函数有9 parameters. I've seen people using first 5 of them, but not completely sure even about them. Unfortunately, documentation for this method is not provided on official web-site。此外,相应的 github 问题已关闭。

source可以找到方法签名如下:

function(imageData, format, x, y, w, h[, alias[, compression[, rotation]]])

imageData 必须是:

  • 一个ImageData对象
  • 一个<img>元素
  • 一个<canvas>个元素
  • 作为 data uri
  • 的图像
  • 或至少具有 imageData 属性 的对象(具有上述数据类型之一)
    在这种情况下,对象还可以将其他参数的值定义为对象的属性。

format 必须是:

  • 以下字符串之一(不区分大小写):'jpeg', 'jpg', 'png'
  • 如果类型不是 string 则脚本的行为就像函数具有以下签名(format 现在是第六个参数):

    function(imageData, x, y, w, h[, format[, alias[, compression[, rotation]]]])
    

    其中 format 的默认值为 jpeg

xy 必须是:

wh 必须是:

  • 定义图像宽度和高度的数字(也以毫米为单位)

alias(可选)必须是:

  • 用于识别图像的唯一字符串(用于内部缓存)
  • undefinednull 在这种情况下,唯一标识符是图像的散列

compression(可选)必须是:

  • 以下字符串之一(不区分大小写):'NONE'、'FAST'、'MEDIUM'、'SLOW' 任何其他类型或值会将 compression 设置为 NONE

rotation(可选,仅当 imageData 是 DOM 元素时相关)必须是:

  • 一个定义旋转角度的数字
  • 或一个对象,然后可以定义:
    • 旋转角度(angle)
    • 旋转中心(xy)(可选,默认:canvas的中心)
    • 背景颜色(bg)(可选,默认:'white'

答案基于可用的代码 here
如果有任何错误或遗漏信息,请随时添加:)