Pdf.js: シングルページビューアの例を作成します

作成日 2017年09月24日  ·  8コメント  ·  ソース: mozilla/pdf.js

プルリクエスト#8724では、単一ページビューアが実装されています。 examplesフォルダーに、このビューアーの使用方法を示すコンポーネントの例があると便利です。

1-other 5-good-beginner-bug

最も参考になるコメント

コンポーネントフォルダ内のpageviewer.jsは、pdf_page_view.jsを使用してPDFファイルを通常どおりに表示する例です。 pdf_single_page_viewer.jsを使用するsinglepageviewer.jsのような例を作成する必要があります。

PDFSinglePageViewer PDFViewerと同じインターフェースを実装していることを考慮して、新しい例はhttps://github.com/mozilla/pdf.js/blob/master/examples/components/simpleviewer.jsに基づいてい

全てのコメント8件

こんにちは! この問題に対処したいと思います。 Githubで問題を解決するのはこれが初めてなので、開始方法を理解するのを手伝っていただければ幸いです。
gulpサーバーでローカルコピーを実行しています。

https://github.com/mozilla/pdf.js/tree/master/examples/componentsフォルダーにコンポーネントの例があります。 このパッチの目的は、 PDFSinglePageViewerを使用する例を追加することです。 他の例と同様に、デフォルトのTracemonkeyPDFファイルをロードするだけです。

ありがとう! 私はこれに取り組んでみます。

だから、私はここで少し混乱しています。 これは私が理解したことです:
コンポーネントフォルダ内のpageviewer.jsは、pdf_page_view.jsを使用してPDFファイルを通常どおりに表示する例です。 pdf_single_page_viewer.jsを使用するsinglepageviewer.jsのような例を作成する必要があります。

私は今のところ正しい道を進んでいますか?

それで、基本的にこれは、単一のページビューアを利用するためにpageviewer.jsファイルから編集する必要があるものですか?

return pdfDocument.getPage(PAGE_TO_VIEW).then(function (pdfPage) {
    // Creating the page view with default parameters.
    var pdfPageView = new PDFJS.PDFPageView({
      container: container,
      id: PAGE_TO_VIEW,
      scale: SCALE,
      defaultViewport: pdfPage.getViewport(SCALE),
      // We can enable text/annotations layers, if needed
      textLayerFactory: new PDFJS.DefaultTextLayerFactory(),
      annotationLayerFactory: new PDFJS.DefaultAnnotationLayerFactory()
    });
    // Associates the actual page with the view, and drawing it
    pdfPageView.setPdfPage(pdfPage);
    return pdfPageView.draw();
  });

これが、singlepageviewer.jsに編集された部分として含まれているものです。

return pdfDocument.getPage(PAGE_TO_VIEW).then(function (pdfPage) {
    // Creating the page view with default parameters.
    var pdfSinglePageView = new PDFJS.PDFSinglePageViewer({
      container: container,
      id: PAGE_TO_VIEW,
      scale: SCALE,
      defaultViewport: pdfPage.getViewport(SCALE),
      // We can enable text/annotations layers, if needed
      textLayerFactory: new PDFJS.DefaultTextLayerFactory(),
      annotationLayerFactory: new PDFJS.DefaultAnnotationLayerFactory()
    });
    // Associates the actual page with the view, and drawing it
    pdfSinglePageView.setPdfPage(pdfPage);
    return pdfSinglePageView.draw();
  });

これまでの私のアプローチは理にかなっていますか?

どうもありがとうございました!

適切なフォーマットでコメントを再投稿します。

コンポーネントフォルダ内のpageviewer.jsは、pdf_page_view.jsを使用してPDFファイルを通常どおりに表示する例です。 pdf_single_page_viewer.jsを使用するsinglepageviewer.jsのような例を作成する必要があります。

PDFSinglePageViewer PDFViewerと同じインターフェースを実装していることを考慮して、新しい例はhttps://github.com/mozilla/pdf.js/blob/master/examples/components/simpleviewer.jsに基づいてい

そのアドバイスをありがとう!
プルリクエストを送信しましたhttps://github.com/mozilla/pdf.js/pull/8989。 確認して、変更が必要な場合はお知らせください。

編集:
ここで何かが足りないかどうかはわかりませんが、コンポーネントの例のいずれも、ブラウザのhttp://localhost:8888/examples/components/{anyfile}.html何も表示しません。 コンソールに次のエラーが表示されます。

singlepageviewer.html:38 GET http://localhost:8888/node_modules/pdfjs-dist/web/pdf_viewer.css net::ERR_ABORTED
singlepageviewer.html:40 GET http://localhost:8888/node_modules/pdfjs-dist/build/pdf.js net::ERR_ABORTED
singlepageviewer.html:41 GET http://localhost:8888/node_modules/pdfjs-dist/web/pdf_single_page_viewer.js net::ERR_ABORTED
singlepageviewer.js:18 Uncaught ReferenceError: PDFJS is not defined
    at singlepageviewer.js:18

ここで何かが足りないかどうかはわかりませんが、 http:// localhost :8888 / examples / components / {anyfile} .htmlのブラウザーにコンポーネントの例で何も表示されません。 コンソールに次のエラーが表示されます。

例の*.jsファイルで述べたように、たとえばここを参照してください。 gulp dist-installか?

了解、ありがとう!
レビューされたすべての変更を含み、Contributing and Squashing Commits wikiによるプルリクエストは次のとおりです: https
どうもありがとうございました!

このページは役に立ちましたか?
0 / 5 - 0 評価