PDF visualization method and system based on incremental rendering
Through incremental rendering technology, visual and non-visual pages of rendering PDF documents are separated and rendered, and the rendering results are cached, which solves the problems of long rendering time, large resource usage and poor user experience in the existing technology, and improves rendering efficiency and quality.
Patent Information
- Application Number
- CN202411041354.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-12-03
AI Technical Summary
The existing PDF document rendering methods take a long time and take up a large resource, resulting in poor user experience, and there may be problems such as page layout errors and missing content when rendering once.
Using an incremental rendering method, the structure information and page content are obtained by parsing PDF documents, the index range of the visual page is determined, the visual page is rendered separately by the page, and the non-visual page is rendered through incremental shard rendering method, and the cache is Render results, avoid repeated rendering.
It effectively improves rendering speed, reduces device resource usage, improves user experience, reduces page lag and content missing problems, and ensures rendering quality.
Smart Images

Figure CN119067069A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of file processing, and in particular to a PDF visualization method and system based on incremental rendering. Background Art
[0002] With the rapid development of information technology, PDF documents have become one of the main formats for electronic document transmission and storage. PDF readers will parse each page object, extract the text, graphics, pictures and other elements in the page, and render them according to the font, size, color and other attributes. However, after the PDF document is parsed, some pages are often visible and some are not. The current visualization method of PDF documents usually requires rendering the entire page, which has the following defects: 1. For large PDF documents, rendering the entire page takes a long time and occupies a large amount of device resources, resulting in freezes or unsmooth page display when users browse PDF documents; Second, PDF files usually contain a large number of pages and complex layouts. Rendering the entire PDF page at once may result in page layout errors, missing fonts, or some content cannot be displayed correctly, affecting the readability of the document. 3. When rendering the entire page of a PDF document, if the user performs interactive operations such as zooming or scrolling, the entire page needs to be re-rendered, resulting in slow rendering speed, delayed response, and poor user experience.
[0003] Therefore, we need to develop a PDF visualization method and system based on incremental rendering, which can render the visible pages and non-visual pages of PDF documents separately without rendering the entire PDF page at one time; at the same time, cache and reuse the rendered pages to improve the rendering speed of PDF documents. Summary of the invention
[0004] The purpose of the present invention is to provide a PDF visualization method and system based on incremental rendering, so as to solve the problems mentioned in the above background technology that the existing rendering method is time-consuming, occupies a large amount of resources and has a poor user experience.
[0005] To achieve the above object, the present invention adopts the following technical solutions: According to one aspect of the present invention, a PDF visualization method based on incremental rendering is provided, and the specific steps of the method are as follows: Parse the PDF document to obtain the structure information and page content of the PDF document; Determining an index range of visible pages in the PDF document according to the structure information and page content of the PDF document; Rendering the visible pages within the index range individually page by page, generating a first rendered image and caching it; Rendering non-visual pages outside the index range by using an incremental tile rendering method, and caching the rendered images; The PDF document is traversed and the rendering step is repeated until all pages of the PDF document are rendered.
[0006] According to another aspect of the present invention, there is provided a PDF visualization system based on incremental rendering, the system comprising: a document parsing module, a range determination module, a separate rendering module, an incremental rendering module and a traversal loop module. The document parsing module is used to parse the PDF document and obtain the structure information and page content of the PDF document; The range determination module is used to determine the index range of visible pages in the PDF document according to the structure information and page content of the PDF document; The above-mentioned separate rendering module is used to render the visible pages within the index range separately page by page, generate a first rendering image and cache it; The incremental rendering module is used to render the non-visual pages outside the index range by using the incremental fragmentation rendering method, and cache the rendered images; The traversal loop module is used to traverse the PDF document and repeat the rendering step until all pages of the PDF document are rendered.
[0007] Based on the above solution, the structural information of the PDF document includes: the total number of pages of the PDF document, the size of each page of the PDF document, and the attributes of each page in the PDF document. The determining of the index range of visible pages in the PDF document specifically includes: Traversing the PDF document to check whether there are hidden pages, blank pages, and pages with more than 50% of page content missing in the PDF document; Eliminate the hidden pages, blank pages, and pages with more than 50% missing page content to obtain the page position of the visible window; The page position at the top of the visible window is used as a starting index, and the page position at the bottom of the visible window is used as an ending index to obtain an index range of visible pages in the PDF document; wherein, there are continuous visible pages between the top of the visible window and the bottom of the visible window.
[0008] Based on the above solution, the visible pages within the index range are rendered separately page by page, specifically including the steps of: Obtaining a page range rectangle for displaying the visible page according to the current window size; Calling the PDF underlying rendering interface to render the page range rectangle, generating a first rendering image and sending it to the cache system for caching; Determine whether the page range rectangle is equal to the visible page rectangle corresponding to the current page index; If not equal, rendering the visible page corresponding to the current page index outside the current window by using the incremental fragmentation rendering method until the rendering of the visible page corresponding to the current page index is completed; If they are equal, the rendering of the visible page corresponding to the current page index is completed.
[0009] Based on the above solution, before the cache system caches the first rendered image, the cache system further includes: associating the first rendered image with the page range rectangle, the current page index, and the zoom value of the current interface.
[0010] Based on the above solution, before rendering the non-visual pages outside the index range by the incremental fragmentation rendering method, the method further includes: Offsetting the current window to the non-visible page, and aligning the center point of the current window with the center point of the non-visible page to obtain an overlapping rectangle of the current window and the non-visible page; The overlapping rectangle is used as the first page range rectangle of the non-visual page, and the PDF underlying rendering interface is called to render the first page range rectangle, generate a second rendering image and send it to the cache system for caching.
[0011] Further, rendering the non-visual pages outside the index range by using an incremental fragmentation rendering method specifically includes: Obtain a second rendered image and use it as an outward expansion basic rectangle, and perform outward expansion on the top of the outward expansion basic rectangle to obtain a first incremental rectangle; Calling the PDF underlying rendering interface to render the first incremental rectangle to generate a first incremental rendering image; splicing the first incremental rendering image with the outward-expanding basic rectangle to obtain a second page range rectangle and sending it to the cache system for caching; Taking the second page range rectangle as a new outward expansion basic rectangle, and performing outward expansion on the right side of the new outward expansion basic rectangle to obtain a second incremental rectangle; Calling the PDF underlying rendering interface to render the second incremental rectangle to generate a second incremental rendering picture; splicing the second incremental rendering image with the new outward-expanding basic rectangle to obtain a third page range rectangle and sending it to the cache system for caching; The steps of expanding, rendering, and generating a new expanding basic rectangle are repeated in the order of expanding in a clockwise direction until all the non-visual pages are rendered.
[0012] Among them, the clockwise expansion refers to expansion at the top, right, bottom and left of the expansion basic rectangle respectively, and when expanding, if the expansion direction is the top or bottom, the width of the incremental rectangle is set to be consistent with the width of the corresponding expansion basic rectangle, and the height is 1 / 2 of the height of the corresponding expansion basic rectangle; if the expansion direction is the right or left, the width of the incremental rectangle is set to be 1 / 2 of the width of the corresponding expansion rectangle, and the height is consistent with the height of the corresponding expansion rectangle. Furthermore, the incremental rectangle needs to be within the current page range of the PDF document; if the height or width of the incremental rectangle set exceeds the current page range of the PDF document during expansion, the current page boundary of the PDF document is used as the upper limit of the height or width of the incremental rectangle.
[0013] Based on the above solution, when the incremental rendering image is generated and stitched with the corresponding outward expansion basic rectangle, the stitching is performed in the direction of the outward expansion.
[0014] It can be seen from the above technical solution that compared with the prior art, the present invention has at least the following advantages and positive effects: (1) The present invention can effectively alleviate the problem of large device resource occupation when rendering the entire page by determining the visible page range after parsing the PDF document and rendering the visible page and the non-visible page separately, thereby improving the rendering speed.
[0015] (2) The present invention caches and reuses pages that have been rendered, thereby reducing repeated rendering of the same page. While improving rendering efficiency, it also enables users to perform interactive operations such as zooming or scrolling more smoothly, thereby improving user experience.
[0016] (3) The present invention gradually renders non-visual pages through an incremental tile rendering method, which ensures that all pages of the PDF document are rendered while reducing the occupation of device resources. It can not only effectively solve the problem of partial content missing when rendering the entire page, but also reduce page freezes and improve rendering quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description only involve some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1A flowchart of a PDF visualization method based on incremental rendering provided by an embodiment of the present invention is shown; Figure 2 A flow chart of a method for rendering visible pages individually according to an embodiment of the present invention is shown; Figure 3 A flow chart of a method for performing incremental tile rendering on a non-visual page provided by an embodiment of the present invention is shown; Figure 4 A schematic diagram of clockwise transformation of an outward-expanding basic rectangle provided by an embodiment of the present invention is shown; Figure 5 A schematic diagram of the structure of a PDF visualization system based on incremental rendering provided by an embodiment of the present invention is shown; in, Figure 5 The reference numerals in the figures are described as follows: 500 - a PDF visualization system based on incremental rendering; 501 - document parsing module, 502 - range determination module, 503 - separate rendering module, 504 - incremental rendering module, 505 - traversal loop module. DETAILED DESCRIPTION
[0019] In order to more clearly explain the purpose, technical solutions and advantages of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. The example implementation methods can be implemented in various forms and should not be understood as being limited to the examples described herein. On the contrary, these implementation methods are provided to make the present invention more comprehensive and complete, and to fully convey the concepts of the example implementation methods to those skilled in the art.
[0020] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solution of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.
[0021] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0022] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0023] The present invention is described in detail below with reference to specific embodiments.
[0024] Example 1
[0025] like Figure 1 As shown, an embodiment of the present invention provides a PDF visualization method based on incremental rendering, and the specific steps of the method are as follows: S1: Parse the PDF document to obtain the structure information and page content of the PDF document; Preferably, the structural information of the PDF document includes: the total number of pages of the PDF document, the size of each page of the PDF document, and the attributes of each page in the PDF document. In this embodiment, the PDF underlying library is first called to parse the PDF document to obtain the structural information and page content of the PDF document; wherein the PDF underlying library is determined by actual needs and programming language, and its type includes but is not limited to iText, PDFBox, PyPDF2 or pdfminer.six.
[0026] S2: Determine the index range of visible pages in the PDF document according to the structure information and page content of the PDF document; Further, determining the index range of visible pages in the PDF document according to the structure information and page content of the PDF document acquired in step S1 specifically includes the following steps: Traversing the PDF document to check whether there are hidden pages, blank pages, and pages with more than 50% of page content missing in the PDF document; Eliminate the hidden pages, blank pages, and pages with more than 50% missing page content to obtain the page position of the visible window; The page position at the top of the visible window is used as a starting index, and the page position at the bottom of the visible window is used as an ending index to obtain an index range of visible pages in the PDF document; wherein, there are continuous visible pages between the top of the visible window and the bottom of the visible window.
[0027] S3: Rendering the visible pages within the index range individually page by page, generating a first rendered image and caching it; Furthermore, the visible pages within the index range are rendered individually page by page, such as Figure 2As shown, the specific steps include: S201: Obtaining a page range rectangle for displaying the visible page according to the current window size; S202: Calling the PDF underlying rendering interface to render the page range rectangle, generating a first rendered image and sending it to the cache system for caching; S203: Determine whether the page range rectangle is equal to the visible page rectangle corresponding to the current page index; S204: If not equal, rendering the visible page corresponding to the current page index outside the current window by using an incremental tile rendering method until the rendering of the visible page corresponding to the current page index is completed; S205: If they are equal, the rendering of the visible page corresponding to the current page index is completed.
[0028] Preferably, in this embodiment, before the cache system caches the first rendered image, it also includes: the cache system associates the first rendered image with the page range rectangle, the current page index and the zoom value of the current interface; so that when the page range rectangle of the same position is subsequently obtained, the rendered area can be identified in a timely and accurate manner, and the cached first rendered image can be called for reuse, without repeated rendering, thereby improving the rendering speed.
[0029] Furthermore, the determining whether the page range rectangle is equal to the visible page rectangle corresponding to the current page index is achieved by informing the interface control to display the first rendered image cached in the cache system in a callback manner.
[0030] In this embodiment, if the page range rectangle is not equal to the visible page rectangle corresponding to the current page index, the visible page corresponding to the current page index outside the current window is regarded as a non-visible page outside the index range, and is rendered using the incremental tile rendering method until all the visible pages corresponding to the current page index are rendered.
[0031] Further, the page is scrolled until the current window falls on the visible page corresponding to the next page index, and the steps of rendering the pages individually (ie, steps S201 to S205) are repeated until all visible pages within the index range are rendered.
[0032] S4: Rendering the non-visual pages outside the index range by using an incremental fragmentation rendering method, and caching the rendered images; Further, when the visible page within the index range is rendered, the current window is offset to the non-visible page, and the center point of the current window is aligned with the center point of the non-visible page to obtain an overlapping rectangle of the current window and the non-visible page; The overlapping rectangle is used as the first page range rectangle of the non-visual page, and the PDF underlying rendering interface is called to render the first page range rectangle, generate a second rendering image and send it to the cache system for caching.
[0033] Furthermore, if Figure 3 As shown, the non-visual pages outside the index range are rendered by an incremental fragmentation rendering method, specifically including: S301: Acquire a second rendered image and use it as an outward expansion basic rectangle, and perform outward expansion on the top of the outward expansion basic rectangle to obtain a first incremental rectangle; S302: Calling the PDF underlying rendering interface to render the first incremental rectangle to generate a first incremental rendering image; S303: splicing the first incremental rendering image with the outward-expanding basic rectangle to obtain a second page range rectangle and sending it to the cache system for caching; S304: taking the second page range rectangle as a new outward expansion basic rectangle, and performing outward expansion on the right side of the new outward expansion basic rectangle to obtain a second incremental rectangle; S305: Calling the PDF underlying rendering interface to render the second incremental rectangle to generate a second incremental rendering image; S306: splicing the second incremental rendering image with the new outward-expanding basic rectangle to obtain a third page range rectangle and sending it to the cache system for caching; S307: Repeat the steps of expanding, rendering, and generating a new expanding basic rectangle in the order of expanding in a clockwise direction until all the non-visual pages are rendered.
[0034] Specifically, in this embodiment, the clockwise expansion refers to expansion at the top, right, bottom and left of the expansion basic rectangle respectively, and when expanding, if the expansion direction is the top or bottom, the width of the incremental rectangle is set to be consistent with the width of the corresponding expansion basic rectangle, and the height is 1 / 2 of the height of the corresponding expansion basic rectangle; if the expansion direction is the right or left, the width of the incremental rectangle is set to be 1 / 2 of the width of the corresponding expansion rectangle, and the height is consistent with the height of the corresponding expansion rectangle. Among them, the transformation of the expansion basic rectangle and the incremental rectangle during the expansion process is as follows: Figure 4 As shown; among them, Figure 4 a is a schematic diagram of the expansion base rectangle and the incremental rectangle in the page range when expanding for the first time (i.e. expanding at the top); Figure 4 b is a schematic diagram of the expansion basic rectangle and the incremental rectangle in the page range during the second expansion (i.e., expansion on the right); Figure 4 c is a schematic diagram of the expansion base rectangle and the incremental rectangle in the page range during the third expansion (i.e., expansion at the bottom); Figure 4D is a schematic diagram of the expansion base rectangle and the incremental rectangle in the page range during the fourth expansion (i.e., expansion on the left). Repeat the steps of expanding and rendering on the top, right, bottom, and left until all non-visible pages are rendered.
[0035] Furthermore, in this embodiment, the incremental rectangle needs to be within the current page range of the PDF document; if the height or width of the incremental rectangle is set to exceed the current page range of the PDF document when expanding outward, the current page boundary of the PDF document is used as the upper limit of the height or width of the incremental rectangle.
[0036] S5: traversing the PDF document and repeating the rendering step until all pages of the PDF document are rendered.
[0037] Furthermore, the PDF document is traversed to check whether all pages of the PDF document have been rendered; if all pages have been rendered, the rendering task is completed; if there are pages that have not been rendered or are incompletely rendered, the rendering steps (i.e., steps S3 and S4) are repeated, and the visible pages and non-visual pages are rendered using corresponding rendering methods.
[0038] The PDF visualization method based on incremental rendering described in the embodiment of the present invention divides the parsed PDF document into visible pages and non-visual pages, and first renders the visible pages page by page in the rendering order, and then uses the incremental slicing method to render the non-visual pages. There is no need to render the entire PDF document at one time, which greatly reduces the content of each rendering, and can not only avoid a large amount of device resources being occupied, but also improve the rendering quality; at the same time, the rendered images are cached and reused, which reduces the situation of repeated rendering, is conducive to improving the rendering speed, and has high practicality.
[0039] Example 2
[0040] like Figure 5 As shown, an embodiment of the present invention provides a PDF visualization system 500 based on incremental rendering, the system comprising: a document parsing module 501, a range determination module 502, a separate rendering module 503, an incremental rendering module 504 and a traversal loop module 505. Among them: The document parsing module 501 is used to parse the PDF document and obtain the structure information and page content of the PDF document; In this embodiment, the document parsing module 501 parses the PDF document by calling the PDF underlying library. The structural information of the PDF document includes: the total number of pages of the PDF document, the size of each page of the PDF document, and the attributes of each page in the PDF document.
[0041] A range determination module 502, configured to determine an index range of visible pages in the PDF document according to the structure information and page content of the PDF document; Preferably, the index range of the visible pages in the PDF document is determined by searching the page position of the visible window, and taking the page position at the top of the visible window as the starting index and the page position at the bottom of the visible window as the ending index.
[0042] In this embodiment, after the document parsing module 501 obtains the structural information and page content of the PDF document, the range determination module 502 starts to traverse the PDF document, checks and removes hidden pages, blank pages, and pages with more than 50% missing page content in the PDF document, thereby obtaining the page position of the visible window.
[0043] A separate rendering module 503, used to render the visible pages within the index range separately page by page, generate a first rendering image and cache it; Further, after determining the index range of the visible pages in the PDF document, the separate rendering module 503 starts to render the visible pages within the index range page by page. First, starting from the top of the visible window, the page range rectangle for displaying the first visible page is obtained according to the current window size; the PDF underlying rendering interface is called to render the page range rectangle, generate a first rendering image and send it to the cache system; the cache system associates the first rendering image with the page range rectangle, the current page index and the zoom value of the current interface and caches it; further, through a callback method, the interface control is notified to display the first rendering image, and it is determined whether the page range rectangle is equal to the visible page rectangle corresponding to the current page index; if it is equal, the rendering of the visible page corresponding to the current page index is completed; if it is not equal, the visible page corresponding to the current page index outside the current window is rendered by the incremental tile rendering method until all the visible pages corresponding to the current page index are rendered. Furthermore, the page is scrolled to place the current window on the visible page corresponding to the next page index, and the rendering of the next visible page is started; the step of rendering each page individually is repeated until all visible pages within the index range are rendered.
[0044] An incremental rendering module 504 is used to render non-visual pages outside the index range by using an incremental tile rendering method, and cache the rendered images; Further, after the visible page is rendered, the incremental rendering module 504 starts to render the non-visual page. First, the current window is offset to the non-visual page, and the center point of the current window is aligned with the center point of the non-visual page to obtain the overlapping rectangle of the current window and the non-visual page; the overlapping rectangle is used as the first page range rectangle of the non-visual page, and the PDF underlying rendering interface is called to render the first page range rectangle, generate a second rendering image and send it to the cache system for caching. Further, the second rendering image is used as the outward expansion basic rectangle, and outward expansion is performed on the top of the outward expansion basic rectangle to obtain a first incremental rectangle; the PDF underlying rendering interface is called to render the first incremental rectangle to generate a first incremental rendering image; the first incremental rendering image is spliced with the outward expansion basic rectangle to obtain a second page range rectangle and send it to the cache system for caching; further, the second page range rectangle is used as a new outward expansion basic rectangle, and the steps of outward expansion, rendering and generating a new outward expansion basic rectangle are repeated in the order of clockwise expansion from the top, right, bottom and left until all the non-visual pages are rendered.
[0045] The traversal loop module 505 is used to traverse the PDF document and repeat the rendering steps until all pages of the PDF document are rendered.
[0046] Furthermore, the traversal loop module 505 traverses the PDF document to check whether all pages of the PDF document have been rendered; if all pages have been rendered, the rendering task is completed; if there are pages that have not been rendered or are incompletely rendered, it is determined whether they are visible pages or non-visible pages, and the separate rendering module 503 or the incremental rendering module 504 is notified to render the relevant pages until all pages of the PDF document are rendered.
[0047] In this embodiment, the visible pages and non-visible pages of the PDF document are rendered separately through a separate rendering module 503 and an incremental rendering module 504, thereby avoiding the problems of large resource usage, page freezes, and some details not being able to be displayed normally when rendering the entire page, and ensuring the rendering quality; at the same time, the rendered images are cached, so that when the page range rectangle at the same position is subsequently obtained, the rendered areas can be identified in a timely and accurate manner, and the cached rendering images can be called for reuse without repeated rendering, thereby effectively improving the rendering speed.
[0048] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present invention, which follows the general principles of the present invention and includes common knowledge or customary techniques in the art that are not disclosed by the present invention. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present invention are indicated by the claims. It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A PDF visualization method based on incremental rendering, characterized in that: The steps include: Parse the PDF document to obtain the structure information and page content of the PDF document; Determining an index range of visible pages in the PDF document according to the structure information and page content of the PDF document; Rendering the visible pages within the index range individually page by page, generating a first rendered image and caching it; Rendering non-visual pages outside the index range by using an incremental tile rendering method, and caching the rendered images; The PDF document is traversed and the rendering step is repeated until all pages of the PDF document are rendered.
2. The PDF visualization method according to claim 1, characterized in that: The page-by-page rendering specifically includes: Obtaining a page range rectangle for displaying the visible page according to the current window size; Calling the PDF underlying rendering interface to render the page range rectangle, generating a first rendering image and sending it to the cache system for caching; Determine whether the page range rectangle is equal to the visible page rectangle corresponding to the current page index; If not equal, rendering the visible page corresponding to the current page index outside the current window by the incremental tile rendering method until the rendering of the visible page corresponding to the current page index is completed; If they are equal, the rendering of the visible page corresponding to the current page index is completed.
3. The PDF visualization method according to claim 2, characterized in that: Before the cache system caches the first rendered image, the cache system further includes associating the first rendered image with the page range rectangle, the current page index, and the zoom value of the current interface.
4. The PDF visualization method according to claim 1, characterized in that: Before rendering the non-visual pages outside the index range by the incremental fragmentation rendering method, the method further includes: Offsetting the current window to the non-visual page, and aligning the center point of the current window with the center point of the non-visual page to obtain an overlapping rectangle of the current window and the non-visual page; The overlapping rectangle is used as the first page range rectangle of the non-visual page, and the PDF underlying rendering interface is called to render the first page range rectangle, generate a second rendering image and send it to the cache system for caching.
5. The PDF visualization method according to claim 1, characterized in that: The rendering of the non-visual pages outside the index range by the incremental fragmentation rendering method specifically includes: Obtain a second rendered image and use it as an outward expansion basic rectangle, and perform outward expansion on the top of the outward expansion basic rectangle to obtain a first incremental rectangle; Calling the PDF underlying rendering interface to render the first incremental rectangle to generate a first incremental rendering image; splicing the first incremental rendering image with the outward-expanding basic rectangle to obtain a second page range rectangle and sending it to the cache system for caching; Taking the second page range rectangle as a new outward expansion basic rectangle, and performing outward expansion on the right side of the new outward expansion basic rectangle to obtain a second incremental rectangle; Calling the PDF underlying rendering interface to render the second incremental rectangle to generate a second incremental rendering picture; splicing the second incremental rendering image with the new outward-expanding basic rectangle to obtain a third page range rectangle and sending it to the cache system for caching; The steps of expanding, rendering, and generating a new expanding basic rectangle are repeated in the order of expanding in a clockwise direction until all the non-visual pages are rendered.
6. The PDF visualization method according to claim 5, characterized in that: When expanding, if the expansion direction is the top or bottom, the width of the incremental rectangle is set to be consistent with the width of the corresponding expansion basic rectangle, and the height is 1 / 2 of the height of the corresponding expansion basic rectangle; if the expansion direction is the right or left side, the width of the incremental rectangle is set to be 1 / 2 of the width of the corresponding expansion rectangle, and the height is consistent with the height of the corresponding expansion rectangle.
7. The PDF visualization method according to claim 5 or 6, characterized in that: When expanding outward, it also includes: the incremental rectangle needs to be within the current page range of the PDF document; if the height or width of the set incremental rectangle exceeds the current page range of the PDF document during expansion, the current page boundary of the PDF document is used as the upper limit of the height or width of the incremental rectangle.
8. The PDF visualization method according to claim 1, characterized in that: The structural information of the PDF document includes: the total number of pages of the PDF document, the size of each page of the PDF document, and the attributes of each page in the PDF document.
9. The PDF visualization method according to claim 1, characterized in that: Determining the index range of visible pages in the PDF document specifically includes: Traversing the PDF document to check whether there are hidden pages, blank pages, and pages with more than 50% of page content missing in the PDF document; Eliminate the hidden pages, blank pages, and pages with more than 50% missing page content to obtain the page position of the visible window; The page position at the top of the visible window is used as a starting index, and the page position at the bottom of the visible window is used as an ending index to obtain an index range of visible pages in the PDF document; wherein, there are continuous visible pages between the top of the visible window and the bottom of the visible window.
10. A PDF visualization system based on incremental rendering, characterized in that: include: A document parsing module, used to parse a PDF document and obtain the structure information and page content of the PDF document; A range determination module, used to determine the index range of visible pages in the PDF document according to the structure information and page content of the PDF document; A separate rendering module, used to render the visible pages within the index range separately page by page, generate a first rendering image and cache it; An incremental rendering module, used to render non-visual pages outside the index range by using an incremental fragmentation rendering method, and cache the rendered images; The traversal loop module is used to traverse the PDF document and repeat the rendering steps until all pages of the PDF document are rendered.
Citation Information
Cited By
Streaming on-demand loading WEB end PDF document preview method and processing terminal
CN120524055A
