Tuyến tính hóa PDF
Sắp xếp lại tệp để trang đầu hiện ra trước khi phần còn lại về tới.
Công cụ này chạy hoàn toàn trong trình duyệt của bạn. Tệp của bạn không bao giờ được tải lên, và bạn có thể tự kiểm chứng điều đó trong tab mạng của trình duyệt. Tự kiểm chứng: mở tab mạng của trình duyệt và theo dõi. Bạn sẽ thấy một yêu cầu nhỏ hỏi xem bạn còn tác vụ nào không - một tên công cụ và một mã băm, không bao giờ là tệp.
Công cụ này làm gì
A linearised PDF is the same document with its objects in a different order. Everything the first page needs is moved to the front of the file, so a reader can draw page one while the remaining megabytes are still arriving. Nothing about the pages, the text or the images changes - open the result next to the original and you will not be able to tell them apart on screen.
Do it to any PDF you publish on a website, link to in an email, or hand to a viewer embedded in an app. It matters most for large files on slow connections, where a document that opens in two seconds and one that appears to hang for thirty are the same file in two different orders.
Cách hoạt động
- Drop the PDF onto this page. Files up to 300 MB are accepted.
- Leave Also repack the file on. It recompresses the streams first, which usually takes another 10 to 25 per cent off the size.
- Press Linearize.
- The download starts on its own, with a -web suffix so you can tell the two versions apart.
- Upload the result as it is. No setting is needed to produce the effect, though your server must support byte-range requests for readers to use it.
The mechanism is ordering, not compression. In an ordinary PDF the objects sit wherever the producer wrote them and the index that finds them is at the end, so a reader over HTTP either waits for the whole file or asks for pieces of it in several round trips. Linearising puts a small hint table, the first page and every object that page depends on right at the front, followed by the rest in page order.
Repacking and linearising pull against each other, which is why the order of the passes matters. Object streams make a file smaller by packing many objects into one compressed block, and linearisation needs the first page's objects reachable on their own. The repack runs first and the linearisation last, so qpdf resolves the conflict rather than producing a file that claims to be linearised and is not.
The effect only exists if the server cooperates. Fast Web View depends on HTTP byte-range requests: the reader asks for the first part of the file, draws page one, then asks for more. A server that does not honour ranges sends the whole file regardless, and the linearised document behaves like the ordinary one. Most static hosting and every CDN supports ranges; some application frameworks streaming a file through their own handler do not.
If the repack fails on an unusual file, you still get the linearisation you asked for. Recompression is treated as a bonus rather than a requirement.
The job happens in your browser through qpdf compiled to WebAssembly, so the file you are preparing to publish - often still a draft - reaches no server before you put it on one.
Công cụ này không làm được gì
- The benefit only appears when the file is served over HTTP by a server that supports byte-range requests. Opening a linearised file from disk is no faster.
Câu hỏi thường gặp
- Tuyến tính hóa thực sự làm gì với tệp?
- Nó viết lại cùng một nội dung theo thứ tự khác: một bảng gợi ý và mọi thứ trang đầu cần được đưa lên phía trước, phần còn lại theo sau theo thứ tự trang. Không trang, ảnh hay ký tự nào thay đổi. Tệp thường lớn hơn một chút so với phiên bản đóng gói hoàn toàn, vì một số đối tượng không còn dùng chung được một khối nén.
- Tôi có cần dùng nó cho một tệp chỉ để gửi email không?
- Không. Fast Web View chỉ có ích khi một trình đọc đang lấy tài liệu qua HTTP từng phần một. Một tệp đính kèm được tải trọn vẹn trước khi mở, nên tuyến tính hóa nó chẳng thay đổi gì. Hãy dùng nó cho bất cứ thứ gì bạn lưu trữ trên máy chủ, nhúng hay liên kết tới.
- Nó làm tệp lớn hơn hay nhỏ hơn?
- Cả hai tác động đều diễn ra. Tuyến tính hóa thêm một bảng gợi ý và ngăn một số đối tượng đóng gói chung với nhau, việc này tốn thêm chút ít. Tùy chọn đóng gói lại nén lại mọi luồng, việc này thường tiết kiệm 10 đến 25 phần trăm với một tệp chưa ai tối ưu. Khi bật đóng gói lại, kết quả thường nhỏ hơn tệp ban đầu của bạn.
- Làm sao tôi xác nhận tệp đã được tuyến tính hóa?
- Hãy mở kết quả trong Acrobat và xem thuộc tính tài liệu: Fast Web View hiển thị Yes. Trên dòng lệnh, qpdf --check báo cáo tệp là đã tuyến tính hóa. Để kiểm chứng tác động thực tế, bạn cũng cần phục vụ nó qua HTTP từ một máy chủ chấp nhận yêu cầu theo dải byte.
- Tệp có được tải lên đâu đó không?
- Không. qpdf chạy dưới dạng WebAssembly trong một Web Worker bên trong trình duyệt của bạn, nên tài liệu ở lại trên thiết bị của bạn cho đến khi chính bạn công bố nó. Trang này cũng hoạt động khi không có kết nối sau khi đã tải xong.