[go: up one dir, main page]

CN120068799A - Online document processing method and device, electronic equipment and medium - Google Patents

Online document processing method and device, electronic equipment and medium Download PDF

Info

Publication number
CN120068799A
CN120068799A CN202510138433.1A CN202510138433A CN120068799A CN 120068799 A CN120068799 A CN 120068799A CN 202510138433 A CN202510138433 A CN 202510138433A CN 120068799 A CN120068799 A CN 120068799A
Authority
CN
China
Prior art keywords
slice
traversed
currently
determining
list
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202510138433.1A
Other languages
Chinese (zh)
Inventor
李佩如
邹学通
刘恒
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202510138433.1A priority Critical patent/CN120068799A/en
Publication of CN120068799A publication Critical patent/CN120068799A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9577Optimising the visualization of content, e.g. distillation of HTML documents

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

本公开提供了一种在线文档处理方法、装置、电子设备、计算机可读存储介质和计算机程序产品,涉及计算机领域,尤其涉及网页文档处理、数据传输、前端应用技术领域。实现方案为:响应于针对文档的预览操作,获取文档中的一个或多个页面各自对应的第一切片列表;依次对第二切片列表中的切片进行遍历以执行第一操作,第二切片列表中包括所有第一切片列表中的按预设预览顺序排列的切片。第一操作包括:根据当前遍历到的切片的位置信息将其绘制在相应画布中;确定当前画布所对应的图片数据以存入该切片的页面所对应的列表中;将列表中最后存入的图片数据渲染到用于预览文档的显示页面中。

The present disclosure provides an online document processing method, device, electronic device, computer-readable storage medium and computer program product, which relate to the computer field, and in particular to the fields of web document processing, data transmission and front-end application technology. The implementation scheme is: in response to a preview operation on a document, a first slice list corresponding to one or more pages in the document is obtained; the slices in the second slice list are traversed in sequence to perform a first operation, and the second slice list includes all slices in the first slice list arranged in a preset preview order. The first operation includes: drawing the slice currently traversed in the corresponding canvas according to its position information; determining the image data corresponding to the current canvas to store it in the list corresponding to the page of the slice; rendering the last stored image data in the list to the display page for previewing the document.

Description

Online document processing method and device, electronic equipment and medium
Technical Field
The present disclosure relates to the field of computers, and in particular, to the technical fields of web document processing, data transmission, and front-end application, and more particularly, to an online document processing method, apparatus, electronic device, computer readable storage medium, and computer program product.
Background
Loading, rendering, and downloading documents (e.g., PDF files) in web pages is a common business requirement. For example, electronic invoices need to be previewed and downloaded after shopping on the e-commerce platform, papers, materials, etc. need to be previewed and downloaded on the educational website. In general, previewing a web document such as a PDF file through a browser may be achieved by introducing a third party tool or converting the document into a picture for loading.
However, the existing methods have certain limitations, which easily cause browser blocking and influence the performance.
Disclosure of Invention
The present disclosure provides an online document processing method, apparatus, electronic device, computer readable storage medium, and computer program product.
According to one aspect of the disclosure, an online document processing method is provided, which comprises the steps of responding to preview operation of a document, obtaining a first slice list corresponding to one or more pages in the document, wherein the first slice list comprises a plurality of slices obtained by conducting picture cutting operation on corresponding pages, sequentially traversing the slices in a second slice list to execute first operation on the currently traversed slices, wherein the second slice list comprises all the slices in the first slice list corresponding to the one or more pages, the slices in the second slice list are arranged according to a preset preview sequence, the first operation comprises determining the pages corresponding to the currently traversed slices as target pages, obtaining the first list corresponding to the target pages and a drawable canvas, determining the corresponding positions of the currently traversed slices in the canvas according to position information of the currently traversed slices in the target pages, storing the currently traversed pictures in the first picture list, storing the corresponding pictures in the first picture list, and rendering the currently traversed data in the first picture list, and finally storing the currently traversed pictures in the first picture list and rendering the first picture list.
According to another aspect of the disclosure, an online document processing device is provided, which comprises an acquisition unit configured to respond to a preview operation for a document, and acquire a first slice list corresponding to one or more pages in the document, wherein the first slice list comprises a plurality of slices obtained by performing a picture cutting operation on corresponding pages, a traversing unit configured to sequentially traverse slices in a second slice list to perform a first operation on a currently traversed slice, wherein the second slice list comprises slices in all first slice lists corresponding to the one or more pages, the slices in the second slice list are arranged in a preset preview sequence, the first operation comprises determining a page corresponding to the currently traversed slice as a target page, acquiring a first list corresponding to the target page and a drawable canvas, traversing the currently traversed slice into the corresponding position of the canvas in the target page according to position information of the currently traversed slice, and storing the currently traversed slice into the first slice list and rendering the currently traversed data into the first page according to the currently traversed slice list, and rendering the currently traversed data into the first page and the currently traversed page.
According to another aspect of the present disclosure, there is provided an electronic device comprising at least one processor, and a memory communicatively coupled to the at least one processor, the memory storing instructions executable by the at least one processor to enable the at least one processor to perform the methods described in the present disclosure.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the method described in the present disclosure.
According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method described in the present disclosure.
According to one or more embodiments of the present disclosure, a document page is cut into a set of slices by a picture cutting technology, which effectively solves the problem of slow loading of large-size pictures in an online preview process of the document, and in addition, in a traversal process of page slices, slices are continuously drawn into corresponding canvases and rendered into display pages, so that users can still display whole pages instead of a certain slice when clicking corresponding page pictures in the preview process, thereby optimizing loading experience.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The accompanying drawings illustrate exemplary embodiments and, together with the description, serve to explain exemplary implementations of the embodiments. The illustrated embodiments are for exemplary purposes only and do not limit the scope of the claims. Throughout the drawings, identical reference numerals designate similar, but not necessarily identical, elements.
FIG. 1 illustrates a schematic diagram of an exemplary system in which various methods described herein may be implemented, in accordance with an embodiment of the present disclosure;
FIG. 2 illustrates a flow chart of an online document processing method according to an embodiment of the present disclosure;
FIG. 3 shows a schematic diagram of cutting a page into a plurality of slices according to an embodiment of the disclosure;
FIGS. 4-7 show display page diagrams implementing document previews according to embodiments of the present disclosure;
FIG. 8 shows a block diagram of an online document processing apparatus according to an embodiment of the present disclosure, and
Fig. 9 illustrates a block diagram of an exemplary electronic device that can be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the present disclosure, the use of the terms "first," "second," and the like to describe various elements is not intended to limit the positional relationship, timing relationship, or importance relationship of the elements, unless otherwise indicated, and such terms are merely used to distinguish one element from another. In some examples, a first element and a second element may refer to the same instance of the element, and in some cases, they may also refer to different instances based on the description of the context.
The terminology used in the description of the various illustrated examples in this disclosure is for the purpose of describing particular examples only and is not intended to be limiting. Unless the context clearly indicates otherwise, the elements may be one or more if the number of the elements is not specifically limited. Furthermore, the term "and/or" as used in this disclosure encompasses any and all possible combinations of the listed items.
Embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
Fig. 1 illustrates a schematic diagram of an exemplary system 100 in which various methods and apparatus described herein may be implemented, in accordance with an embodiment of the present disclosure. Referring to fig. 1, the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. Client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.
In embodiments of the present disclosure, the server 120 may run one or more services or software applications that enable methods of online document processing to be performed.
In some embodiments, server 120 may also provide other services or software applications, which may include non-virtual environments and virtual environments. In some embodiments, these services may be provided as web-based services or cloud services, for example, provided to users of client devices 101, 102, 103, 104, 105, and/or 106 under a software as a service (SaaS) model.
In the configuration shown in fig. 1, server 120 may include one or more components that implement the functions performed by server 120. These components may include software components, hardware components, or a combination thereof that are executable by one or more processors. A user operating client devices 101, 102, 103, 104, 105, and/or 106 may in turn utilize one or more client applications to interact with server 120 to utilize the services provided by these components. It should be appreciated that a variety of different system configurations are possible, which may differ from system 100. Accordingly, FIG. 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.
The user may preview the document using client devices 101, 102, 103, 104, 105, and/or 106. The client device may provide an interface that enables a user of the client device to interact with the client device. The client device may also output information to the user via the interface. Although fig. 1 depicts only six client devices, those skilled in the art will appreciate that the present disclosure may support any number of client devices.
Client devices 101, 102, 103, 104, 105, and/or 106 may include various types of computer devices, such as portable handheld devices, general purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, gaming systems, thin clients, various messaging devices, sensors or other sensing devices, and the like. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, application iOS, UNIX-like operating systems, linux or Linux-like operating systems (e.g., GOOGLE Chrome OS), or include various mobile operating systems, such as MICROSOFT Windows Mobile OS, iOS, windows Phone, android. Portable handheld devices may include cellular telephones, smart phones, tablet computers, personal Digital Assistants (PDAs), and the like. Wearable devices may include head mounted displays (such as smart glasses) and other devices. The gaming system may include various handheld gaming devices, internet-enabled gaming devices, and the like. The client device is capable of executing a variety of different applications, such as various Internet-related applications, communication applications (e.g., email applications), short Message Service (SMS) applications, and may use a variety of communication protocols.
Network 110 may be any type of network known to those skilled in the art that may support data communications using any of a number of available protocols, including but not limited to TCP/IP, SNA, IPX, etc. For example only, the one or more networks 110 may be a Local Area Network (LAN), an ethernet-based network, a token ring, a Wide Area Network (WAN), the internet, a virtual network, a Virtual Private Network (VPN), an intranet, an extranet, a blockchain network, a Public Switched Telephone Network (PSTN), an infrared network, a wireless network (e.g., bluetooth, WIFI), and/or any combination of these and/or other networks.
The server 120 may include one or more general purpose computers, special purpose server computers (e.g., PC (personal computer) servers, UNIX servers, mid-end servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and/or combination. The server 120 may include one or more virtual machines running a virtual operating system, or other computing architecture that involves virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain virtual storage devices of the server). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
The computing units in server 120 may run one or more operating systems including any of the operating systems described above as well as any commercially available server operating systems. Server 120 may also run any of a variety of additional server applications and/or middle tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.
In some implementations, server 120 may include one or more applications to analyze and consolidate data feeds and/or event updates received from users of client devices 101, 102, 103, 104, 105, and 106. Server 120 may also include one or more applications to display data feeds and/or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.
In some implementations, the server 120 may be a server of a distributed system or a server that incorporates a blockchain. The server 120 may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. The cloud server is a host product in a cloud computing service system, so as to solve the defects of large management difficulty and weak service expansibility in the traditional physical host and Virtual special server (VPS PRIVATE SERVER) service.
The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store information such as slice files, source file data for documents, and the like. Database 130 may reside in various locations. For example, the database used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. Database 130 may be of different types. In some embodiments, the database used by server 120 may be, for example, a relational database. One or more of these databases may store, update, and retrieve the databases and data from the databases in response to the commands.
In some embodiments, one or more of databases 130 may also be used by applications to store application data. The databases used by the application may be different types of databases, such as key value stores, object stores, or conventional stores supported by the file system.
The system 100 of fig. 1 may be configured and operated in various ways to enable application of the various methods and apparatus described in accordance with the present disclosure.
In this disclosure, the spatially relative terms "horizontal"/"landscape" and "vertical"/"landscape" are used in connection with displaying pages. In such a context, "horizontal direction"/"lateral direction" refers to the row direction of the display page, and "vertical direction"/"longitudinal direction" refers to the column direction of the display page. In addition, the spatially relative terms "upper", "lower", "left", "right" are also used in connection with displaying pages. "up", "down", "left", "right" indicate the orientation on the image of a document (or equivalently, the displayed page) as viewed from the preview user's perspective when the document (e.g., PDF file) is properly oriented with respect to the preview user for preview reading. Thus, "up-down direction" corresponds substantially to the column direction of the display page, viewport, and "left-right direction" corresponds substantially to the row direction of the display page.
In general, previewing a web document such as a PDF file through a browser may be achieved by introducing a third party tool or converting the document into a picture for loading. For example, pdf.js is a tool pushed by Mozilla that can convert PDF files into HTML5 pages for presentation, one of the most popular PDF loading tools at this stage. In general, the third party tool belongs to a black box scheme, has high limitation that in terms of functions, when unexpected situations such as safety problems and white screens occur, the third party tool is difficult to check and repair, in terms of performance, the third party tool is fixed in volume, and when the situation of loading a cache occurs, the third party tool is difficult to optimize.
At present, a method for converting a document into a picture for loading, converting a PDF file into a picture format for rendering, and combining a picture loading optimization technology mainly comprises three schemes of reducing HTTP request times, compressing the size of the picture and preloading. However, the PDF file converted pictures are generally larger, the whole screen is required to be occupied in certain scenes, the traditional picture loading technology is adopted to have limited optimization space, the picture loading time is in the second level, and the user experience is poor.
Thus, a method according to the present disclosure provides an online document processing method. FIG. 2 illustrates a flowchart of an online document processing method according to an embodiment of the present disclosure, as illustrated in FIG. 2, the method 200 includes, in response to a preview operation for the document, obtaining a first slice list corresponding to each of one or more pages in the document, wherein the first slice list includes a plurality of slices obtained by performing a picture cutting operation on the corresponding pages (step 210), and traversing sequentially slices in a second slice list to perform a first operation on the currently traversed slices, wherein the second slice list includes slices in all first slice lists corresponding to the one or more pages, and the slices in the second slice list are arranged in a preset preview order (step 220).
The first operation comprises the steps of determining a page corresponding to a currently traversed slice to serve as a target page, obtaining a first list corresponding to the target page and a drawable canvas, drawing the currently traversed slice at a corresponding position in the canvas according to position information of the currently traversed slice in the target page, determining picture data corresponding to the currently traversed slice and storing the picture data in the first list, and obtaining picture data which is finally stored in the first list to render the currently traversed slice into a display page for previewing the document based on the picture data.
According to the embodiment of the disclosure, the document page is cut into a group of slices through the picture cutting technology, the problem that a large-size picture is slowly loaded in the online preview process of the document is effectively solved, and in the traversing process of the page slices, the slices are continuously drawn into corresponding canvases and rendered into display pages, so that in the preview process, a user can still display the whole page instead of a certain slice when clicking the corresponding page picture, and loading experience is optimized.
In this disclosure, a document may include any suitable document that may be converted into a picture for loading and previewing, such as a PDF file, a word file, a web page file, and the like, without limitation.
In some embodiments, in the preprocessing stage, the document to be processed may be converted into a picture according to pages, and an original picture list is generated. Then, performing a picture cutting operation on each picture in the original picture list to obtain a group of slice lists, namely a first slice list, corresponding to each picture.
In the present disclosure, the picture cutting operation may be implemented by any suitable method to cut a picture into multiple small pictures (i.e., slices).
In some embodiments, a bottom-up and top-down picture cutting operation method may be included. And, the document pages may be cut according to at least one of the above methods.
In the above embodiment, the bottom-up picture cutting operation method defines the cut slice size, for example 256×256 pixels, so as to cut the picture of the page based on the defined slice size, so as to obtain the slice list corresponding to the page and including the slice with the corresponding size. The method gradually builds the image boundary and the whole image segmentation result from the pixel level, and requires higher calculation and time cost, but can obtain finer segmentation results. The data format of the bottom-up picture cutting operation method can be as follows:
in some examples, for a document including multiple pages, when the pages are cut using a bottom-up method, the multiple pages may be defined to correspond to the same or different slice sizes, which is not limited herein.
In the above embodiment, the top-down picture cutting operation method, that is, the cut level of the picture is defined. In each level of cutting, the picture is cut into four small blocks according to an upper knife, a lower knife and a left knife and a right knife. Then, in the next-level cutting, the four small blocks obtained by cutting the previous layer are respectively used as new pictures to be cut and cut into four small blocks again, so that sixteen slices are obtained, and the like for each level. The method starts from the whole picture, gradually partitions the outlines and boundaries of different pictures downwards, has high partition speed, is easily interfered by factors such as noise and the like, and the partition result may not be as fine as the bottom-up method. The data format of the top-down picture cutting operation method may be as follows:
Therefore, it may be necessary to define which cutting scheme to take, depending on the actual requirements, the minimum slice size or cut level.
In cutting a page of a document into a set of slices by a picture cutting technique, in some examples, it may be further determined how many slices the page of the document needs to be cut into. Specifically, if the bottom-up picture cutting operation method is adopted, the calculation formula is that the number of slices= (original page picture width/slice width) × (original page picture height/slice height). If the top-down picture cutting operation method is adopted, the calculation formula is that the number of slices=4×level.
Thus, by dividing the original page picture into a corresponding number of slices, a two-dimensional array of slices can be output, the data format being as follows:
According to some embodiments, the lateral index of a slice across the whole picture and the longitudinal index of a slice across the whole picture may be used to indicate which slice is in the lateral direction and which slice is in the longitudinal direction, respectively. For example, in an embodiment in which the whole image is cut into 16 slices by the top-down picture cutting operation method, as shown in fig. 3, the slice 301 has a lateral index of 2 and a longitudinal index of 2, that is, (xIndex, yIndex) = (2, 2), so as to represent that the slice 301 is a slice of the second row and the second column after the whole image is cut.
In some embodiments, after the preprocessing operation, the result of the cutting picture is saved for subsequent document previewing. In some examples, multiple slicing methods may be adopted, and slicing results obtained by the multiple slicing methods are stored for adapting to different size screens of the preview device, such as a PC end and a mobile end, so as to achieve the optimal loading effect.
In this disclosure, a "display page" is an interface through which a user can browse information and perform operations. By way of example, the display page may be web page content that appears on the screen when a computer, cell phone, or the like is opened. The page can be a search engine, or can be a news website, social media website, or other website.
In some examples, the user may preview the PDF file through a browser web page in a search engine. Thus, the browser web page may be a display page for previewing a document. Thus, the canvas corresponding to the corresponding page in the PDF file can be rendered into the webpage for user preview.
In this disclosure, viewport refers to the user-viewable portion of a displayed page. In a browser, a viewport is simply the area of the screen where the browser displays the page content, such as the viewable area of a web page displayed in the screen.
In some embodiments, the preview operation for the document may include an action for initiating a preview operation for the document, such as clicking on a file in a web page, clicking on a preset area of a screen, or entering a preset character, etc.
In some embodiments, a first list of clips is obtained for each of one or more pages in the document in response to a preview operation for the document. In response to a preview operation for the document, a request for obtaining data corresponding to the document may be generated to obtain the first clip list based on the request. At this time, it is possible to acquire the corresponding slice list generated by the preprocessing operation described above to improve the data transmission efficiency. In some examples, buffering may be provided by HTTP response header to reduce unnecessary network requests.
In the above-described embodiment, in which the slicing results obtained by the plurality of slicing methods may be stored for adapting to different-sized screens of the preview apparatus, the screen information of the apparatus may be included in the request generated based on the preview operation to obtain the slicing results obtained by the slicing method corresponding to the screen information based on the request.
In the present disclosure, the slices in the second slice list described in step 220 are arranged in a preset preview order, wherein the preset preview order (first preset preview order) may be determined based on the reading order of the document. For example, for a PDF file comprising multiple pages, the preview user typically reads sequentially from the first page (i.e., the top page) to the last page. Also, for any one page, in the case where text or the like therein extends in a substantially right-left direction (i.e., a landscape reading matter) with respect to the preview user, the preview user typically reads from the left side to the right side while reading each line. At this time, the preview sequence determined based on the reading sequence of the document may be to start from the first page of the document and to sequentially read from left to right and from top to bottom starting from the first row and first column of slices (i.e., upper left corner) for slices in the first page. In the example shown in fig. 3, the preview order of the page may be (xIndex, yIndex) = (1, 1) (1, 2) (1, 3) (1, 4) (2, 1) (2, 2) (2, 3) (2, 4) (3, 1) (3, 2) (3, 3) (3, 4) (4, 1) (4, 2) (4, 3) (4, 4). And after the sections in the first page are all previewed, continuing to preview the sections in the second page according to the same sequence. Thus, the preview order of all slices corresponding to all pages to be previewed in the document is determined.
In this disclosure, all first slice lists corresponding to one or more pages of the document may be equivalently considered as one second slice list together, for convenience of subsequent description. Or may be obtained by merging all the first slice lists corresponding to one or more pages of the document. And the slices in the second slice list are arranged according to a preset preview sequence.
In some embodiments, all slices in all first slice lists may be included in the second slice list. All partial slices in the first slice list may be included, such as filtering out partial blank slices, to save subsequent loading and rendering time. Of course, the slices in the first slice list may be slice lists formed by filtering out blank slices, which is not limited herein.
It will be appreciated that for the case where the text lines extend in a substantially vertical direction relative to the reader (i.e., portrait reading), the corresponding preview sequence may also be determined based on the reading sequence based on the above examples.
According to some embodiments, a method according to the present disclosure may further include obtaining first size information of the target page and second size information of the canvas, determining third size information of a slice currently traversed, and determining a scale based on the first size information and the second size information. Drawing the slice at the corresponding position in the canvas according to the position information of the currently traversed slice in the corresponding page comprises drawing the slice at the position corresponding to the canvas according to the third size information, the scaling and the position information of the slice in the corresponding page.
In general, size and location information of the page, canvas, and page content (e.g., slices) need to be considered in processing tasks that draw the page content onto the canvas. Thus, in some examples, first size information for a target page may be obtained, which generally includes a width and a height (e.g., in pixels) of the page. This information may be obtained by parsing the HTML/CSS of the page or using a specific API. Second size information of the canvas is acquired, which also includes the width and height of the canvas. The size of the canvas may be specified by a user or automatically determined based on the resolution of the display device. Scaling is typically calculated based on size information of the page and canvas to ensure that the page content is properly adapted to the canvas size. A ratio of page width to canvas width, or page height to canvas height ratio (depending on which ratio is better suited to maintaining the aspect ratio of the content) may be used. For example, if the page width is 1000 pixels and the canvas width is 500 pixels, the horizontal scaling is 0.5.
For a number of slices into which the page content may be partitioned, each slice has its own size information (width and height). During the traversal, the width and height of the current slice are recorded. The slice is rendered according to the slice size, scale and position information to adjust the size of the slice using the calculated scale. From the position information (e.g., the coordinates of the upper left corner) of the slice in the original page, the drawing position of the slice on the canvas is determined. For example, the slice may be drawn onto the canvas using an appropriate drawing API (e.g., CANVAS API).
In some embodiments, obtaining the first list and the drawable canvas corresponding to the target page includes determining whether there is currently a corresponding first list and canvas for the target page, and if it is determined that the target page does not already have a corresponding first list and canvas, generating an empty first list and drawable canvas corresponding to the target page for use in rendering each slice in the target page into a display page.
In some embodiments, the slices may be combined into one picture by Canvas technology in JavaScript language, rendered in a web page. For example, the first clip list corresponding to each page may be sequentially acquired, so that the first clip list corresponding to each page is used as an input of a Canvas stitching process, and thus the first list and the Canvas corresponding to each page are determined.
Specifically, for example, a slice corresponding to the first page in the second slice list may be traversed first. For example, all slices belonging to the first page may be acquired, set to originList, as input to the Canvas stitching process. Then, for the first page, an empty list resList and a Canvas are created, resList for holding a dynamically rendered list of pictures src. In the Canvas splicing process, a first slice in originList is firstly acquired, a picture object (i.e. an image object) is newly established according to the position information (e.g. URL) of the slice, further, drawing the slice at the corresponding position of the corresponding Canvas based on the position and size information of the slice can be realized through a onload callback function, the Canvas can be converted into picture data through a Canvas. ToDataURL method and stored in resList, the last picture data in resList is acquired, and a < img > tag is created and rendered in a webpage. After traversing all slices belonging to the first page, further acquiring all slices belonging to the second page to be used as new input of Canvas splicing flow. Until all pages have been loaded and rendered.
FIG. 4 shows a schematic view of a display page implementing a document preview in accordance with an embodiment of the present disclosure. As shown in FIG. 4, in a viewport 401 where the page is displayed, the page 402 of the current preview-to-document can be seen. In the previous process, the page 402 is split into 16 sections as shown in fig. 3. Also, the grid in fig. 4 that includes a "# indicates that a slice of the region has currently been rendered into the display page, while the blank grid indicates that a slice of the region has not yet been rendered into the display page. While the rendering operation of all slices in page 402 is not currently implemented, the user may still see a complete picture of the page when the operation of the user to select the page (e.g., clicking on the page area in the screen) is monitored.
According to some embodiments, traversing the slices in the second slice list sequentially comprises determining, for a slice that was last rendered into the display page, whether the slice is currently outside a lower boundary of a viewport of the display page and is a distance from the lower boundary of the viewport that is outside the viewport that is an area outside the viewport, and continuing traversing the slice in the second slice list to perform the first operation in response to determining that the slice is not currently outside the lower boundary of the viewport or that the slice is currently outside the lower boundary of the viewport but is not greater than the first preset value.
According to some embodiments, traversing the slices in the second list of slices sequentially further comprises suspending traversing the slices in the second list of slices in response to determining that the slice is currently outside the lower boundary of the viewport and at a distance from the lower boundary of the viewport that is greater than the first preset value.
5-6 Show display page schematics implementing document previews according to embodiments of the present disclosure. Illustratively, if the user slides down on the basis of FIG. 4 to continue previewing the document, after loading and rendering of the slices in page 402 is completed, the slices in page 403 continue to be loaded and rendered. Currently, it can be seen that the third row of slices 404 has been rendered into the page 403, where the dashed lines represent the slice regions that have been rendered but that are outside the viewport and not yet visible to the user. As shown in fig. 5, the slice 404 may be determined to be outside the lower boundary of the viewport 401 of the display page, i.e., in the region below the viewport. And further, determining whether the distance of the slice 404 from the lower boundary of the viewport 401 is greater than a first preset value, it may be determined whether the distance a1 of the upper boundary of the slice 404 from the lower boundary of the viewport 401 is greater than the first preset value.
With continued reference to fig. 5, if it is determined that the distance a1 of the upper boundary of the slice 404 from the lower boundary of the viewport 401 is greater than the first preset value, traversal of the remaining slices in the second slice list is paused.
Referring to fig. 6, if a downward sliding operation of the user for further previewing of the document is monitored, at which time it is determined that the distance a2 of the upper boundary of the slice 404 from the lower boundary of the viewport 401 is not greater than the first preset value, traversing the remaining slices in the second slice list is continued to perform the first operation. If at this point a sliding operation of the user for further previewing of the document is not monitored, it may be determined that at least the first one of the next row of slices 404 may continue to be loaded.
In some embodiments, the distance of the slice from the lower boundary of the viewport may be determined based on a difference between the distance of the upper boundary of the slice from the upper boundary of the viewport and the distance between the upper and lower boundaries of the viewport. For example, the distance between the upper boundary of the slice that was last rendered into the display page and the upper boundary of the viewport may be obtained by getBoundingClientRect (). Top method, and the distance between the upper and lower boundaries of the viewport (i.e., the screen height) may be obtained by the window. With continued reference to fig. 5, to determine the distance a1 of the upper boundary of the slice 404 from the lower boundary of the viewport 401, the difference between the distance h2 of the upper boundary of the slice from the upper boundary of the viewport and the distance h2 between the upper and lower boundaries of the viewport may be obtained for determination.
In the above embodiment, the first preset value may be a positive value. By the embodiment, the slices corresponding to the current preview position displayed in the viewport can be loaded, preview experience is improved, meanwhile, the situation that excessive loading users possibly need no slices of the preview position can be avoided, and computing resources are saved.
In some examples, the first preset value may be equal to the corresponding slice height. The first preset value is set to be equal to the slice height, so that the next row of slices can be loaded in advance, the situation that a user starts to load and short white screen appears when sliding is avoided, and preview experience is further improved.
According to some embodiments, traversing the slices in the second list of slices sequentially includes suspending traversing the slices in the second list of slices in response to determining that the slice is currently outside the lower boundary of the viewport and is not the last slice in the row of slices in which it is located after rendering to the display page, and continuing traversing the slices in the second list of slices to perform the first operation in response to determining that the slice is currently outside the lower boundary of the viewport and is not the last slice in the row of slices in which it is located after rendering to the display page, and in response to determining that the slice is currently outside the lower boundary of the viewport and is greater than the first preset value.
In the above embodiments, with continued reference to fig. 5 or 6, the determination of whether a slice 404 is outside the lower boundary of the viewport is performed only if that slice is determined to be the last slice in the current row. Thus, each time the above determination operation is performed, a complete row of slices has been loaded.
In the above embodiment, the "last slice" is determined based on a preset preview sequence for traversing the slice. Further, it may be determined whether a slice is the last slice in the current row based on its longitudinal index over the entire map.
During the loop traversal, the slice data needs to be cached. When the PDF file is previewed through the browser web page as described above, all the sliced data is cached in the browser memory, and if the number of slices is large, the memory is full, and the web page collapses. Taking the V8 engine of the Chrome browser as an example, the heap memory constraints are shown in table 1.
System and method for controlling a system Physical memory Maximum heap memory limit
64 Bits >16G 4G
64 Bits <=16G 2G
32 Bits / 1G
TABLE 1
Thus, according to some embodiments, a method according to the present disclosure may further include determining whether memory occupied by all slices in the second slice list that have been rendered into the display page exceeds a preset memory limit, and performing a memory scrubbing operation on one or more slices that have been rendered into the display page based on the preview operation in response to determining that the preset memory limit is exceeded.
To ensure the stability of the web page, it may be determined whether the cached data has exceeded the memory limit when loading a new slice. If so, a memory scrub operation may be performed on one or more slices that have been rendered into the display page based on the preview operation.
In the present disclosure, after a user starts a preview operation for a document, the preview operation may be continuously monitored, for example, corresponding preview position, sliding direction, and other information may be obtained. In some examples, the memory scrub operation may be performed on one or more slices that are furthest from the current preview location. It will be appreciated that one or more slices furthest from the current preview location are the slices that were first traversed and rendered in the preset preview order before the memory clear operation was not performed. Therefore, the influence of memory limitation on user preview can be reduced to the greatest extent.
For example, in the embodiment of implementing slice composition and rendering by Canvas technology in JavaScript language described above, FIFO (first in first out) policy may be adopted to point the earliest created picture object (i.e. image object) to null for dereferencing, and remove the corresponding < img > tag in the web page structure, and clean up the memory occupation of the historical slices by means of garbage collection mechanism of the search engine, so as to achieve better loading experience.
According to some embodiments, determining whether memory occupied by all slices that have been rendered into the display page exceeds a preset memory limit is based on determining a second preset value, wherein the second preset value is a positive integer and a number of slices of the second preset value occupy memory that does not exceed the preset memory limit, and determining that memory occupied by all slices that have been rendered into the display page exceeds the preset memory limit in response to determining that a number of all slices that have been rendered into the display page is greater than the second preset value.
As described above, to prevent memory from being full, it is desirable to determine whether the cached data has exceeded the memory limit when loading a new slice. However, it is generally difficult to detect the memory of the browser in real time, which results in a large computing consumption. Therefore, in the above embodiment, by setting the upper limit of the number of slices that can be buffered, as long as the number of slices rendered is controlled not to exceed the upper limit, the calculation consumption is greatly saved.
According to some embodiments, traversing the slices in the second slice list in turn to execute a first operation on the currently traversed slice comprises responding to the preview operation after executing a memory cleaning operation, determining at least one slice to be traversed in the second slice list and a corresponding traversing sequence based on a sliding direction corresponding to the preview operation, wherein the traversing sequence is matched with the sliding direction, and traversing the at least one slice to be traversed in turn based on the traversing sequence to execute the first operation on the currently traversed slice.
It can be understood that after the memory cleaning operation is performed, the original traversing operation is stopped for the second slice list, and at this time, at least one slice to be traversed and the corresponding traversing sequence thereof are determined in the second slice list based on the sliding direction corresponding to the preview operation again.
In some examples, after a user initiates a preview operation for a document, the preview operation may be continuously monitored to obtain corresponding preview location information and sliding direction information. Based on the sliding direction corresponding to the preview operation, at least one slice to be traversed in the second slice list and a corresponding traversal order may be determined.
For example, if 1 to 200 slices are included in the second slice list, and after rendering to the 50 th slice, the memory footprint of the 1 st slice is cleared by a memory clear operation before rendering the 51 st slice. At this time, if the user sliding downward is detected, it may be determined that the slice to be traversed at this time is 51 th to 200 th slices, and the traversing order thereof matches the current sliding direction, that is, from top to bottom, may be 51, 52..once, 200 (consistent with the original preset preview order). Further, if the traversal continues down to the 120 th slice, since only 50 slices can be saved at maximum, the rendered time is 71-120. At this time, if the user starts to slide upward, by monitoring the preview operation, the corresponding preview position information and slide direction information can be continuously obtained. If the user continues to slide upwards, it may be determined that the slice to be traversed at this time is the 1 st-70 th slice when sliding to the corresponding preview position, and its traversal order matches the current sliding direction, i.e., from bottom to top, may be 70, 69, 68,..1.
Thus, in some embodiments, the traversal order is further determined based on the corresponding preset preview order (second preset preview order). For example, the corresponding preset preview sequence (the second preset preview sequence) may be the original preset preview sequence (i.e., the first preset preview sequence) of the slices in the second slice list. Accordingly, the traversal may be performed in the reverse or same order as the first preset preview order according to the upward sliding or the downward sliding.
In some embodiments, the second pre-set preview sequence may be determined based on a current reading sequence of the document. Reference is made to the above description about the first preset preview sequence, and no further description is given here. For example, the document may be read in a similar order to that described above when sliding down, and may be sequentially read from bottom to top and from top to bottom when sliding up.
According to some embodiments, a method according to the present disclosure may further include determining a current first index for indicating a first slice currently rendered into the display page that is arranged in the preset preview order and a second index for indicating a last slice currently rendered into the display page that is arranged in the preset preview order.
Thus, according to some embodiments, traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on a currently traversed slice may include performing a memory scrub operation on the last slice indicated by the current second index and adjusting the second index to be used to indicate a new last slice in response to determining that the sliding direction is sliding upward, performing the first operation on the currently traversed slice and adjusting the first index to be used to indicate a new first slice.
According to some embodiments, traversing the at least one slice to be traversed in turn based on the traversal order to perform the first operation on the currently traversed slice may include performing a second operation in response to determining that the sliding direction is sliding down, wherein the second operation includes performing a memory scrub operation on the first slice indicated by the current first index and adjusting the first index to indicate a new first slice, and performing the first operation on the currently traversed slice and adjusting the second index to indicate a new last slice.
That is, the slice range that has been currently rendered in the display page may be recorded by setting the first index and the second index.
In some examples, the first index and the second index may be set for elements in the resList list. For example, in response to triggering a memory clean-up operation, the slice ranges in the resList list that are currently being rendered in the display page are recorded with variables startIndex and endIndex, respectively. For example, in response to triggering the memory clear operation, startIndex and endIndex are set and the endIndex initial value is set to the current slice to be rendered and startIndex initial value is set to the endIndex value minus the second preset value.
In the embodiment, by setting the first index and the second index, the subsequent determination of the slice to be traversed based on the user preview operation is facilitated, and the memory cleaning operation is timely realized, so that better loading experience is achieved.
According to some embodiments, traversing the at least one slice to be traversed sequentially based on the traversing order to perform the first operation on the currently traversed slice includes, in response to determining that the sliding direction is sliding downward, determining, for the slice currently indicated by the second index, whether the slice is currently outside a lower boundary of a viewport of the displayed page and a distance of the slice from the lower boundary is greater than a first preset value, wherein the lower boundary outside of the viewport is an area outside of the viewport, and continuing traversing the at least one slice to be traversed in response to determining that the slice is not currently outside of the lower boundary of the viewport or that the slice is currently outside of the lower boundary of the viewport but a distance from the lower boundary of the viewport is not greater than the first preset value.
According to some embodiments, traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on the currently traversed slice includes suspending traversing the at least one slice to be traversed in response to determining that the slice is currently outside the lower boundary of the viewport and at a distance from the lower boundary of the viewport that is greater than the first preset value.
According to some embodiments, traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on the currently traversed slice includes suspending traversing the at least one slice to be traversed in response to determining that the slice is currently outside the lower boundary of the viewport and is a last slice in the slice row in which the slice is determined to be greater than the first preset value, and continuing traversing the at least one slice to be traversed in response to determining that the slice is currently outside the lower boundary of the viewport and is a last slice in the slice row in which the slice is determined to be not.
Here, similar to the above description with reference to fig. 5 to 6, the pre-loading of the slice corresponding to the current preview location is ensured by setting the first preset value, which is not described herein.
In some examples, rendering of the slice to be rendered and memory scrubbing of the slice to be cleaned are implemented based on the set first index (startIndex) and second index (endIndex). When the user is monitored to slide downwards, and the next slice is detected to be rendered, if a 'endIndex +1' slice exists, the < img > tag is recreated and rendered into the display page according to the position information (e.g., URL) of the slice. Synchronization dereferences the current startIndex, updated to startindex++, endIndex ++.
According to some embodiments, traversing the at least one slice to be traversed sequentially based on the traversing order to perform the first operation on the currently traversed slice includes, in response to determining that the sliding direction is sliding upward, determining, for the slice currently indicated by the first index, whether the slice is currently outside an upper boundary of a viewport of the display page and a distance of the slice from the upper boundary is greater than a first preset value, wherein the outside of the upper boundary of the viewport is an area outside of the viewport, and continuing traversing the at least one slice to be traversed in response to determining that the slice is not currently outside of the upper boundary of the viewport or that the slice is currently outside of the upper boundary of the viewport but a distance from the upper boundary of the viewport is not greater than the first preset value.
According to some embodiments, traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on the currently traversed slice includes suspending traversing the at least one slice to be traversed in response to determining that the slice is currently outside the upper boundary of the viewport and at a distance from the upper boundary of the viewport that is greater than the first preset value.
According to some embodiments, traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on the currently traversed slice includes suspending traversing the at least one slice to be traversed in response to determining that the slice is currently outside the upper boundary of the viewport and is a last slice in the slice row in which the slice is determined to be greater than the first preset value and determining that the slice is not a last slice in the slice row in which the slice is located, and continuing traversing the at least one slice to be traversed in response to determining that the slice is currently outside the upper boundary of the viewport and is a distance from the upper boundary of the viewport is greater than the first preset value.
FIG. 7 shows a display page schematic diagram that enables document previews according to an embodiment of the present disclosure. Similar to the description with reference to fig. 5-6, the pre-loading of the slice corresponding to the current preview location viewport is ensured by setting a first preset value during the sliding up as shown in fig. 7. Therefore, the method ensures that slices corresponding to the current preview position displayed in the viewport can be loaded, improves preview experience, and simultaneously can avoid excessive loading of slices which are possibly unnecessary to preview positions by users, thereby saving calculation resources.
In some examples, rendering of the slice to be rendered and memory scrubbing of the slice to be cleaned are implemented based on the set first index (startIndex) and second index (endIndex). When it is detected that the user slides up and it is detected that the previous slice needs to be rendered, if a "startIndex-1" slice exists, the < img > tag is recreated and rendered into the display page according to the position information (e.g., URL) of the slice. Synchronization removes the current endIndex reference and updates to startIndex-endIndex-.
According to some embodiments, the method according to the present disclosure further comprises determining a device type of a device for generating the download request in response to the download request for the document to be processed, and obtaining source data of the document to be processed whose file type matches the device type, wherein the source data is for being downloaded to the device generating the download request.
In some examples, documents are stored as source data in multiple formats for different download scenarios to adapt to download requirements of different devices. For example, for PDF files, the original PDF file is reserved for downloading by the android device, and compressed into Zip compression packets for downloading by the IOS device.
In some examples, when the above method is implemented in JavaScript language, the user equipment type may be identified by a navigator. The data format can be as follows:
if(/iPhone|iPad|iPod/i.test(navigator.userAgent)){//IOS
Else if (/ Android/i.test (navigator user agent)) {// Android)
}
By the embodiment of the disclosure, the problems of slow loading, space limitation and the like in the existing document preview can be effectively solved at will, the downloading requirements of different devices can be adapted, and the user experience of the user during online preview and downloading is improved.
According to an embodiment of the present disclosure, as shown in fig. 8, there is further provided an online document processing apparatus 800, including an obtaining unit 810 configured to obtain, in response to a preview operation for the document, a first slice list corresponding to each of one or more pages in the document, where the first slice list includes a plurality of slices obtained by performing a picture cutting operation on the corresponding page, and a traversing unit 820 configured to sequentially traverse slices in a second slice list to perform a first operation on the currently traversed slices, where the second slice list includes slices in all the first slice lists corresponding to the one or more pages, and the slices in the second slice list are arranged in a preset preview order. The first operation comprises the steps of determining a page corresponding to a currently traversed slice to serve as a target page, obtaining a first list corresponding to the target page and a drawable canvas, drawing the currently traversed slice at a corresponding position in the canvas according to position information of the currently traversed slice in the target page, determining picture data corresponding to the currently traversed slice and storing the picture data in the first list, and obtaining picture data which is stored last in the first list to render the currently traversed slice into a display page for previewing the document based on the picture data.
Here, the operations of the above units 810 to 820 of the online document processing apparatus 800 are similar to the operations of the steps 210 to 220 described above, and are not repeated here.
In the technical scheme of the disclosure, the related processes of collecting, storing, using, processing, transmitting, providing, disclosing and the like of the personal information of the user accord with the regulations of related laws and regulations, and the public order colloquial is not violated.
According to embodiments of the present disclosure, there is also provided an electronic device, a readable storage medium and a computer program product.
Referring to fig. 9, a block diagram of an electronic device 900 that may be a server or a client of the present disclosure, which is an example of a hardware device that may be applied to aspects of the present disclosure, will now be described. Electronic devices are intended to represent various forms of digital electronic computer devices, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 9, the electronic device 900 includes a computing unit 901 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 902 or a computer program loaded from a storage unit 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other by a bus 904. An input/output (I/O) interface 905 is also connected to the bus 904.
A plurality of components in the electronic device 900 are connected to the I/O interface 905, including an input unit 906, an output unit 907, a storage unit 908, and a communication unit 909. The input unit 906 may be any type of device capable of inputting information to the electronic device 900, the input unit 906 may receive input numeric or character information and generate key signal inputs related to user settings and/or function control of the electronic device, and may include, but is not limited to, a mouse, a keyboard, a touch screen, a trackpad, a trackball, a joystick, a microphone, and/or a remote control. The output unit 907 may be any type of device capable of presenting information and may include, but is not limited to, a display, speakers, video/audio output terminals, vibrators, and/or printers. Storage unit 908 may include, but is not limited to, magnetic disks, optical disks. The communication unit 909 allows the electronic device 900 to exchange information/data with other devices through a computer network such as the internet and/or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers and/or chipsets, such as bluetooth devices, 802.11 devices, wiFi devices, wiMax devices, cellular communication devices, and/or the like.
The computing unit 901 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 901 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as method 200. For example, in some embodiments, the method 200 may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 908. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 900 via the ROM 902 and/or the communication unit 909. When the computer program is loaded into RAM903 and executed by computing unit 901, one or more steps of method 200 described above may be performed. Alternatively, in other embodiments, computing unit 901 may be configured to perform method 200 by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include being implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be a special or general purpose programmable processor, operable to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user, for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback), and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a Local Area Network (LAN), a Wide Area Network (WAN), the Internet, and a blockchain network.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
Although embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it is to be understood that the foregoing methods, systems, and apparatus are merely exemplary embodiments or examples, and that the scope of the present invention is not limited by these embodiments or examples but only by the claims following the grant and their equivalents. Various elements of the embodiments or examples may be omitted or replaced with equivalent elements thereof. Furthermore, the steps may be performed in a different order than described in the present disclosure. Further, various elements of the embodiments or examples may be combined in various ways. It is important that as technology evolves, many of the elements described herein may be replaced by equivalent elements that appear after the disclosure.

Claims (21)

1. An online document processing method, comprising:
Responding to preview operation for the document, and acquiring a first slice list corresponding to one or more pages in the document, wherein the first slice list comprises a plurality of slices obtained by performing picture cutting operation on the corresponding pages;
Traversing the slices in the second slice list in sequence to execute a first operation on the currently traversed slices, wherein the second slice list comprises all the slices in the first slice list corresponding to the one or more pages, the slices in the second slice list are arranged according to a preset preview sequence, and the first operation comprises:
determining a page corresponding to the currently traversed slice as a target page;
acquiring a first list and a drawable canvas corresponding to the target page;
Drawing the current traversed slice at a corresponding position in the canvas according to the position information of the current traversed slice in the target page;
Determining the picture data corresponding to the canvas and storing the picture data in the first list, and
And acquiring the last stored picture data in the first list so as to render the currently traversed slice into a display page for previewing the document based on the picture data.
2. The method of claim 1, wherein traversing the slices in the second slice list sequentially comprises:
For a slice which is rendered into the display page last time, determining whether the slice is currently positioned outside the lower boundary of the view port of the display page and whether the distance between the slice and the lower boundary is larger than a first preset value, wherein the outside of the lower boundary of the view port is an area outside the view port;
And in response to determining that the slice is not currently outside the lower boundary of the viewport or that the slice is currently outside the lower boundary of the viewport but is not more than the first preset value, continuing to traverse the slices in the second slice list to perform the first operation.
3. The method of claim 2, wherein traversing the slices in the second slice list in turn further comprises:
in response to determining that the slice is currently outside the lower boundary of the viewport and a distance from the lower boundary of the viewport is greater than the first preset value, traversing the slice in the second list of slices is paused.
4. The method of claim 2, wherein traversing the slices in the second slice list sequentially comprises:
In response to determining that the slice is currently outside the lower boundary of the viewport and a distance from the lower boundary of the viewport is greater than the first preset value, and determining that the slice is the last slice in the slice row in which the slice is located after being rendered to the display page, suspending traversing the slice in the second slice list;
And in response to determining that the slice is currently outside the lower boundary of the viewport and the distance from the lower boundary of the viewport is greater than the first preset value, and determining that the slice is not the last slice in the slice row in which the slice is located after being rendered to the display page, continuing to traverse the slices in the second slice list to perform the first operation.
5. The method of claim 1, further comprising:
determining whether memory occupied by all slices in the second slice list that have been rendered into the display page exceeds a preset memory limit, and
And in response to determining that the preset memory limit is exceeded, performing a memory cleanup operation on one or more slices rendered into the display page based on the preview operation.
6. The method of claim 5, wherein determining whether memory occupied by all slices that have been rendered to the display page exceeds a preset memory limit is based on:
Determining a second preset value, wherein the second preset value is a positive integer, and the number of slices of the second preset value does not occupy more memory than the preset memory limit, and
And in response to determining that the number of all slices that have been rendered into the display page is greater than the second preset value, determining that memory occupied by all slices that have been rendered into the display page exceeds the preset memory limit.
7. The method of claim 5 or 6, wherein traversing the slices in the second slice list in turn to perform the first operation on the currently traversed slice comprises:
After performing memory cleaning operation, responding to the preview operation, and determining at least one slice to be traversed in the second slice list and a corresponding traversing sequence based on a sliding direction corresponding to the preview operation, wherein the traversing sequence is matched with the sliding direction;
traversing the at least one slice to be traversed in turn based on the traversing order to execute the first operation on the currently traversed slice.
8. The method of claim 7, further comprising:
Determining a current first index and a second index, wherein the first index is used for indicating a first slice which is currently rendered into the display page and is arranged according to the preset preview sequence, the second index is used for indicating a last slice which is currently rendered into the display page and is arranged according to the preset preview sequence,
Wherein traversing the at least one slice to be traversed in turn based on the traversal order to perform the first operation on the currently traversed slice includes:
In response to determining that the sliding direction is sliding upwards, performing memory cleaning operation on the last slice indicated by the second index, and adjusting the second index to be used for indicating a new last slice;
And performing the first operation on the currently traversed slice, and adjusting the first index to be used for indicating the new first slice.
9. The method of claim 7, further comprising:
Determining a current first index and a second index in response to determining that the memory scrub operation has been performed, wherein the first index is used for indicating a first slice currently rendered into the display page and arranged in the preset preview sequence, the second index is used for indicating a last slice currently rendered into the display page and arranged in the preset preview sequence,
Wherein traversing the at least one slice to be traversed in turn based on the traversal order to perform the first operation on the currently traversed slice includes:
in response to determining that the sliding direction is sliding downward, performing a second operation, wherein the second operation comprises:
Performing memory cleaning operation on the first slice indicated by the current first index, and adjusting the first index to enable the first index to be used for indicating a new first slice;
the first operation is performed on the currently traversed slice and the second index is adjusted to be used to indicate the new last slice.
10. The method of claim 9, wherein traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on a currently traversed slice comprises:
In response to determining that the sliding direction is downward sliding, for a slice currently indicated by the second index, determining whether the slice is currently outside a lower boundary of a viewport of the display page and a distance from the lower boundary of the slice is greater than a first preset value, wherein the outside of the lower boundary of the viewport is an area outside the viewport;
And continuing traversing the at least one slice to be traversed in response to determining that the slice is not currently outside the lower boundary of the viewport or that the slice is currently outside the lower boundary of the viewport but is not more than the first preset value.
11. The method of claim 10, wherein traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on a currently traversed slice comprises:
And in response to determining that the slice is currently outside the lower boundary of the viewport and the distance from the lower boundary of the viewport is greater than the first preset value, suspending traversing the at least one slice to be traversed.
12. The method of claim 10, wherein traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on a currently traversed slice comprises:
In response to determining that the slice is currently outside the lower boundary of the viewport and a distance from the lower boundary of the viewport is greater than the first preset value, and determining that the slice is the last slice in the slice row in which the slice is located, suspending traversing the at least one slice to be traversed;
And continuing traversing the at least one slice to be traversed in response to determining that the slice is currently outside the lower boundary of the viewport and that the distance from the lower boundary of the viewport is greater than the first preset value and that the slice is not the last slice in the slice row in which the slice is located.
13. The method of claim 8, wherein traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on a currently traversed slice comprises:
responding to the fact that the sliding direction is upward sliding, and for a slice indicated by the first index at present, determining whether the slice is currently located outside the upper boundary of a view port of the display page, wherein the distance between the slice and the upper boundary is larger than a first preset value, and the outside of the upper boundary of the view port is an area outside the view port;
And continuing traversing the at least one slice to be traversed in response to determining that the slice is not currently outside the upper boundary of the viewport or that the slice is currently outside the upper boundary of the viewport but is not more than the first preset value.
14. The method of claim 13, wherein traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on a currently traversed slice comprises:
and in response to determining that the slice is currently outside the upper boundary of the viewport and the distance from the upper boundary of the viewport is greater than the first preset value, suspending traversing the at least one slice to be traversed.
15. The method of claim 13, wherein traversing the at least one slice to be traversed sequentially based on the traversal order to perform the first operation on a currently traversed slice comprises:
in response to determining that the slice is currently outside the upper boundary of the viewport and a distance from the upper boundary of the viewport is greater than the first preset value, and determining that the slice is the last slice in the slice row in which the slice is located, suspending traversing the at least one slice to be traversed;
And continuing traversing the at least one slice to be traversed in response to determining that the slice is currently outside the upper boundary of the viewport and that the distance from the upper boundary of the viewport is greater than the first preset value and that the slice is not the last slice in the slice row in which the slice is located.
16. The method of claim 1, further comprising:
Acquiring first size information of the target page and second size information of the canvas;
determining third size information of the currently traversed slice, and
Determining a scaling based on the first size information and the second size information,
And wherein drawing the slice at the corresponding position in the canvas according to the position information of the currently traversed slice in the corresponding page comprises drawing the slice at the position corresponding to the canvas according to the third size information, the scaling and the position information of the slice in the corresponding page.
17. The method of claim 1, further comprising:
determining a device type of a device for generating the download request in response to the download request for the document, and
And acquiring source data of the document to be processed, the file type of which is matched with the device type, wherein the source data is used for being downloaded to the device generating the downloading request.
18. An online document processing apparatus, comprising:
an obtaining unit configured to obtain a first slice list corresponding to each of one or more pages in the document in response to a preview operation for the document, wherein the first slice list includes a plurality of slices obtained by performing a picture cutting operation on the corresponding pages;
the traversing unit is configured to sequentially traverse the slices in the second slice list so as to execute a first operation on the currently traversed slices, wherein the second slice list comprises all the slices in the first slice list corresponding to the one or more pages, the slices in the second slice list are arranged according to a preset preview sequence, and the first operation comprises:
determining a page corresponding to the currently traversed slice as a target page;
acquiring a first list and a drawable canvas corresponding to the target page;
Drawing the current traversed slice at a corresponding position in the canvas according to the position information of the current traversed slice in the target page;
Determining the picture data corresponding to the canvas and storing the picture data in the first list, and
And acquiring the last stored picture data in the first list so as to render the currently traversed slice into a display page for previewing the document based on the picture data.
19. An electronic device, comprising:
at least one processor, and
A memory communicatively coupled to the at least one processor, wherein
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-17.
20. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-17.
21. A computer program product comprising a computer program, wherein the computer program, when executed by a processor, implements the method of any of claims 1-17.
CN202510138433.1A 2025-02-07 2025-02-07 Online document processing method and device, electronic equipment and medium Pending CN120068799A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202510138433.1A CN120068799A (en) 2025-02-07 2025-02-07 Online document processing method and device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202510138433.1A CN120068799A (en) 2025-02-07 2025-02-07 Online document processing method and device, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN120068799A true CN120068799A (en) 2025-05-30

Family

ID=95803480

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202510138433.1A Pending CN120068799A (en) 2025-02-07 2025-02-07 Online document processing method and device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN120068799A (en)

Similar Documents

Publication Publication Date Title
US8446411B2 (en) Adaptive image rendering and use of imposter
US20180101295A1 (en) System for displaying elements of a scrollable list
US10423527B2 (en) Memory management and image display for mobile devices
CN110032701B (en) Image display control method and device, storage medium and electronic equipment
CN112926000B (en) Display area rendering method, device, equipment, readable storage medium and product
CN111832271B (en) Data presentation method, device, electronic equipment and storage medium
US20170205980A1 (en) Method and an apparatus for providing a multitasking view
CN113626113A (en) Page rendering method and device
CN113780297A (en) Image processing method, device, equipment and storage medium
JP2021152901A (en) Method and apparatus for creating image
CN114004840A (en) Image processing method, training method, detection method, device, equipment and medium
WO2018184436A1 (en) Method and device for displaying image
US9501812B2 (en) Map performance by dynamically reducing map detail
WO2023226371A1 (en) Target object interactive reproduction control method and apparatus, device and storage medium
US9612734B1 (en) Random access browser scrolling for large pages
CN111767490B (en) Method, device, equipment and storage medium for displaying images
CN112445394B (en) Screenshot method and screenshot device
CN110727383B (en) Touch interaction method, device, electronic device and storage medium based on applet
CN112218003B (en) Desktop image acquisition method and device and electronic equipment
CN109739403B (en) Method and apparatus for processing information
US10963690B2 (en) Method for identifying main picture in web page
CN113810755A (en) Panoramic video preview method and device, electronic equipment and storage medium
CN120068799A (en) Online document processing method and device, electronic equipment and medium
CN112053280B (en) Method, device, equipment and storage medium for displaying panoramic maps
CN115712788A (en) Page display method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination