PDF JS-延迟加载? [英] PDF JS - Lazy load?

查看:496
本文介绍了PDF JS-延迟加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎pdf.js本身正在请求PDF文件的整个字节范围请求.取而代之的是,是否可以仅在PDF加载时请求5页,在滚动时就可以加载另一组5页,就像这样.是否可以通过使用pdf.js来实现此目的?

It seems, pdf.js itself requesting whole byte range requests of a PDF file. Instead, is it possible to request only 5 pages on PDF load, On scroll can able to load another set of 5 pages, like that.. Is there a way to achieve this by using pdf.js ?

推荐答案

长话短说-否

PDF不是连续的存储格式.如果将PDF文件的格式设置为可快速进行Web查看,则可以让它显示第1页,而其他页面仍在流式传输中,但是您可以不要求从特定的页面或页面范围开始. pdf内部使用了一堆节,它们之间的链节/指针和摘要.可以将它们想象为木块,它们之间有一些细绳.在文件足够"以提供所需的部分之前,您无法呈现任何内容,但是就您的问题而言,内部部分的组织几乎是随机的.

PDF is not a contiguous storage format. If the PDF file is formatted for fast web view then you can get it to show page 1 whilst other pages are still streaming in, but you can't ask to start at a specific page or page range. Internally pdf uses a bunch of sections, links/pointers between them and digests. Think of them as wooden blocks with bits of string between them. You can't render anything until you have 'enough' of the file to provide the parts you need, but the organisation of the internal sections is pretty much random as far as your question is concerned.

获取特定页面的唯一方法是让服务器端组件将它们从您的PDF文件中分离出来,并制作一个仅包含这些部分的新PDF文件,但是翻到第6页将意味着打开一个新页面.文档等.

The only way to get specific pages would be to have a server-side component split them out of the PDF file for you and make a new PDF file containing just those parts, but paging on to page 6 would mean opening a new document, etc.

Acrobat Viewer有一些启动参数,可以让您设置要显示的第一页,其他查看器也可以提供此功能,但是除非您有一些非常聪明的客户端-服务器交互,否则它仍然需要整个PDF文档将首先出现在客户端中.

There are startup params for Acrobat viewer that could allow you to set the first page to be displayed, and other viewers may offer this feature, but unless you have some very smart client-server interaction this would still require the entire PDF document to be present in the client first.

这篇关于PDF JS-延迟加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆