vue-pdf: Error during font loading: Failed to execute 'postMessage' on 'Worker': ArrayBuffer at index 0 is already detached
- vue-pdf version 4.0.11
- vue.js version 2.6.11
import CMapReaderFactory from 'vue-pdf/src/CMapReaderFactory.js'
this.vuePdfSrc = pdf.createLoadingTask({url:src,CMapReaderFactory})
after use CMapReaderFactory ,First rendering of PDF file ,Fonts can be realistic.
But when I switch the URL of the PDF file, I call again
this.vuePdfSrc = pdf.createLoadingTask({url:src,CMapReaderFactory})
Console prompt Warning: Error during font loading: Failed to execute 'postMessage' on 'Worker': ArrayBuffer at index 0 is already detached.
and Some fonts cannot be displayed.
Is there something wrong with the way I use it?
I need to toggle the PDF file on the same page
Thank you in advance for your answer
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 30
temporary fix :
complete CMapReaderFactory.js file
解决办法,拷贝cmap文件到本地,直接引用。
this.src = pdf.createLoadingTask({ // url: this.$route.params.srcId, url: 'http://localhost:8887/22.pdf', cMapUrl: '../../../../static/cmaps/', cMapPacked: true})原因其实是CMapReaderFactory 对象动态import语言文件的时候缓存了文件,导致第二次取缓存加载时出了问题,把CMapReaderFactory.js的代码改成这样就行了: ` var bcmapName = ‘./buffer-loader!pdfjs-dist/cmaps/’+query.name+‘.bcmap’; return import(bcmapName).then(function(bcmap) { //移除缓存的文件 delete require.cache[require.resolve(bcmapName)];
`
Is there any way not to modify dependent files?
提示:Error during font loading: unexpected EOF in bcmap
搞出来了没