How to generate utf-8 tables in jsPDF?

岁酱吖の 提交于 2021-01-29 12:58:56

问题


I test jsPDF playground, Arabic section http://raw.githack.com/MrRio/jsPDF/master/#, but couldn't make a utf table. here is the code which I've used, I wonder how should I fix this,

var generateData = function(amount) {
  var result = [];
  var data = {
    coin: "100",
    game_group: "گروه",
    game_name: "سلام",
    game_version: "25",
    machine: "20485861",
    vlt: "0"
  };
  for (var i = 0; i < amount; i += 1) {
    data.id = (i + 1).toString();
    result.push(Object.assign({}, data));
  }
  return result;
};

function createHeaders(keys) {
  var result = [];
  for (var i = 0; i < keys.length; i += 1) {
    result.push({
      id: keys[i],
      name: keys[i],
      prompt: keys[i],
      width: 65,
      align: "center",
      padding: 0
    });
  }
  return result;
}

var headers = createHeaders([
  "id",
  "coin",
  "game_group",
  "game_name",
  "game_version",
  "machine",
  "vlt"
]);

var doc = new jsPDF();
doc.addFont("test/reference/Amiri-Regular.ttf", "Amiri", "normal");

doc.setFont("Amiri"); // set font
doc.setFontSize(50);
doc.table(1, 1, generateData(100), headers, { autoSize: true });

来源:https://stackoverflow.com/questions/64183071/how-to-generate-utf-8-tables-in-jspdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!