Hướng dẫn pdf javascript - pdfjavascript

Current View

Go to First Page Go to Last Page
Rotate Clockwise Rotate Counterclockwise
Enable hand tool
Document Properties…
Toggle Sidebar
Find
Previous
Next
Page:
Presentation Mode Open Print Download Current View
Tools
Zoom Out
Zoom In
Automatic Zoom Actual Size Fit Page Full Width 50% 75% 100% 125% 150% 200% 300% 400%
More Information Less Information
Close

Enter the password to open this PDF file:

Cancel OK
File name:

-

File size:

-

Title:

-

Author:

-

Subject:

-

Keywords:

-

Creation Date:

-

Modification Date:

-

Creator:

-

PDF Producer:

-

PDF Version:

-

Page Count:

-

Close
#mozPrintCallback-shim { position: fixed; top: 0; left: 0; height: 100%; width: 100%; z-index: 9999999; display: block; text-align: center; background-color: rgba[0, 0, 0, 0.5]; } #mozPrintCallback-shim[hidden] { display: none; } @media print { #mozPrintCallback-shim { display: none; } } #mozPrintCallback-shim .mozPrintCallback-dialog-box { display: inline-block; margin: -50px auto 0; position: relative; top: 45%; left: 0; min-width: 220px; max-width: 400px; padding: 9px; border: 1px solid hsla[0, 0%, 0%, .5]; border-radius: 2px; box-shadow: 0 1px 4px rgba[0, 0, 0, 0.3]; background-color: #474747; color: hsl[0, 0%, 85%]; font-size: 16px; line-height: 20px; } #mozPrintCallback-shim .progress-row { clear: both; padding: 1em 0; } #mozPrintCallback-shim progress { width: 100%; } #mozPrintCallback-shim .relative-progress { clear: both; float: right; } #mozPrintCallback-shim .progress-actions { clear: both; }
Preparing document for printing...
0%

Trong file các bạn chú ý đoạn code trên thẻ head:

            var config = {
                imageResourcesPath : './images/', // duong dan toi folder image
                workerSrc : 'pdf.worker.js', // duong dan toi toi file pdf.worker.js
                pdfFile : 'demo.pdf' // duong dan toi file pdf
            };
        
        
        
        
        
        
        

Bạn chú ý là chỉ đổi ba thông các thông số trong biến config nhé, còn các file css và js mình sẽ đính kèm theo.

Cách hiển thị PDF Reader trên website

Với đoạn mã HTML trên thì chiều rộng và chiều cao của trang sẽ là 100% nên bạn không thể đưa nó vào trong một trang web bình thường được, thay vào đó bạn hay tạo một file hiển thị riêng, sau đó dùng iframe để embed vào xác định chiều rộng, cao cho iframe. Như vậy bạn đã làm được chức năng đọc file pdf online rồi đấy.đọc file pdf online rồi đấy.

Bài viết này được đăng tại freetuts.net, không được copy dưới mọi hình thức.freetuts.net, không được copy dưới mọi hình thức.

Lời kết

Nếu bạn đọc document của plugin này thì cũng có thể tự làm được nhưng mình nghĩ tại sao không dùng những cái có sẵn, ban chỉ cần download về và custome lại y như phần 1 tôi đã trình bày thì việc đọc file pdf online với PDFReader pdf.js không còn là khó khăn nữa

Danh sách file tải về

Tên file tải vềPass giải nén
Download pdf reader freetuts.net hoặc gameportable.net

Bài Viết Liên Quan

Chủ Đề