【发布时间】:2021-02-21 10:05:28
【问题描述】:
我的目的是将屏幕截图与标记一起保存。我关注了这个tutorial 和这个 answer,但它对我不起作用。屏幕截图总是没有标记。以下是我的代码
function generateSnaphot(ncrNo_, luName_, keyRef_, markupsStringData) {
console.log('* * * * * generateSnaphot ');
var screenshot = new Image();
screenshot.onload = function () {
viewer.loadExtension('Autodesk.Viewing.MarkupsCore').then(function (markupCore) {
// load the markups
markupCore.show();
markupCore.enterViewMode();
markupCore.loadMarkups(markupsStringData, "layerName");
// ideally should also restore the state of Viewer for this markup
// prepare to render the markups
var canvas = document.getElementById('snapshot');
canvas.width = viewer.container.clientWidth;
canvas.height = viewer.container.clientHeight;
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(screenshot, 0, 0, canvas.width, canvas.height);
markupCore.renderToCanvas(ctx, function() {
// hide the markups
//markupCore.hide();
var canvas = document.getElementById('snapshot');
const a = document.createElement('a');
//a.style = 'display: none';
document.body.appendChild(a);
a.href = canvas.toDataURL();
a.download = 'markup.png';
a.click();
document.body.removeChild(a);
}, true);
// hide the markups
//markupCore.hide();
});
};
// Get the full image
viewer.getScreenShot(viewer.container.clientWidth, viewer.container.clientHeight, function (blobURL) {
console.log('%%%%%%%%%%%%%%% blobURL : ', blobURL);
CreateAndConnectMedia(ncrNo_, luName_, keyRef_, blobURL);
});
}
我从 generateData() 方法中获得了正确的标记,并且还从 blob 中获得了正确的屏幕截图。但最终屏幕截图中缺少标记。
我的代码有问题吗?还是我没有正确处理这个过程?
【问题讨论】:
标签: autodesk-forge autodesk-viewer