• [mobile开发碎碎念]手机页面上显示PDF文件


    demo:http://mozilla.github.io/pdf.js/web/viewer.html

    项目地址:https://github.com/mozilla/pdf.js

    <script type="text/javascript">
        //
        // NOTE:
        // Modifying the URL below to another server will likely *NOT* work. Because of browser
        // security restrictions, we have to use a file server with special headers
        // (CORS) - most servers don't support cross-origin browser requests.
        //
        var url = 'aaa.pdf';
    
        //
        // Disable workers to avoid yet another cross-origin issue (workers need the URL of
        // the script to be loaded, and dynamically loading a cross-origin script does
        // not work)
        //
        PDFJS.disableWorker = true;
    
        //
        // Asynchronous download PDF as an ArrayBuffer
        //
        PDFJS.getDocument(url).then(function getPdfHelloWorld(pdf) {
          //
          // Fetch the first page
          //
          pdf.getPage(1).then(function getPageHelloWorld(page) {
            var scale = 1.0;
            var viewport = page.getViewport(($(window).width()-4) / page.getViewport(1.0).width);
    
            //
            // Prepare canvas using PDF page dimensions
            //
            var canvas = document.getElementById('the-canvas');
            var context = canvas.getContext('2d');
            canvas.height = viewport.height;
            canvas.width = viewport.width;
    
            //
            // Render PDF page into canvas context
            //
            page.render({canvasContext: context, viewport: viewport});
          });
        });
      </script>
  • 相关阅读:
    关于异步取消线程以及异步销毁锁的探讨
    pthread_mutex_init & 互斥锁pthread_mutex_t的使用(转)
    Qt设置全局的widget的stylesheet
    浅析pthread_cond_wait(转)
    575 Skew Binary
    HDU 1229 还是A+B
    10370
    10300
    UVA 10071 Problem B Back to High School Physics
    UVA 10055 Problem A Hashmat the brave warrior
  • 原文地址:https://www.cnblogs.com/nasa/p/3469541.html
Copyright © 2020-2023  润新知