如何在不定义 pdf.worker 位置的情况下使用 pdf.js
how to use pdf.js without defining pdf.worker location
我在使用 pdf.js 查看 pdf 时遇到问题。问题来自于
PDFJS.workerSrc 设置。是否可以将 pdf.worker.js 包含在
header,喜欢
<script type="text/javascript" src="./../jsfiles/pdf.worker.js"></script>
并且不使用
PDFJS.workerSrc = './../jsfiles/pdf.worker.js';
这可能吗?非常感谢。
In order to bundle all src/
files into two production scripts and build the generic viewer, run:
$ gulp generic
This will generate pdf.js
and pdf.worker.js
in the build/generic/build/
directory. Both scripts are needed but only pdf.js
needs to be included since pdf.worker.js
will be loaded by pdf.js
. The PDF.js files are large and should be minified for production.
这意味着你只需要添加以下代码:
<script type="text/javascript" src="pdf.js"></script>
请记住,所有生成的文件都应位于与 pdf.js
相同的目录中
我在使用 pdf.js 查看 pdf 时遇到问题。问题来自于 PDFJS.workerSrc 设置。是否可以将 pdf.worker.js 包含在 header,喜欢
<script type="text/javascript" src="./../jsfiles/pdf.worker.js"></script>
并且不使用
PDFJS.workerSrc = './../jsfiles/pdf.worker.js';
这可能吗?非常感谢。
In order to bundle all
src/
files into two production scripts and build the generic viewer, run:$ gulp generic
This will generate
pdf.js
andpdf.worker.js
in thebuild/generic/build/
directory. Both scripts are needed but onlypdf.js
needs to be included sincepdf.worker.js
will be loaded bypdf.js
. The PDF.js files are large and should be minified for production.
这意味着你只需要添加以下代码:
<script type="text/javascript" src="pdf.js"></script>
请记住,所有生成的文件都应位于与 pdf.js