前言 本文的解决方案旨在解决大体积PDF在线浏览加载缓慢、影响用户体验的难题。通过利用分片加载技术,前端请求时附带range及读取大小信息,后端据此返回相应的PDF文件流。这种方式有效地减轻了服务器和浏览器的负担,提升了加载速度和用户体验。同时解决了首次加载全部分片导致浏览器内存不足的问题。 技术栈:Spring Boot、Vue和pdf.js。 分片加载的效果 前端项目 index.vue <template> <div class="pdf"> <iframe :src="`/static/pdf/web/viewer.html?file=${encodeURIComponent(src)}`" frameborder="0" style="width: 100%; height: calc(100vh)" ></iframe> </div> </template> <script> import baseUrl from "@/api/baseurl.js"; export default { data() { return { baseUrl:...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with response.setContent
Contact response.setContent, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack