这段代码:
PDFJS.getDocument(parameters).then(
function getDocumentCallback(pdfDocument) {
self.load(pdfDocument, scale);
self.loading = false;
}
应该调用这个函数:
PDFJS.getDocument = function getDocument(source) {
return alert('never gets here');
var workerInitializedPromise, workerReadyPromise, transport;
if (typeof source === 'string') {
source = { url: source };
return alert('string');
} else if (isArrayBuffer(source)) {
source = { data: source };
return alert('data');
} else if (typeof source !== 'object') {
return alert('erro');
error('Invalid parameter in getDocument, need either Uint8Array, ' +
'string or a parameter object');
}
if (!source.url && !source.data) {
error('Invalid parameter array, need either .data or .url');
return alert('erro 2');
}
// copy/use all keys as is except 'url' -- full path is required
var params = {};
for (var key in source) {
if (key === 'url' && typeof window !== 'undefined') {
params[key] = combineUrl(window.location.href, source[key]);
continue;
}
params[key] = source[key];
}
workerInitializedPromise = new PDFJS.Promise();
workerReadyPromise = new PDFJS.Promise();
transport = new WorkerTransport(workerInitializedPromise, workerReadyPromise);
workerInitializedPromise.then(function transportInitialized() {
transport.fetchDocument(params);
});
return workerReadyPromise;
};
虽然如果我使用
@Scripts.Render("~/PDF/js")
调用脚本而不是使用
<script type="text/javascript" src="Url.Content("~/pdf.js/api.js")"> </script>
该功能PDFJS.getDocument
永远不会被触发。
我错过了什么吗?
编辑:两种情况下都加载了 js 文件。只是函数没有被调用