我正在通过 Captivate Prime 中运行的 Captivate 课程创建自定义证书。我们编写了关于从 Captivate Prime 获取 API 的代码,它们似乎在 Chrome、Firefox 和 Edge 中填充,但在 IE 7-10 中没有。作为一个单独的问题,将证书生成为 PDF 是通过代码完成的,并且该代码由按钮激活。当学员返回 Captivate Prime 中的课程时,该按钮将不再起作用。
设置:学习者参加 10 个问题的测试。如果通过,则打开证书“课程”,当它显示时,它会从 API 中提取信息并填写一般信息;姓名、地址、课程名称、参加过的比赛等。页面上有一个按钮,学习者可以单击该按钮创建 PDF 并下载它,其中包含已提取的 API 中的所有信息。在 Internet Explorer 中,Captivate Prime 中的页面不会填写 API 信息,但它可以在 Chrome、Firefox 和 Edge 中使用。如果您返回课程并查看该内容(证书创建),则信息会再次加载到视觉对象上,但该按钮将无法生成 PDF。
我附上了代码,但如果我没有足够详细地描述这一点或者您有任何疑问,请随时提问。
这是 PDF 创建。
// This is the function that will generate a PDF from an image and text fields.
function createCert() {
var imgBackground = new Image();
imgBackground.src = "DHA-Test-Cert.png";
imgBackground.onload = function () {
var doc = new jsPDF({
orientation: "landscape",
unit: "in",
format: [11, 8.5],
});
doc.addImage(imgBackground, 0, 0, 11, 8.5);
var userName = window.cpAPIInterface.getVariableValue("v_UserName");
var fileName = "DHACertPDF.pdf";
var courseTitle = window.cpAPIInterface.getVariableValue("v_CourseTitle");
var dateCompleted =
window.cpAPIInterface.getVariableValue("v_CompletionDate");
var userAddress1 = window.cpAPIInterface.getVariableValue("v_Address1");
var userAddress2 = window.cpAPIInterface.getVariableValue("v_Address2");
var userCityStateZip =
window.cpAPIInterface.getVariableValue("v_CityStateZip");
doc.setFontSize(12);
doc.setTextColor(0, 0, 0);
doc.setFont("helvetica");
doc.setFontType("bold");
doc.text(4.6, 6.6, userName, null, null, "left");
doc.text(4.6, 7.2, courseTitle, null, null, "left");
doc.setFontType("normal");
doc.text(0.41, 2.8, dateCompleted, null, null, "left");
doc.text(0.41, 3.0, courseTitle, null, null, "left");
doc.text(0.41, 5.6, userName, null, null, "left");
doc.text(0.41, 5.8, userAddress1, null, null, "left");
doc.text(0.41, 6.0, userAddress2, null, null, "left");
doc.text(0.41, 6.2, userCityStateZip, null, null, "left");
doc.save(fileName);
};
}