A document display method, device, equipment and storage medium

By creating a canvas using a dynamic library and loading hidden tags, the problem of lost fonts and layout in document display was solved, the original document was restored and its functions were expanded, and the user experience was improved.

CN115329720BActive Publication Date: 2026-02-10BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211134319.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-16
Publication Date
2026-02-10
Estimated Expiration
2042-09-16

AI Technical Summary

Technical Problem

Existing technologies cannot reproduce the true appearance of a document in document display, resulting in the loss of fonts and layout, and a poor user experience.

Method used

A canvas is created using a dynamic library, the font is loaded from the document's font information by calling a hidden tag, and the document is rendered according to the font information to ensure consistency between font and layout.

Benefits of technology

It restores the original appearance of the document display, improves the user experience, and supports document function expansion, such as pen marking and quick export, and prevents document content copying.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115329720B_ABST
    Figure CN115329720B_ABST
Patent Text Reader

Abstract

The present disclosure provides a document display method and device, equipment and storage medium, relates to the field of data processing, in particular to the field of text processing. The specific implementation scheme is: in response to a display request of a document, a canvas for displaying the document is created through a dynamic library; target data corresponding to the document is obtained, the target data including font information of the document; when it is determined that the font in the font information does not exist in a font library, a hidden label corresponding to the font information is created by calling the dynamic library; the font in the font information is used by calling the label, so that the font in the font information is loaded to the font library; and the document is rendered to the canvas according to the font in the font information. Through the implementation of the present disclosure, when the document is displayed to the user, the original document layout can be retained, and the font is also consistent, so that the overall appearance of the original document can be restored.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data processing technology, and more particularly to the field of text processing technology. Background Technology

[0002] The document library contains hundreds of millions of documents, including various types such as Word, Excel, PDF, and PPT. For displaying Word, PDF, PPT, and Excel documents, the current document library mini-program uses a fluid layout, which extracts the document content and then renders it on the front end. The biggest drawback of this method is that it cannot reproduce the true appearance of the document, losing its original layout. Summary of the Invention

[0003] This disclosure provides a document display method, apparatus, device, and storage medium.

[0004] According to one aspect of this disclosure, a document display method is provided, comprising: in response to a document display request, creating a canvas for displaying the document through a dynamic library; obtaining target data corresponding to the document, the target data including font information of the document; when it is determined that the font in the font information does not exist in the font library, calling the dynamic library to create a hidden tag corresponding to the font information; calling the tag to use the font in the font information so that the font in the font information is loaded into the font library; and rendering the document onto the canvas according to the font in the font information.

[0005] According to another aspect of this disclosure, a document display apparatus is provided, comprising: a creation unit, configured to create a canvas for displaying the document via a dynamic library in response to a document display request; an acquisition unit, configured to acquire target data corresponding to the document, the target data including font information of the document; a first invocation unit, configured to invoke the dynamic library to create a hidden tag corresponding to the font when it is determined that the font in the font information does not exist in the font library; a second invocation unit, configured to invoke the tag to use the font in the font information, so that the font in the font information is loaded into the font library; and a rendering unit, configured to render the document onto the canvas according to the font in the font information.

[0006] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method of the first aspect or any embodiment of the first aspect.

[0007] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause a computer to perform a method according to the first aspect or any embodiment of the first aspect.

[0008] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method according to the first aspect or any embodiment of the first aspect.

[0009] The document display method, apparatus, device, storage medium, and computer program product provided in this disclosure create a canvas for displaying documents by employing the ability to create a canvas using dynamic libraries. When it is determined that the font in the font information does not exist in the font library, the ability to create a hidden tag using dynamic libraries is further employed to create a hidden tag. This hidden tag is then called to use the font in the font information, loading the font in the font information into the font library so that it can be used by the canvas. Then, the document is rendered onto the canvas according to the font in the font information corresponding to the document. When the document is displayed to the user, not only is the original document layout preserved, but the font is also kept consistent, restoring the full appearance of the original document. Therefore, when the user needs to download the document, the layout and font of the downloaded document are consistent with what the user actually saw, improving the user experience. Furthermore, drawing document content on a canvas can expand document functionality. For example, it provides a drawing tool for marking and doodling on the document; exporting long images from WAP documents can be shortened from 6 seconds to 100 milliseconds; and anti-cheating measures can prevent users from copying document content by interfering with source code execution, such as disabling manipulation of the document object model to obtain text content.

[0010] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0011] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:

[0012] Figure 1 This is a schematic diagram of a document display method according to this disclosure;

[0013] Figure 2 This is a schematic diagram illustrating another method of document display according to this disclosure;

[0014] Figure 3 This is a schematic diagram illustrating another method of document display according to this disclosure;

[0015] Figure 4 This is a structural schematic diagram of a document display device according to the present disclosure;

[0016] Figure 5 This is a block diagram of an electronic device used to implement the document display method of the embodiments of this disclosure. Detailed Implementation

[0017] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0018] This disclosure provides a document display method applicable to document display in mini-programs, PCs, mobile web pages (WAP), etc. Figure 1 As shown, document display methods include:

[0019] S101. In response to a document display request, create a canvas for displaying the document using a dynamic library.

[0020] In this embodiment, document types include Word, Excel, PDF, PPT, etc. When a user finds a document they want to read in the document library, they can use the electronic device's input tools, such as a mouse or keyboard, to input a document display request. When the electronic device receives the user's document display request, it can create a canvas for displaying the document on a preview page, such as a document reader or browser, using a dynamic library. The dynamic library can be a mini-program, a PC, or a WAP application that comes with it, or it can be pre-downloaded by the user. The canvas provides an application programming interface (API), through which JavaScript (JS) can be used to draw images and text, and can be used for animation, games, data visualization, image editing, and real-time video processing, etc. This embodiment fully utilizes the characteristics of the canvas.

[0021] S102. Obtain the target data corresponding to the document, including the document's font information.

[0022] In this embodiment, before the front end renders the document using a canvas, the back end sends the target data of the document to the front end, providing the specific content of the document.

[0023] In some embodiments, the target data includes, but is not limited to, text and image information within the document. Text information includes, but is not limited to, text, the third position of the text on the page, and the font information corresponding to the text. Image information includes, but is not limited to, images within the document and the first position of the images on the page. Font information includes font, font size, font color, and font weight. The target data corresponding to the document can be obtained by parsing the document when the user uploads it to the document library. The high-level programming language JavaScript can be used to parse the document and obtain the target data corresponding to the document.

[0024] S103. If it is determined that the font in the font information does not exist in the font library, call the dynamic library to create the hidden tag corresponding to the font information.

[0025] In this embodiment, after obtaining the target data corresponding to the document, the font in the font information can be determined. Since different fonts can be used in the document, and it is impossible for every font to be present on the user's electronic device at the same time, in order for the document to be rendered using the original font, it is necessary to ensure that the font of the document is loaded in the font library. However, the current document library uses lazy loading for fonts; font loading is only triggered when a font has been used. Therefore, even if the target data includes the font of the document, if the font does not exist in the font library, the canvas still cannot use the font. Therefore, by determining whether the font in the font information exists in the font library, if the font does not exist in the font library, the capabilities of dynamic libraries can be utilized to create a hidden tag. This tag is used to use the font in the font information, thereby triggering the loading of the font in the font information into the font library. Creating a hidden tag is to make the tag invisible to the user on the preview page, which can improve the user experience.

[0026] S104. Call the tag to use the font in the font information so that the font in the font information is loaded into the font library.

[0027] In this embodiment, after creating a hidden label, the label can be invoked to use the font in the font information, thereby making the font in the font information used, which triggers the font in the font information to be loaded into the font library. Thus, when the canvas draws the text of the document, it can use the font in the font information, so that the drawn document has the same font as the original document.

[0028] S105. Render the document onto the canvas according to the font in the font information.

[0029] In this embodiment, once the font of the original document exists in the font library, the parameters for drawing text can be set according to the font, font size, font color, font weight, etc. in the font information. Then, the text is drawn onto the canvas according to the third position of the text on the page, and the image is drawn onto the canvas according to the position of the image on the page.

[0030] The document display method provided in this disclosure utilizes the ability of a dynamic library to create a canvas for displaying the document. When it is determined that the font in the font information does not exist in the font library, the method further utilizes the ability of the dynamic library to create hidden tags, creating hidden tags corresponding to the font information. These hidden tags are then called to use the font in the font information, loading the font into the font library so that it can be used by the canvas. The document is then rendered onto the canvas according to its corresponding font information. When displaying the document to the user, the original document layout is preserved, and the font remains consistent, restoring the full appearance of the original document. Therefore, when the user needs to download the document, the layout and font of the downloaded document are consistent with what the user actually saw, improving the user experience. Furthermore, drawing document content on the canvas can expand the document's functionality. For example, it provides a drawing tool for marking and drawing on the document; exporting long images from WAP documents can be reduced from 6 seconds to 100 milliseconds; and anti-cheating measures prevent users from copying document content by interfering with source code execution, such as disabling operations on the document object model to obtain text content.

[0031] In an optional embodiment, since the document is uploaded to the library earlier than the time the user reads or downloads the document from the library, the document can be directly parsed when the user uploads it to the library to obtain the target data corresponding to the document, and then saved to obtain the save address, which is also the address of the target data. Therefore, when the user needs to read the document, real-time document parsing is not required; the target data can be quickly located based on its address, improving document display speed. Therefore, in step S101, before responding to a document display request, such as... Figure 2 As shown, document display methods also include:

[0032] S202. Recognize text information and sub-image information in the document. The text information includes the text in the document, the third position of the text on the page, and the font information corresponding to the text. The sub-image information includes the sub-images in the document and the first position of each sub-image on the page.

[0033] In this embodiment, a text recognition tool can be used to identify the text on each page of the document, the font information corresponding to the text, and the third position of the text on the page. An image recognition tool can be used to identify each sub-image on each page of the document, and the first position of each sub-image in the document.

[0034] S202. Combine the sub-images into one image, and form image information based on the image and the first position of each sub-image in the image on the page.

[0035] In this embodiment, since the canvas needs to download the image before drawing it, and then draw the image onto the canvas after the download is complete, in order to reduce the number of times the image is downloaded on the same page, the sub-images on the same page can be combined into one image. When combining the images, the sub-images can be rotated, scaled, and their transparency can be adjusted. When combining the images, it is necessary to record the size of each sub-image, the position of each sub-image in the image, the first position of each sub-image on the page, the processing of each sub-image, etc., and form image information based on the combined image and the first position of each sub-image on the page.

[0036] S203. Save the text and image information to obtain the target data.

[0037] In this embodiment, text and image information can be saved separately for each page.

[0038] S204. Obtain the address of the target data based on the storage addresses of the saved text and image information.

[0039] In this embodiment, saving text and image information yields a storage address, which is the address of the target data.

[0040] In an optional embodiment, step S102, obtaining the target data corresponding to the document, includes: obtaining the address of the target data corresponding to the document; if it is determined that there is no cached page corresponding to the address of the target data, downloading the target data according to the address of the target data. If it is determined that there is a cached page corresponding to the address of the target data, the target data is obtained from the cached page, wherein the cached page includes the text information and image information corresponding to the document.

[0041] Specifically, since the document is parsed and its corresponding target data is saved when it is uploaded to the document library, and the address of the target data is obtained, when retrieving the target data of the document, you can first obtain the address of the target data. For example, you can first obtain the address of the target data of the document's homepage.

[0042] Before a user reads a document, other users may have already read it. During the reading process of other users, the target data corresponding to the document will also be downloaded and saved as a cached page. Therefore, in order to reduce the waste of computing resources and duplicate downloads, after obtaining the address of the target data corresponding to the document, it can be determined whether there is a cached page corresponding to the address of the target data. If it is determined that there is no cached page corresponding to the target data, the target data will be downloaded from the address of the target data and then rendered.

[0043] If a cached page corresponding to the target data exists, the target data can be retrieved from the cached page without downloading it again, thus reducing the time and computing resources required to download the target data.

[0044] In an optional embodiment, before saving the text and image information in step S204, the document display method further includes:

[0045] Convert text and image information into data in the target format.

[0046] Specifically, a single reader or browser typically supports only one type of document. In this embodiment, to enable the same reader or browser to support multiple document types, after parsing the document, the text and image information are converted into data in a target format, which can be customized. This target format data is then saved. Therefore, when a user needs to read a document, after obtaining the target data corresponding to the document, the reader or browser uses a parser corresponding to that target format to parse the target data, thus obtaining parsed data of the same type as the original document. This allows the same reader or browser to simultaneously support the display of multiple document types, such as Word, PDF, PPT, and TXT documents.

[0047] In an optional embodiment, step S105, rendering text and images onto the canvas according to the font in the font information, includes:

[0048] Based on the stacking order of text and images in the document, render the text onto the canvas according to the font information.

[0049] Specifically, the document content has a hierarchical relationship, meaning the stacking order of the documents is inconsistent. If the stacking order of text and images is not considered when drawing the document content, some images may cover the text. In order to prevent the document from being covered, this embodiment of the disclosure adopts a sequential rendering method, rendering text and images onto the canvas in the order of their stacking, thereby avoiding the situation where text is covered by images.

[0050] The only drawback of using a canvas for drawing is the inability to utilize the default interactive features provided by Document Object Model elements, such as swiping to select text, copying, and click events. Text copying is a frequent user operation; therefore, in an optional embodiment, after rendering the document to the canvas according to the font information in step S105, as follows... Figure 3 As shown, document display methods also include:

[0051] S106. Record the second position of text and images on the canvas.

[0052] In this embodiment, when drawing text and images onto the canvas, the second position of the text and images drawn onto the canvas can be recorded in real time.

[0053] S107. Create a second canvas on top of the existing canvas; specifically, the second canvas completely covers and overlaps the canvas in the above embodiment. The content of the second canvas is empty and transparent. Thus, when the mouse or the user's finger slides on the second canvas, the coordinates of the slide can be obtained. If the coordinates of the slide coincide with the coordinates of the text, the text can be selected.

[0054] S108. A dynamic library is called to create a Document Object Model (DOM) on the second canvas, allowing the DOM to edit the document based on the text and images in their second positions on the canvas. Specifically, the dynamic library is called to create a document object model on the second canvas, so that selected text can be highlighted. Operations such as copying, deleting, marking, and underlining the text can then be performed on the second canvas, without affecting the document content on the first canvas.

[0055] In this embodiment, by recording the second position of text and images on the canvas, a second canvas is created on the first canvas, and a document object model is created on the second canvas by calling a dynamic library. This enables interactive operations such as copying the document. Since the interactive operations are performed on the second canvas, they do not affect the document content on the first canvas. Therefore, when the user wants to restore the document, it is not necessary to redraw the text on the canvas.

[0056] This disclosure also provides a document display device, applicable to document display in mini-programs, PCs, mobile web pages (wap), etc. Figure 4 As shown, the document display device includes:

[0057] The creation unit 21 is used to create a canvas for displaying the document through a dynamic library in response to the document display request; for details of the specific implementation, please refer to the description of step S101 in the above method embodiment, which will not be repeated here.

[0058] The acquisition unit 22 is used to acquire the target data corresponding to the document, and the target data includes the font information of the document; for details of the specific implementation, please refer to the description of step S102 of the above method embodiment, which will not be repeated here.

[0059] The first calling unit 23 is used to call the dynamic library to create a hidden tag corresponding to the font information when it is determined that the font information does not exist in the font library; for details of the specific implementation, please refer to the description of step S103 of the above method embodiment, which will not be repeated here.

[0060] The second calling unit 24 is used to call the font in the font information of the tag so that the font in the font information is loaded into the font library; for details of the specific implementation, please refer to the description of step S104 of the above method embodiment, which will not be repeated here.

[0061] The rendering unit 25 is used to render text and images onto the canvas according to the font information. For detailed implementation methods, please refer to the description of step S105 in the above method embodiment, which will not be repeated here.

[0062] The document display device provided in this disclosure creates a canvas for displaying documents by employing the ability to create a canvas using a dynamic library. When it is determined that the font in the font information does not exist in the font library, the device continues to use the ability to create hidden tags using the dynamic library. A hidden tag is created and called to use the font in the font information, loading the font into the font library so that it can be used by the canvas. Then, the document is rendered onto the canvas according to the font in the font information. When displaying the document to the user, the original document layout is preserved, and the font remains consistent, restoring the full appearance of the original document. Therefore, when the user needs to download the document, the layout and font of the downloaded document are consistent with what the user actually saw, improving the user experience. Furthermore, drawing document content on the canvas can also expand the document's functionality. For example, it provides a drawing tool for marking and drawing on the document; exporting long images from WAP documents can be shortened from 6 seconds to 100 milliseconds; and anti-cheating measures prevent users from copying document content by interfering with source code execution, such as disabling operations on the document object model to obtain text content.

[0063] In an optional embodiment, the acquisition unit includes: an acquisition subunit, configured to acquire the address of the target data corresponding to the document; and a first determination subunit, configured to download the target data according to the address of the target data if it is determined that there is no cached page corresponding to the address of the target data.

[0064] In an optional embodiment, the acquisition unit further includes a second determination subunit, configured to acquire the target data from the cached page if it is determined that a cached page corresponding to the address of the target data exists.

[0065] In an optional embodiment, before the creation unit, the device further includes: a recognition unit, used to recognize text information and sub-image information in the document, wherein the text information includes text in the document and the font information corresponding to the text, and the sub-image information includes sub-images in the document and the first position of each sub-image on the page; a synthesis unit, used to synthesize the sub-images into an image, and form image information based on the image and the first position of each sub-image in the image on the page; a storage unit, used to store the text information and image information to obtain target data; and a obtaining unit, used to obtain the address of the target data based on the storage address of the stored text information and image information.

[0066] In an optional embodiment, prior to the saving unit, the apparatus further includes a conversion unit for converting text information and image information into data in a target format.

[0067] In an optional embodiment, the rendering unit includes a rendering subunit, configured to render text onto the canvas and render images onto the canvas according to the font information in the font, based on the stacking order of text and images in the document.

[0068] In an optional embodiment, after the rendering unit, the apparatus further includes: a recording unit for recording the second positions of text and images on the canvas; a second creation unit for creating a second canvas on the canvas; and a third invocation unit for invoking a dynamic library to create a document object model on the second canvas, so that the document object model can edit the document based on the second positions of text and images on the canvas.

[0069] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0070] Figure 5 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0071] like Figure 5As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.

[0072] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of monitors, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0073] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose 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 801 performs the various methods and processes described above, such as document presentation methods. For example, in some embodiments, the document presentation method can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the document presentation method described above can be performed. Alternatively, in other embodiments, the computing unit 801 can be configured to perform the document presentation method by any other suitable means (e.g., by means of firmware).

[0074] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0075] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This 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 when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0076] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0077] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0078] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0079] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.

[0080] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0081] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A document display method applied to a document library, wherein the document library performs lazy loading of fonts; the lazy loading indicates that if a font has been used, the font is triggered to be loaded into the font library; If the font has not been used, it will not be loaded into the font library; among other things, Fonts not loaded into the font library cannot be used on the canvas. The method includes: In response to a document display request, a canvas for displaying the document is created using a dynamic library; Obtain the target data corresponding to the document, wherein the target data includes the font information of the document; If it is determined that the font in the font information does not exist in the font library, the dynamic library is called to create the hidden tag corresponding to the font information; The tag is invoked to use the font from the font information, so that the font from the font information is loaded into the font library; The document is rendered onto the canvas according to the font in the font information.

2. The method according to claim 1, wherein obtaining the target data corresponding to the document includes: Obtain the address of the target data corresponding to the document; If it is determined that there is no cached page corresponding to the address of the target data, the target data is downloaded according to the address of the target data.

3. The method according to claim 2, further comprising: If it is determined that a cached page corresponding to the address of the target data exists, the target data is obtained from the cached page.

4. The method of claim 1, further comprising, before responding to a document display request: The document identifies text information and sub-image information. The text information includes the text in the document, the third position of the text on the page, and the font information corresponding to the text. The sub-image information includes the sub-images in the document and the first position of each sub-image on the page. The sub-images are combined into one image, and image information is formed based on the image and the first position of each sub-image in the image on the page; Save the text information and the image information to obtain the target data; The address of the target data is obtained based on the storage address of the text information and the image information.

5. The method according to claim 4, further comprising, before saving the text information and the image information: Convert the text information and the image information into data in the target format.

6. The method according to claim 4, wherein rendering the document onto the canvas according to the font in the font information comprises: Based on the stacking order of the text and images in the document, the text is rendered onto the canvas according to the font in the font information, and the images are rendered onto the canvas.

7. The method according to claim 6, further comprising, after rendering the document onto the canvas according to the font in the font information: Record the second position of the text and the image on the canvas; Create a second canvas on the first canvas; A dynamic library is invoked to create a document object model on the second canvas, so that the document object model can edit the document based on the text and the image at a second position on the canvas.

8. A document display device applied to a document library, wherein the document library performs lazy loading of fonts; the lazy loading indicates that if a font has been used, the font is triggered to be loaded into the font library; If the font has not been used, it will not be loaded into the font library; among other things, Fonts not loaded into the font library cannot be used on the canvas. The device includes: Create a unit to respond to a document display request and create a canvas for displaying the document using a dynamic library; An acquisition unit is used to acquire target data corresponding to the document, wherein the target data includes the font information of the document; The first calling unit is used to call the dynamic library to create a hidden tag corresponding to the font when it is determined that the font in the font information does not exist in the font library; The second calling unit is used to call the tag to use the font in the font information, so that the font in the font information is loaded into the font library; A rendering unit is used to render the document onto the canvas according to the font in the font information.

9. The apparatus according to claim 8, wherein the acquiring unit comprises: A subunit is used to obtain the address of the target data corresponding to the document; The first determination subunit is used to download the target data according to the address of the target data if it is determined that there is no cached page corresponding to the address of the target data.

10. The apparatus according to claim 9, wherein the acquiring unit further comprises: The second determination subunit is used to obtain the target data from the cache page if it is determined that a cache page corresponding to the address of the target data exists.

11. The apparatus of claim 8, further comprising, prior to creating the unit: The recognition unit is used to recognize text information and sub-image information in the document. The text information includes the text in the document, the third position of the text on the page, and the font information corresponding to the text. The sub-image information includes the sub-images in the document and the first position of each sub-image on the page. A compositing unit is used to combine the sub-images into a single image, and to form image information based on the image and the first position of each of the sub-images in the image on the page; A storage unit is used to store the text information and the image information to obtain the target data; The obtaining unit is used to obtain the address of the target data based on the storage address of the text information and the image information.

12. The apparatus of claim 11, further comprising, prior to the storage unit: The conversion unit is used to convert the text information and the image information into data in the target format.

13. The apparatus of claim 11, wherein the rendering unit comprises: The rendering subunit is used to render the text onto the canvas and the image onto the canvas according to the stacking order of the text and the image in the document and the font in the font information.

14. The apparatus of claim 13, further comprising, after the rendering unit: A recording unit is used to record the second position of the text and the image on the canvas; The second creation unit is used to create a second canvas on the canvas; The third calling unit is used to call a dynamic library to create a document object model on the second canvas, so that the document object model can edit the document based on the text and the image at the second position on the canvas.

15. An electronic device comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.

16. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-7.

17. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Font handling for viewing documents on web

    CN102326179A

  • Document display method and device, equipment and computer readable medium

    CN112650714A