Web paging preview method, system and equipment of PDF file and medium

By splitting PDF files into fine units and loading their images on demand, the problem of slow loading speed and high memory usage in large PDF file previews is solved, improving user experience and loading efficiency.

CN118673233APending Publication Date: 2024-09-20INSPUR FINANCIAL INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410664711.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-09-20

Smart Images

  • Figure CN118673233A
    Figure CN118673233A
Patent Text Reader

Abstract

The invention discloses a web paging preview method, a web paging preview system and web paging preview equipment for a PDF (Portable Document Format) file and a medium. The web paging preview method comprises the following steps of: carrying out fine unit splitting on a PDF to be processed; performing picture conversion operation on the PDF after the fine unit splitting; loading the PDF after picture conversion as required according to the element showing condition; according to the method and the device, the problems of too slow transmission and too large memory occupation of a large PDF network can be solved, the first screen waiting time of a user is shortened, the user experience is improved, and the file loading flexibility and efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a method, system, device and medium for web paging preview of a PDF file. Background Art

[0002] In web browser applications, the need to preview PDF files is very common. Common implementation methods currently include using iframe tags and embed tags to directly load PDF files, or using third-party plug-in libraries such as pdf.js and react-pdf to implement PDF preview functions. These methods can meet the basic needs of users in most cases, but they have obvious shortcomings when processing large PDF files.

[0003] Specifically, when the PDF file is large, the traditional preview method often faces the problems of slow loading speed and excessive memory usage. This is because large PDF files require longer network transmission time, which directly affects the user experience. For example, a PDF file of about 15M and containing more than 100 pages may take up to 30 seconds to transmit in a server environment with a bandwidth of 4M, which is obviously unacceptable for modern users who pursue efficiency and speed.

[0004] In addition, even if the file is successfully transferred to the browser, the rendering of large PDF files in the browser will consume a lot of memory resources, which may cause the browser performance to deteriorate or even freeze or crash.

[0005] Therefore, the existing PDF preview technology has obvious performance bottlenecks when processing large files, and it is necessary to seek more efficient solutions to optimize the preview process and improve the user experience. Summary of the invention

[0006] The object of the present invention is to provide a method, system, device and medium for web page preview of PDF files, thereby solving all or one of the above problems existing in the prior art.

[0007] In order to solve the above technical problems, the specific technical solutions of the present invention are as follows: In one aspect, the present invention provides a method for web page preview of a PDF file, comprising the following steps: Preprocessing steps: Split the PDF to be processed into fine units; Format conversion steps: Performing image conversion operation on the PDF obtained by splitting the fine units; Lazy loading steps: The PDF converted from the image is loaded on demand according to the element display situation.

[0008] As an improved solution, the fine unit splitting includes: Convert the PDF to be processed into several sub-PDF files.

[0009] As an improved solution, the fine unit splitting further includes: The PDF to be processed is converted into a plurality of sub-PDF files according to page numbers.

[0010] As an improved solution, the picture conversion operation includes: The preprocessing script and the pdf-image library are used to convert the plurality of sub-pdf files into images.

[0011] As an improved solution, the picture conversion operation further includes: Use pdf-image to obtain the file information of the PDF to be processed, traverse the page numbers, and call convertPage of pdf-image to convert each page of the sub-pdf file into a corresponding image file.

[0012] As an improved solution, the image file corresponding to the sub-pdf file is the PDF file after the image is converted.

[0013] As an improved solution, the PDF converted from the image is loaded on demand according to the element display situation, including: In response to obtaining the PDF converted from the image, when an IntersectionObserver is used to monitor that an element appears within the viewport, the PDF converted from the image is loaded accordingly.

[0014] On the other hand, the present invention also provides a web page preview system for a PDF file, comprising: The preprocessing module is used to: split the PDF to be processed into fine units; A format conversion module, used for: performing image conversion operation on the PDF after the fine unit is split; The lazy loading module is used to load the PDF converted from the image on demand according to the element display situation.

[0015] On the other hand, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the web paging preview method of the PDF file are implemented.

[0016] On the other hand, the present invention further provides a computer device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; wherein: The memory is used to store computer programs; The processor is used to execute the steps of the web page preview method of the PDF file by running the program stored in the memory.

[0017] The beneficial effects of the technical solution of the present invention are: 1. The web paging preview method of the PDF file described in the present invention can solve the problem of slow network transmission of large PDF files and excessive memory usage, reduce the user's first screen waiting time, improve user experience, and improve the flexibility and efficiency of file loading.

[0018] 2. The web page preview system for PDF files described in the present invention can realize the web page preview method for PDF files described in the present invention through the mutual cooperation of system modules.

[0019] 3. The computer-readable storage medium described in the present invention can realize the cooperation of the guiding system module, thereby realizing the web paging preview method of the PDF file described in the present invention, and the computer-readable storage medium described in the present invention also effectively improves the operability of the web paging preview method of the PDF file.

[0020] 4. The computer device described in the present invention can store and execute the computer-readable storage medium, thereby realizing the web paging preview method of the PDF file described in the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 It is a flowchart of the web page preview method of a PDF file according to Embodiment 1 of the present invention; Figure 2 It is a detailed flowchart of the web page preview method of a PDF file according to Embodiment 1 of the present invention; Figure 3 It is a schematic diagram of the architecture of the web page preview system for PDF files according to Embodiment 2 of the present invention; Figure 4 is a schematic diagram of the structure of the computer device described in Example 4 of the present invention; The symbols in the accompanying drawings are explained as follows: 1501, processor; 1502, communication interface; 1503, memory; 1504, communication bus. DETAILED DESCRIPTION

[0023] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present invention.

[0024] In the description of the present invention, it should be noted that the embodiments described in the present invention are only part of the embodiments of the present invention, rather than all of the embodiments; based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present invention.

[0025] The terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this article described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment. Example 1

[0026] This embodiment provides a web page preview method for a PDF file, such as Figure 1 and Figure 2 As shown, the following steps are included: The core function of the present invention is to solve the problem that large PDF files are transmitted too slowly over the network and occupy too much memory. The specific steps are as follows: S100, pre-processing steps: In one implementation, the entire PDF file is split into smaller units for preview; Specifically, convert an entire PDF file into images according to page numbers, with one PDF page corresponding to one image. Based on this preprocessing, subsequent on-demand loading or piecewise loading can be facilitated instead of loading the entire PDF file at once. S200, format conversion steps: In one implementation, use node to write a preprocessing script, and use the pdf-image library to convert each page of the PDF file to be processed into an image. Specifically, the key to reading PDF data is to use pdf-image to obtain the information of the PDF file, then traverse the page numbers, and then call pdfImage's convertPage to convert each page into a corresponding image.

[0027] S300, lazy loading steps: In one implementation, in response to each page of images being obtained, all rendering is not performed at once, and IntersectionObserver is used to monitor whether the element appears within the viewport. If it does, the image is loaded, thereby achieving on-demand loading of PDF files.

[0028] It should be noted that all the above examples are only for explaining the present invention and cannot limit the protection scope of the present invention. Example 2

[0029] This embodiment is based on the same inventive concept as the web page preview method of a PDF file described in Embodiment 1, and provides a web page preview system for a PDF file, such as Figure 3 As shown, including: The preprocessing module is used to: split the PDF to be processed into fine units; A format conversion module, used for: performing image conversion operation on the PDF after the fine unit is split; The lazy loading module is used to load the PDF converted from the image on demand according to the element display situation. Example 3

[0030] This embodiment provides a computer-readable storage medium, including: The storage medium is used to store computer software instructions used to implement the web paging preview method for PDF files described in the above-mentioned embodiment 1, which includes a program for executing the above-mentioned web paging preview method for PDF files; specifically, the executable program can be built into the web paging preview system for PDF files described in the embodiment 2, so that the web paging preview system for PDF files can implement the web paging preview method for PDF files described in the embodiment 1 by executing the built-in executable program.

[0031] In addition, the computer-readable storage medium of this embodiment may adopt any combination of one or more computer-readable storage media, wherein the computer-readable storage medium includes electrical, optical, electromagnetic, infrared or semiconductor systems, devices or components, or any combination thereof. Example 4

[0032] This embodiment provides an electronic device, such as Figure 4 As shown, the electronic device may include: a processor 1501 , a communication interface 1502 , a memory 1503 and a communication bus 1504 , wherein the processor 1501 , the communication interface 1502 , and the memory 1503 communicate with each other via the communication bus 1504 .

[0033] Memory 1503, used for storing computer programs; The processor 1501 is used to implement the steps of the web page preview method of the PDF file described in the above embodiment 1 when executing the computer program stored in the memory 1503.

[0034] As an embodiment of the present invention, the communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0035] As an implementation mode of the present invention, the communication interface is used for communication between the above-mentioned terminal and other devices.

[0036] As an embodiment of the present invention, the memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0037] As an embodiment of the present invention, the above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.

[0038] Different from the prior art, the web paging preview method, system, device and medium of a PDF file of the present application can solve the problem of slow network transmission of large PDF files and excessive memory usage, reduce the user's first screen waiting time, improve user experience, and improve the flexibility and efficiency of file loading.

[0039] It should be understood that in the various embodiments of this document, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this document.

[0040] It should also be understood that in the embodiments of this document, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this document generally indicates that the associated objects before and after are in an "or" relationship.

[0041] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this article.

[0042] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0043] In the several embodiments provided herein, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or can be electrical, mechanical or other forms of connection.

[0044] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of this article.

[0045] In addition, each functional unit in each embodiment of this invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional unit.

[0046] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this article is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of this article. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0047] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A web page preview method for PDF files, It is characterized in that The following steps are involved: Preprocessing steps: Split the PDF to be processed into fine units; Format conversion steps: Performing image conversion operation on the PDF obtained by splitting the fine units; Lazy loading steps: The PDF converted from the image is loaded on demand according to the element display situation.

2. The web page preview method of a PDF file according to claim 1, Features: The fine unit splitting includes: Convert the PDF to be processed into several sub-PDF files.

3. The web page preview method of a PDF file according to claim 2, Features: The fine unit splitting further comprises: The PDF to be processed is converted into a plurality of sub-PDF files according to page numbers.

4. The web page preview method of a PDF file according to claim 2, Features: The picture conversion operation includes: The preprocessing script and the pdf-image library are used to convert the plurality of sub-pdf files into images.

5. The web page preview method of a PDF file according to claim 4, Features: The picture conversion operation further includes: Use pdf-image to obtain the file information of the PDF to be processed, traverse the page numbers, and call convertPage of pdf-image to convert each page of the sub-pdf file into a corresponding image file.

6. The web page preview method of a PDF file according to claim 5, Features: The image file corresponding to the sub-pdf file is the PDF file after the image is converted.

7. The web page preview method of a PDF file according to claim 1, Features: The step of loading the PDF converted from the image on demand according to the element display situation includes: In response to obtaining the PDF converted from the image, when an IntersectionObserver is used to monitor that an element appears within the viewport, the PDF converted from the image is loaded accordingly.

8. A web page preview system for PDF files, It is characterized in that include: The preprocessing module is used to: split the PDF to be processed into fine units; A format conversion module, used for: performing image conversion operation on the PDF after the fine unit is split; The lazy loading module is used to load the PDF converted from the image on demand according to the element display situation.

9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for web paging preview of a PDF file according to any one of claims 1 to 7 are implemented.

10. A computer device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; wherein: The memory is used to store computer programs; The processor is used to execute the steps of the web page preview method of a PDF file according to any one of claims 1 to 7 by running the program stored in the memory.