mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.22k stars 9.96k forks source link

Print in IE11 just using pdf.js #9223

Closed abramhum closed 6 years ago

abramhum commented 6 years ago

Hi:

I use pdf.js to print pdf in canvas, and it work very well, but when I using printThis library to print the data in canvas in IE11, the result is terrible, the bottom rim will excess the page and show the rim in the upper edge of the second page. But this not happen in chrome. Chrome work well. My pdfjs Version is '1.7.225'; My code snippet is as followings: `javascript part:

<script type="text/javascript" src="./../pdfjs/printThis.js"></script>

    function CallPDFJsToPrintCanvas(base64data) {
        PDFJS.workerSrc = './../pdfjs/pdf.worker.js';
        PDFJS.getDocument(ConvertToBinary(base64data)).then(function (pdf) {
                var pageNum = 1;
                pdf.getPage(pageNum).then(function (page) {
                    var canvas = document.createElement('canvas');
                    canvas.classname += "mainCanvas";
                    var context = canvas.getContext('2d');
                    var viewport = page.getViewport(4);
                    canvas.height = viewport.height;
                    canvas.width = viewport.width;
                    canvas.style.height = "29.7cm";
                    canvas.style.width = "21cm";
                    document.getElementById('pdf-container').appendChild(canvas);
                    var renderContext = {
                        canvasContext: context,
                        viewport: viewport
                    };

                    var renderTask = page.render(renderContext);
                });

        })
    }

CSS part: @media all and (-ms-high-contrast:none) { .mainCanvas { width: 21cm; height: 29.7cm; margin: 0mm 0mm 0mm 0mm; overflow: hidden; } /IE11/ }

` If there any solution for that, thanks a lot.

Snuffleupagus commented 6 years ago

but when I using printThis library to print the data in canvas in IE11, the result is terrible,

What is "printThis"; are you perhaps referring to https://github.com/jasonday/printThis? Please keep in mind that we cannot provide support for other libraries, so you'll need to direct support queries to its vendor instead.

My pdfjs Version is '1.7.225';

That version is no longer supported, please find the latest releases in https://github.com/mozilla/pdf.js/releases.

Finally, as asked for in both ISSUE_TEMPLATE.md and CONTRIBUTING.md, for questions regarding custom implementations of PDF.js a working example must be provided (since just code snippets aren't helpful).

Closing as incomplete.