Data processing method, electronic device, computer storage medium and computer program product

By extracting text and rendering scalable vector graphics on PDF text pages, creating text editing areas, solving the problem of difficulty in editing text in PDF files, achieving efficient text editing functions and reducing development costs.

CN119740548APending Publication Date: 2025-04-01UC MOBILE CHINA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411581502.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-06
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

The prior art is difficult to edit the text in PDF files, which leads to difficulties for users when they need to modify the content of the document.

Method used

By extracting text during the display of the target text page, obtaining text content information and attribute information, and rendering scalable vector graphics based on this information to create a text editing area. The user performs editing operations in the text editing area, updates the rendering results, and synchronizes the original page data.

Benefits of technology

It realizes the editing function of text in PDF files, reduces development complexity and cost, and can quickly provide text editing services to users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119740548A_ABST
    Figure CN119740548A_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a data processing method, an electronic device, a computer storage medium and a computer program product, wherein the data processing method comprises: in the process of displaying a target text page, extracting text from the target text page to obtain text content information and text attribute information of each text in the target text page; performing scalable vector graphics rendering based on the text content information and text attribute information of each text to obtain a text editing area; displaying scalable vector graphics corresponding to each text in the target text page in the text editing area; updating the rendering result in the text editing area in response to a text editing operation in the text editing area, displaying the edited text in the text editing area, and modifying the original page data corresponding to the target text page based on the updated rendering result. The embodiment of the present application can quickly provide text editing services to users at a relatively low development cost and development complexity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a data processing method, an electronic device, a computer storage medium, and a computer program product. Background Art

[0002] With the rapid development of information technology and the advent of the digital age, PDF (Portable Document Format) has become a widely used document format because of its advantages of maintaining format consistency on different devices and platforms and facilitating sharing and storage.

[0003] When using PDF documents, users often face the need to modify and edit the document content, including updating information, correcting errors, adding comments, or reformatting.

[0004] Therefore, how to edit the text in the PDF file has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] In view of this, an embodiment of the present application provides a data processing solution to at least partially solve the above-mentioned problem.

[0006] According to a first aspect of an embodiment of the present application, a data processing method is provided, including:

[0007] During the display of the target text page, text extraction is performed on the target text page to obtain text content information and text attribute information of each text in the target text page;

[0008] Based on the text content information and text attribute information of each text, a scalable vector graphics rendering is performed to obtain a text editing area; the text editing area displays the scalable vector graphics corresponding to each text in the target text page;

[0009] In response to a text editing operation in the text editing area, a rendering result in the text editing area is updated, the edited text is displayed in the text editing area, and original page data corresponding to the target text page is modified based on the updated rendering result.

[0010] According to a second aspect of an embodiment of the present application, another data processing method is provided, which is applied to a client device, including:

[0011] Sending a page data acquisition request for a target document to a server device;

[0012] Receive the original page data returned by the server device, and display the target text page based on the original page data;

[0013] Performing text extraction on the target text page to obtain text content information and text attribute information of each text in the target text page; performing scalable vector graphics rendering based on the text content information and text attribute information of each text to obtain a text editing area;

[0014] In response to a text editing operation in the text editing area, updating a rendering result in the text editing area, and displaying edited text in the text editing area;

[0015] According to the updated rendering result, the edited text layout information in the text editing area is generated, and the edited text layout information is sent to the server device, so that the server device updates the original page data based on the edited text layout information and saves the updated page data.

[0016] According to the third aspect of an embodiment of the present application, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method described in the first aspect or the second aspect.

[0017] According to a fourth aspect of an embodiment of the present application, a computer storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect or the second aspect is implemented.

[0018] According to the data processing scheme provided in the embodiment of the present application, during the display process of the target text page, text extraction is performed on the page; after obtaining the text content information and text attribute information of each text in the target text page, scalable vector graphics rendering is performed based on the above information, and a text editing area displaying a scalable vector graphics corresponding to each text is obtained, so that the user can perform text editing in the area; thereafter, the rendering result inside the above area is updated according to the text editing operation, the edited text is displayed in the text editing area, and the page data of the target text page is synchronously modified based on the updated rendering result.

[0019] In the embodiment of the present application, after extracting the text content information and text attribute information of each text in the target text page, from the perspective of upper-level application development, a text editing area is provided by rendering a scalable vector graphics corresponding to the text, so that the user can perform text editing operations in the area; then, according to the editing operation, the rendering result is updated from a visual level to show the user the effect of the edited target text page, and the page data is modified according to the updated rendering result, so as to save the target text page edited by the user for the next page display. Compared with the solution in the related art that realizes text editing by modifying the underlying source code of the existing open source rendering library, the embodiment of the present application realizes text editing from the upper-level architecture level through scalable vector graphics rendering, and does not involve modification and processing of the underlying source code. Therefore, the complexity of the solution implementation and the development cost are relatively low, and the online service of the text editing function can be completed in a relatively short development time.

[0020] In summary, through the embodiments of the present application, text editing services can be quickly provided to users with lower development costs and development complexity. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0022] Figure 1 A flowchart of a data processing method according to an embodiment of the present application;

[0023] Figure 2 A diagram of the text layout of a PDF page;

[0024] Figure 3 A schematic diagram of text blocks obtained by splitting a target text page in an embodiment of the present application;

[0025] Figure 4 This is a comparison diagram between the PDF coordinate system and the page coordinate system;

[0026] Figure 5 A schematic diagram of an exemplary system applicable to the data processing method of an embodiment of the present application;

[0027] Figure 6 A flowchart of another data processing method provided according to an embodiment of the present application;

[0028] Figure 7A structural block diagram of a data processing device provided according to an embodiment of the present application;

[0029] Figure 8 A structural block diagram of another data processing device provided according to an embodiment of the present application;

[0030] Fig. 9 The present invention is a schematic diagram of the structure of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0031] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.

[0032] The specific implementation of the embodiment of the present application is further explained below in conjunction with the accompanying drawings of the embodiment of the present application.

[0033] Refer to the figure, Figure 1 The data processing method provided in the embodiment of the present application may include the following steps:

[0034] Step 102: During the display of the target text page, text extraction is performed on the target text page to obtain text content information and text attribute information of each text in the target text page.

[0035] Specifically, the target text page may be a non-editable page containing text characters. Exemplarily, the target text page in the embodiment of the present application may be a Portable Document Format (PDF) page, or may be a non-editable web page, and so on.

[0036] In the embodiments of the present application, there is no limitation on the specific extraction method used for text extraction. For example, with respect to PDF pages, a PDF open source rendering library (such as PDFium, etc.) provided in the relevant technology for PDF rendering and processing can be used to perform text parsing on the PDF page through the open source rendering library to extract the text content information and text attribute information of each text in the target text page. Among them, the text content information represents the specific content of the text, and the text attribute information represents the layout of each text in the page, which may specifically include: geometric posture information (text coordinate information, size information, rotation angle information), font information, glyph information, boundary range information, and the like.

[0037] Step 104 , based on the text content information and text attribute information of each text, a scalable vector graphics rendering is performed to obtain a text editing area; the text editing area displays the scalable vector graphics corresponding to each text in the target text page.

[0038] Specifically, for each text in the target text page, the SVG (Scalable Vector Graphics) information corresponding to each text can be converted according to the text content information of the text and the font information in the text attribute information. After the SVG information is obtained, the SVG graphics rendering can be performed in the target text page according to the information, so as to display the text editing area containing the scalable vector graphics corresponding to each text to the user.

[0039] SVG is an XML markup language used to describe two-dimensional graphics. Unlike bitmap images, SVG images are based on mathematical descriptions rather than pixel descriptions and are stored in text form, so they can be scaled to any size without distortion. In other words, SVG graphics are scalable and do not require resolution dependence, which means that they can be enlarged or reduced without distortion. Based on the above-mentioned characteristics of SVG images, in an embodiment of the present application, the size and position of each scalable vector image can be customized and changed according to actual needs. In other words, in an embodiment of the present application, through SVG rendering, a text editing area of ​​any suitable size can be displayed to the user at any suitable position in the page, thereby meeting the user's text editing needs while further meeting the user's personalized needs at the visual level of text display.

[0040] Step 106 , in response to the text editing operation in the text editing area, updating the rendering result in the text editing area, displaying the edited text in the text editing area, and modifying the original page data corresponding to the target text page based on the updated rendering result.

[0041] Specifically, after the text editing area is displayed to the user, the user can perform text editing operations within the area. After the client device detects the user's text editing operation, the rendering result in the text editing area can be adaptively updated according to the operation content, so that the edited text desired by the user can be displayed in a matching manner within the text editing area. For example: the text editing operation can be: text addition operation, text deletion operation, and so on. With respect to the text addition operation, when it is detected that the user performs a preset text addition operation, the newly added text can be drawn and displayed at the corresponding position in the text editing area through drawing functions such as Canvas. With respect to the text deletion operation, when it is detected that the user performs a preset text deletion operation, the text can be deleted at the corresponding position in the text editing area, thereby updating the rendering result in the text editing area.

[0042] In addition, according to the user's text editing operation, the rendering result in the text editing area is updated, which mainly shows the edited target text page to the user from a visual level. Considering that the user usually wants to save the edited target text page, therefore, in the embodiment of the present application, the original page data corresponding to the target text page is further modified according to the updated rendering result, so as to realize the write-back saving of the edited target text page.

[0043] At present, in order to provide the functions of editing and saving document pages, the relevant technologies are mainly based on open source rendering libraries (such as PDFium libraries for PDF documents), which are implemented through secondary development of the underlying source code. PDFium is an open source PDF rendering library. PDFium provides the functions of interpreting PDF document data and rendering PDF pages to output images, but it does not have the function of editing PDF document page elements. If you want to implement the PDF text editing function, you need to modify the underlying source code of the PDFium library to implement PDF text self-rendering, so that it has the text editing function. However, the development time cost, complexity and difficulty of the above-mentioned text self-rendering function are very large. If you want to put the PDF text editing function online in a short period of time to serve users, the above solution is not applicable.

[0044] In the embodiment of the present application, after extracting the text content information and text attribute information of each text in the target text page, a text editing area is provided from the perspective of the upper-level application by rendering the scalable vector graphics corresponding to the text, so that the user can perform PDF text editing operations in the area; then, according to the editing operation, the rendering result is updated from the visual level to show the user the effect of the edited target text page, and the page data is modified according to the updated rendering result, so as to save the target text page edited by the user for the next page display. Compared with the above-mentioned related technology, which realizes text editing by modifying the underlying source code of the existing open source rendering library, the embodiment of the present application realizes text editing from the upper-level architecture level through scalable vector graphics rendering, and does not involve the modification and processing of the underlying source code. Therefore, the complexity of the solution implementation and the development cost are relatively low, and the online service of the text editing function can be completed in a relatively short development time.

[0045] In summary, through the embodiments of the present application, text editing services for non-editable pages can be quickly provided to users with lower development costs and development complexity.

[0046] The data processing method provided in the embodiment of the present application can be executed by any appropriate device with data processing capabilities, including but not limited to: a PC and a server.

[0047] Optionally, in some of the embodiments, after obtaining the text content information and text attribute information of each text in the target text page, the method further includes:

[0048] Analyze the text content information and text attribute information of each text to generate text layout information in the target text page;

[0049] Modify the original page data corresponding to the target text page based on the updated rendering result, including:

[0050] Based on the updated rendering result, the text layout information in the target text page is modified to obtain the edited text layout information for the target text page, and the original page data corresponding to the target text page is modified according to the edited text layout information.

[0051] Specifically, the text layout information in the target text page generated by the above-mentioned embodiment of the present application can characterize the layout between the texts contained in the target text page. The text layout information may include: the boundary information of the page, the text line information contained in the page, the text content and text attribute information of each text contained in the text line, and so on. Among them, as for the boundary information of the page, exemplarily, it can include the bottom position information, the top position information and the boundary information on the left and right sides, and so on; as for the text line information contained in the page, exemplarily, it can include the boundary information of the text line, the content and attribute information of each text contained in the text line, and so on. In the embodiment of the present application, the specific data structure of the text layout information in the target text page is not limited, and can be customized according to actual conditions.

[0052] In the above embodiment of the present application, before the text editing operation, the text layout information in the target text page is first generated from the macro level of the target text page by analyzing the text content information and the text attribute information. Afterwards, based on the text editing operation and the corresponding updated rendering result, the above text layout information is adaptively modified to obtain the edited text layout information, so that the original page data can be written back and saved according to the edited text layout information. The above process introduces the text layout information corresponding to the macro level of the target text page to record the page layout change process brought about by the text editing operation, so that the modified page data matching the text editing operation can be obtained quickly and accurately.

[0053] Optionally, in some of the embodiments, analyzing the text content information and text attribute information of each text to generate text layout information in the target text page includes:

[0054] Analyze the text content information and text attribute information of each text, split the target text page into multiple text blocks, and obtain the text layout information in each text block;

[0055] Based on the text content information and text attribute information of each text, scalable vector graphics rendering is performed to obtain a text editing area, including:

[0056] In response to a text block selection operation, determining a text block to be edited from a plurality of text blocks;

[0057] Based on the text layout information in the text block to be edited, a scalable vector graphics rendering is performed in the text block to be edited to obtain a text editing area;

[0058] Based on the updated rendering result, the text layout information in the target text page is modified to obtain the edited text layout information for the target text page, including:

[0059] Based on the updated rendering result, the text layout information in the text block to be edited is modified to obtain the edited text layout information for the text block to be edited.

[0060] Specifically, for a complete target text page, especially a page containing more texts, each text is usually distributed in different positions, thus forming different paragraph areas. Through the text extraction operation, what is obtained is independent individual text information, which cannot fully reflect the organizational relationship and paragraphs between texts. In other words, each text exists in the page in the form of independent coordinates, and the correlation between texts is poor.

[0061] When a user performs text editing operations on text with poor associations, the client device may not be able to accurately capture the user's intention, and thus cannot accurately update the subsequent rendering results. This may cause the editing results presented to the user to be inconsistent with the user's editing needs.

[0062] For example, see Figure 2 , Figure 2 The following is a schematic diagram of the editing process of a PDF page. Figure 2 The page before editing shown in the figure contains two text paragraphs, and the text lines in the two text paragraphs are aligned with each other, that is, the first text line of the first text paragraph is aligned with the first text line of the second text paragraph, the second text line of the first text paragraph is aligned with the second text line of the second text paragraph, etc. When the user deletes two texts in the first text line of the first text paragraph, the resulting page should theoretically be Figure 2 The "edited theoretical PDF page" shown: the remaining text after the above-mentioned deleted text in the first text line of the first text paragraph is shifted two character positions to the left; the first two texts in the second text line are moved up to the end of the first text line, and the remaining text in the second text line is shifted two characters to the left; the first two texts in the third text line are moved up to the end of the second text line, and the remaining text in the third text line is shifted two characters to the left; the first two texts in the fourth text line are moved up to the end of the third text line.

[0063] If the relationship between the texts is not clear, the result may be Figure 2 The "actual PDF page after editing" shown: while the remaining text in the first text line of the first text paragraph after the deleted text is shifted two character positions to the left, the text in the first text line of the second text paragraph is also shifted two character positions to the left…, which will cause the actual editing result finally presented to the user to be not the theoretical editing result that the user wants.

[0064] Based on the above considerations, in the above embodiment of the present application, after the text content information and text attribute information are extracted, the text in the page is divided into blocks in an organized manner according to the above information, and multiple text blocks and text layout information of each text block are obtained. Afterwards, in response to the user's text block selection operation, subsequent operations such as scalable vector graphics rendering and editing and updating are performed separately for the selected text block to be edited. Through the above page splitting operation, texts with related relationships can be divided into one text block, and then the rendering results can be updated based on the clear relationship between the texts in the text block, which can ensure that the new page layout after the user's editing operation meets the user's editing needs, thereby improving the accuracy of text editing and user experience.

[0065] Similar to the text layout information in the target text page, the text layout information of each text block obtained in the above embodiment of the present application can also represent the layout of each text contained in the text block. The text layout information may include: the boundary information of the text block, the text line information contained in the text block, the text content and text attribute information of each text contained in the text line, etc.

[0066] Furthermore, to facilitate the user's selection of text blocks to be edited, after obtaining multiple text blocks and text layout information of each text block, the outer border corresponding to each text block can be drawn on the page according to the text block boundary information in the text layout information. When the user's selection operation on a certain outer block is detected, the text block in the outer border is determined as the text block to be edited, so that subsequent editing operations can be performed on the text block to be edited.

[0067] See also Figure 3 , Figure 3 This is a schematic diagram of text blocks obtained by splitting a target text page in an embodiment of the present application. Figure 3 After the page splitting process of the above embodiment of the present application, the journal article displayed in the target text page of the present invention can be obtained. Figure 3 The page diagram is shown in Figure 1. The page is divided into 9 text blocks, namely: title, author information, abstract, and the first to sixth paragraphs of the text. In addition, to facilitate user selection, Figure 3 An outer border is also drawn for each text block. When the user clicks on an outer border, subsequent text editing operations can be performed on the text block in the outer border.

[0068] Optionally, in some of the embodiments, the text attribute information includes: text glyph information, text font information and text boundary information;

[0069] Based on the text content information and text attribute information of each text, scalable vector graphics rendering is performed to obtain a text editing area, including:

[0070] Create a background overlay;

[0071] Based on the text content information and text font information of each text, convert and obtain scalable vector graphics information corresponding to each text;

[0072] Determine the rendering area of ​​each text in the background overlay layer according to the text font information and text boundary information of each text;

[0073] According to the scalable vector graphics information corresponding to each text and the rendering area of ​​each text in the background overlay layer, the scalable vector graphics rendering is performed in the background overlay layer to obtain the text editing area.

[0074] Specifically, in the above-mentioned embodiment of the present application, when rendering the text editing area, first, according to the text layout information of the page, a background overlay layer that does not contain text information is created and covered on the upper layer of the page (for example, PDFium can be used to generate the editing area background layer without text); then the scalable vector graphics information corresponding to each text in the page is obtained; then, according to the font and boundary information of the text, the rendering area of ​​the single text is determined, and then the scalable vector graphics corresponding to the text is placed in the corresponding rendering area by scaling the scalable vector graphics information. Since the position and placement area of ​​each scalable vector graphics in the text editing area finally obtained are obtained according to the attribute information of each text in the page, each scalable vector graphics inside the text editing area can completely overlap with the text originally displayed in the page, so that the non-editable target text page can be converted into an editable text editing area without the user's perception, further improving the user's experience.

[0075] Furthermore, in the case where the page is divided into multiple text blocks and the user has selected a text block to be edited, the process of obtaining the text editing area may include:

[0076] According to the local information of the text in the text block to be edited, the background overlay layer of the text block is covered; based on the text content information and text font information of each text in the text block to be edited, the scalable vector graphics information corresponding to each text in the text block to be edited is converted; according to the text font information and text boundary information of each text in the text block to be edited, the rendering area of ​​each text in the background overlay layer is determined; according to the scalable vector graphics information corresponding to each text and the rendering area of ​​each text in the background overlay layer, the scalable vector graphics rendering is performed in the background overlay layer to obtain the text editing area corresponding to the text block to be edited.

[0077] Optionally, in some of the embodiments, in response to a text editing operation in the text editing area, a specific process of updating a rendering result in the text editing area may include:

[0078] In response to a text editing operation in the text editing area, determining editing position information of the text to be edited;

[0079] According to the editing position information of the text to be edited, the rendering result in the text editing area is updated.

[0080] Specifically, the editing position of the text to be edited may be determined first according to the text editing operation performed by the user in the text editing area, and then the rendering result update operation may be performed at the editing position.

[0081] Optionally, in some embodiments, the text editing operation may be a text adding operation, and in response to the text editing operation in the text editing area, determining the editing position information of the text to be edited includes:

[0082] In response to a text adding operation in the text editing area, determining a text adding position of the text to be added;

[0083] Correspondingly, the process of updating the rendering result in the text editing area according to the editing position information of the text to be edited may include:

[0084] Determine the text font information of the text to be added according to the text font information of the text located in the same preset area as the text adding position;

[0085] According to the text font information of the text to be added, a rendering operation of the text to be added is performed at the text adding position to update the rendering result in the text editing area.

[0086] Specifically, after determining the text conditional text and the text to be added according to the user's text adding operation, the font information of the text to be added can be determined according to the font information of other texts (such as adjacent text, etc.) near the text adding position in the text editing area, and then rendered again at the text adding position according to the determined font, thereby updating the original rendering result and obtaining the edited PDF page.

[0087] Furthermore, the process of performing the text rendering operation at the text adding position according to the text font information of the text to be added to update the rendering result in the text editing area may specifically include:

[0088] Through canvas technology, the text to be added is rendered according to the text font information of the text to be added, and the obtained rendering result of the text to be added is added to the text adding position to update the rendering result in the text editing area.

[0089] Optionally, in some embodiments, the text editing operation may be a text deletion operation, and the process of determining the editing position information of the to-be-edited text in response to the text editing operation in the text editing area may specifically include:

[0090] In response to a text deletion operation in the text editing area, determining text to be deleted and text position information of the text to be deleted;

[0091] Correspondingly, the process of updating the rendering result in the text editing area according to the editing position information of the text to be edited may specifically include:

[0092] According to the text position information of the text to be deleted, the text to be deleted is removed from each text to obtain the retained text;

[0093] Based on the text content information and text attribute information of each reserved text, the scalable vector graphics corresponding to each reserved text are re-rendered to update the rendering result in the text editing area.

[0094] Specifically, for a text block, its structure on the screen rendering tree corresponding to the page may include: a block editor component and text layout information in the text block. A canvas element and a textarea element can be mounted in the quick editor component. Among them, canvas is responsible for the display of newly added text, and textarea is used to detect the addition, deletion and editing operations of text by listening to keyboard input events through textarea. The text layout information in the text block can be used to convert each text character into a div node, so that the text characters are displayed on the background overlay.

[0095] Optionally, in some of the embodiments, the text content information and text attribute information of each text are analyzed, the target text page is split into multiple text blocks, and the text layout information in each text block is obtained, including:

[0096] Analyze text attribute information of each text, and divide each text into multiple text lines;

[0097] For the multiple text lines obtained by the division, the multiple text lines are divided into multiple text blocks according to the relationship between the line spacing values ​​between adjacent text lines and a preset line spacing threshold.

[0098] Specifically, when splitting a page into text blocks, each text may be first divided into different text lines according to the coordinate information in the text attribute information of each text (for example, texts with the same ordinate or abscissa may be divided into one text line). Afterwards, for each divided text line, it may be further divided into different text blocks according to the line spacing value between adjacent text lines. For example, it may be determined whether the line spacing between adjacent text lines is less than a preset spacing. If so, it is determined that the adjacent text lines are in the same text block. Otherwise, it is determined that the adjacent texts are in different text blocks.

[0099] Optionally, in some of the embodiments, analyzing the text attribute information of each text and dividing each text into a plurality of text lines includes:

[0100] Divide the texts with the same vertical coordinates into a candidate text line;

[0101] The candidate text line is split into multiple text lines according to the relationship between the text spacing value between adjacent texts in the candidate text line and a preset text spacing threshold.

[0102] Specifically, on some pages (such as Figure 2 In a page (as shown in the figure), there may be multiple parallel text paragraphs along the same direction (such as along the horizontal direction), that is to say, although the ordinates of the texts are the same, the texts do belong to different text paragraphs. In order to improve the accuracy of text block division, in an embodiment of the present application, when dividing text lines, not only the ordinate value of the text is considered, but also the text spacing value between adjacent texts. Specifically, when the text spacing value between adjacent texts is small, the adjacent texts are divided into the same text line. Conversely, when the text spacing value between adjacent texts is large, the adjacent texts are divided into different text lines. The above process can effectively improve the accuracy of text block splitting.

[0103] Furthermore, in the case of PDF pages, text is extracted from the PDF pages, and in the text attribute information obtained, the text coordinate values ​​are usually expressed based on the PDF coordinate system. The PDF coordinate system is a coordinate system in the text space, and the coordinate system takes the lower left corner of the page as the origin (see Figure 4 ). When rendering a scalable vector image, it is usually based on the page coordinate system, which is a coordinate system in user space, and the origin of the coordinate system is at the upper left corner of the page. Therefore, after extracting the text attribute information, the coordinate information represented by the PDF coordinate system can be first converted to obtain the coordinate information represented by the page coordinate system, so as to perform subsequent rendering operations based on the information.

[0104] In an embodiment of the present application, a traditional coordinate conversion algorithm can be used to perform coordinate conversion in real time when coordinate conversion is required; or a coordinate conversion function for converting between the PDF coordinate system and the page P coordinate system can be pre-written, and then when coordinate conversion is required, the conversion result can be obtained by calling the function, and so on.

[0105] In an embodiment of the present application, through the coordinate conversion process, the rendered scalable vector graphics can be made to completely overlap with the texts originally displayed on the page, thereby converting the non-editable PDF page into an editable text editing area without the user's perception, further improving the user experience.

[0106] Correspondingly, since the page data of PDF is usually represented by the relative position in the PDF coordinate system, after the editing is completed and the updated rendering result is obtained, and the edited text layout information is obtained, in order to maintain the consistency of the page data, the position information in the edited text layout information can also be converted into coordinates to obtain the position information represented by the PDF coordinate system.

[0107] In addition, the data processing methods provided in the above-mentioned embodiments of the present application can be applied to any type of platform (such as Windows, Linux, macOS, etc.). Specifically, when constructing the program, the development framework corresponding to each platform can be used to construct application programs suitable for different platforms that can implement the data processing methods of the embodiments of the present application.

[0108] Furthermore, in the embodiment of the present application, an application for implementing the data processing method provided in the embodiment of the present application can be developed and constructed based on the Electron framework: unified code writing is performed based on the Electron framework, and the written code is packaged into an application suitable for multiple operating systems, without the need to write and maintain different codes for each platform separately. In this way, the cross-platform capability of the present application solution can be improved, that is, the application program can be built and run on multiple different operating system platforms using the same code base, which can effectively reduce development and maintenance costs.

[0109] See also Figure 5 , Figure 5 This is a schematic diagram of an exemplary system for the data processing method of the embodiment of the present application. For ease of understanding, first combine Figure 5 The application scenarios of the data processing method provided in the embodiments of the present application are explained.

[0110] like Figure 5 As shown, the system 500 may include a server 502, a communication network 504 and / or one or more user devices (ie, client devices) 506. Figure 5The example in FIG. 1 is a plurality of user devices.

[0111] The server 502 may be any suitable device storing page data corresponding to the target document, including but not limited to a server cluster, a computing cloud server cluster, etc. In some embodiments, the server 502 may perform any suitable function. For example, in some embodiments, the server 502 may receive a page data request sent by the user device 506 to return the corresponding page data to the user device 506 for the user to view.

[0112] In some embodiments, the communication network 504 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 504 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN) and / or any other suitable communication network. The user device 506 can be connected to the communication network 504 via one or more communication links (e.g., communication link 512), and the communication network 504 can be linked to the server 502 via one or more communication links (e.g., communication link 514). The communication link can be any communication link suitable for transmitting data between the user device 406 and the server 502, such as a network link, a dial-up link, a wireless link, a hard-wired link, any other suitable communication link or any suitable combination of such links.

[0113] User equipment 506 may include any one or more user equipment suitable for data processing. In some embodiments, user equipment 506 may include any suitable type of equipment. For example, in some embodiments, user equipment 506 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, and / or any other suitable type of user equipment.

[0114] Reference Figure 6 , Figure 6 FIG. 1 is a flowchart of another data processing method according to an embodiment of the present application. The data processing method provided in the embodiment of the present application can be Figure 5 The server 502 in the system shown in the figure executes. Specifically, the data processing method provided in this embodiment includes the following steps:

[0115] Step 602: Send a page data acquisition request for the target document to the server device.

[0116] Specifically, when a user wants to preview a target document, a page data acquisition request may be sent to a server device through a client device to acquire page data for page display from the server device.

[0117] Step 604: Receive the original page data returned by the server device, and display the target text page based on the original page data.

[0118] Step 606, extract text from the target text page to obtain text content information and text attribute information of each text in the target text page; perform scalable vector graphics rendering based on the text content information and text attribute information of each text to obtain a text editing area.

[0119] Step 608 , in response to the text editing operation in the text editing area, updating the rendering result in the text editing area, and displaying the edited text in the text editing area.

[0120] Step 610, generating edited text layout information in the text editing area according to the updated rendering result, and sending the edited text layout information to the server device, so that the server device updates the original page data based on the edited text layout information and saves the updated page data.

[0121] Specifically, in this step, the edited text layout information generated in the text editing area can represent the layout of the texts contained in the text editing area. After obtaining the above-mentioned edited text layout information, the information can be sent to the server device. The server device can then write back and save the original page data according to the above-mentioned edited text layout information.

[0122] The above process introduces edited text layout information to record the page layout change information brought about by the text editing operation, so that the server-side device can quickly and accurately obtain the modified page data matching the text editing operation.

[0123] Optionally, in some of the embodiments, after obtaining the text content information and text attribute information of each text in the target text page, the method further includes:

[0124] Analyze the text content information and text attribute information of each text to generate text layout information in the target text page;

[0125] Generate the edited text layout information in the text editing area according to the updated rendering result, including:

[0126] According to the updated rendering result, the text layout information in the target text page is modified to obtain the edited text layout information.

[0127] Specifically, in the above embodiment of the present application, before the text editing operation, the text layout information in the target text page is first generated from the macro level of the target text page by analyzing the text content information and the text attribute information. Afterwards, based on the text editing operation and the corresponding updated rendering result, the above text layout information is adaptively modified to obtain the edited text layout information, so that the subsequent server-side device can write back and save the original page data according to the edited text layout information. The above process introduces the text layout information corresponding to the macro level of the target text page to record the page layout change process brought about by the text editing operation, so that the modified page data matching the text editing operation can be quickly and accurately obtained.

[0128] Optionally, in some of the embodiments, after sending the edited text layout information to the server device, the method further includes:

[0129] Sending a page data acquisition request for a target document to a server device;

[0130] Receive the updated page data returned by the server device, and display the target text page based on the updated page data.

[0131] Specifically, after receiving the edited text layout information, the server device can modify the original page data according to the edited text layout information, thereby obtaining updated page data updated by the user's editing operation. Afterwards, when the client device sends a page data acquisition request to the server device again, the server device can return the updated page data to the client device to display the edited target text page to the user.

[0132] In the embodiment of the present application, after extracting the text content information and text attribute information of each text in the target text page, from the perspective of upper-level application development, a text editing area is provided by rendering a scalable vector graphics corresponding to the text, so that the user can perform text editing operations in the area; then, according to the editing operation, the rendering result is updated from a visual level to show the user the effect of the edited target text page, and the page data is modified according to the updated rendering result, so as to save the page edited by the user for the next page display. Compared with the solution in the related art that realizes text editing by modifying the underlying source code of the existing open source rendering library, the embodiment of the present application realizes text editing from the upper-level architecture level through scalable vector graphics rendering, and does not involve modification and processing of the underlying source code. Therefore, the complexity of the solution implementation and the development cost are relatively low, and the online service of the text editing function can be completed in a relatively short development time.

[0133] The specific implementation of each step in the data processing method of this embodiment can refer to the description of the corresponding part in the aforementioned method embodiment 1, and will not be repeated here.

[0134] Figure 7 The data processing device provided in the embodiment of the present application includes:

[0135] The text extraction module 702 is used to extract text from the target text page during the display process of the target text page, and obtain the text content information and text attribute information of each text in the target text page;

[0136] The rendering module 704 is used to render a scalable vector map based on the text content information and text attribute information of each text to obtain a text editing area; the text editing area displays the scalable vector map corresponding to each text in the target text page;

[0137] The editing module 706 is used to update the rendering result in the text editing area in response to the text editing operation in the text editing area, display the edited text in the text editing area, and modify the original page data corresponding to the target text page based on the updated rendering result.

[0138] Optionally, in some of the embodiments, the data processing device further includes:

[0139] A text layout information generating module is used to analyze the text content information and text attribute information of each text in the target text page after obtaining the text content information and text attribute information of each text, and generate the text layout information in the target text page;

[0140] Correspondingly, when the editing module 706 executes the step of modifying the original page data corresponding to the target text page based on the updated rendering result, it is specifically used to: modify the text layout information in the target text page based on the updated rendering result, obtain the edited text layout information for the target text page, and modify the original page data corresponding to the target text page according to the edited text layout information.

[0141] Optionally, in some of the embodiments, the text layout information generating module is specifically used to: analyze the text content information and text attribute information of each text, split the target text page into multiple text blocks, and obtain the text layout information in each text block;

[0142] The rendering module 704 is specifically used to: determine a text block to be edited from multiple text blocks in response to a text block selection operation; perform scalable vector graphics rendering in the text block to be edited based on text layout information in the text block to be edited to obtain a text editing area;

[0143] The editing module 706, when executing the step of modifying the text layout information in the target text page based on the updated rendering result to obtain the edited text layout information for the target text page, is specifically used to: modify the text layout information in the text block to be edited based on the updated rendering result to obtain the edited text layout information for the text block to be edited.

[0144] Optionally, in some of the embodiments, the text attribute information includes: text glyph information, text font information and text boundary information;

[0145] The rendering module 704 is specifically used to: create a background overlay layer; convert the scalable vector image information corresponding to each text based on the text content information and text font information of each text; determine the rendering area of ​​each text in the background overlay layer according to the text font information and text boundary information of each text; perform scalable vector image rendering in the background overlay layer according to the scalable vector image information corresponding to each text and the rendering area of ​​each text in the background overlay layer to obtain a text editing area.

[0146] Optionally, in some of the embodiments, the editing module 706, when executing the step of updating the rendering result in the text editing area in response to the text editing operation in the text editing area, is specifically used to: determine the editing position information of the text to be edited in response to the text editing operation in the text editing area; and update the rendering result in the text editing area according to the editing position information of the text to be edited.

[0147] Optionally, in some of the embodiments, the text editing operation is a text adding operation, and the editing module 706, when executing the step of determining the editing position information of the text to be edited in response to the text editing operation in the text editing area, is specifically used to: determine the text adding position of the text to be added in response to the text adding operation in the text editing area;

[0148] The editing module 706, when executing the step of updating the rendering result in the text editing area according to the editing position information of the text to be edited, is specifically used to: determine the text font information of the text to be added according to the text font information of the text located in the same preset area as the text adding position; perform the text rendering operation to be added at the text adding position according to the text font information of the text to be added, so as to update the rendering result in the text editing area.

[0149] Optionally, in some of the embodiments, the text editing operation is a text deletion operation, and the editing module 706, when executing the step of determining the editing position information of the text to be edited in response to the text editing operation in the text editing area, is specifically used to: determine the text to be deleted and the text position information of the text to be deleted in response to the text deletion operation in the text editing area;

[0150] The editing module 706, when executing the step of updating the rendering result in the text editing area according to the editing position information of the text to be edited, is specifically used for: removing the text to be deleted from each text according to the text position information of the text to be deleted, so as to obtain the retained text; based on the text content information and text attribute information of each retained text, re-rendering the scalable vector graphics corresponding to each retained text to update the rendering result in the text editing area.

[0151] Optionally, in some of the embodiments, the text layout information generation module, when executing the step of analyzing the text content information and text attribute information of each text to split the target text page into multiple text blocks, is specifically used to: analyze the text attribute information of each text to divide each text into multiple text lines; and for the multiple text lines obtained by the division, split the multiple text lines into multiple text blocks according to the size relationship between the line spacing value between adjacent text lines and a preset line spacing threshold.

[0152] Optionally, in some of the embodiments, the text layout information generation module, when executing the step of analyzing the text attribute information of each text and dividing each text into multiple text lines, is specifically used to: divide texts with the same text vertical coordinate into a candidate text line; and split the candidate text line into multiple text lines based on the relationship between the text spacing value between adjacent texts in the candidate text line and a preset text spacing threshold.

[0153] Optionally, in some of the embodiments, the target text page is a portable document format page; the text extraction module 702, when executing the step of extracting text from the target text page to obtain text content information and text attribute information of each text in the target text page, is specifically used to: use an open source rendering library for portable document format pages to perform text parsing on the target text page, and extract text content information and text attribute information of each text in the target text page.

[0154] The data processing device of this embodiment is used to implement the corresponding data processing method in the above-mentioned embodiment 1, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here. In addition, the functional implementation of each module in the data processing device of this embodiment can refer to the description of the corresponding part in the above-mentioned method embodiment 1, which will not be described in detail here.

[0155] Figure 8 The data processing device provided in the embodiment of the present application is applied to a client device, including:

[0156] The request sending module 802 is used to send a page data acquisition request for a target document to a server device;

[0157] The page display module 804 is used to receive the original page data returned by the server device and display the target text page based on the original page data;

[0158] The text editing area obtaining module 806 is used to extract text from the target text page to obtain text content information and text attribute information of each text in the target text page; based on the text content information and text attribute information of each text, scalable vector graphics rendering is performed to obtain a text editing area;

[0159] A rendering result updating module 808, for updating the rendering result in the text editing area in response to the text editing operation in the text editing area, and displaying the edited text in the text editing area;

[0160] The layout information sending module 810 is used to generate edited text layout information in the text editing area according to the updated rendering result, and send the edited text layout information to the server device, so that the server device updates the original page data based on the edited text layout information and saves the updated page data.

[0161] Optionally, in some of the embodiments, the layout information generating module is used to analyze the text content information and text attribute information of each text in the target text page after obtaining the text content information and text attribute information of each text in the target text page, and generate the text layout information in the target text page;

[0162] Correspondingly, when executing the step of generating edited text layout information in the text editing area according to the updated rendering result, the layout information sending module 810 is specifically used to modify the text layout information in the target text page according to the updated rendering result to obtain the edited text layout information.

[0163] Optionally, in some of the embodiments, the request sending module 802 is also used to: after sending the edited text layout information to the server device, send a page data acquisition request for the target document to the server device again; correspondingly, the page display module 804 is also used to: receive the updated page data returned by the server device, and display the target text page based on the updated page data.

[0164] The data processing device of this embodiment is used to implement the corresponding data processing method in the aforementioned embodiment 2, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here. In addition, the functional implementation of each module in the data processing device of this embodiment can refer to the description of the corresponding part in the aforementioned method embodiment 2, which will not be described in detail here.

[0165] Embodiment 5

[0166] Reference Fig. 9 , shows a schematic diagram of the structure of an electronic device according to Embodiment 5 of the present application. The specific embodiments of the present application do not limit the specific implementation of the electronic device.

[0167] like Fig. 9 As shown, the electronic device may include: a processor (processor) 902 , a communication interface (Communications Interface) 904 , a memory (memory) 906 , and a communication bus 908 .

[0168] in:

[0169] The processor 902 , the communication interface 904 , and the memory 906 communicate with each other via a communication bus 908 .

[0170] The communication interface 904 is used to communicate with other electronic devices or servers.

[0171] The processor 902 is used to execute the program 910, and specifically can execute the relevant steps in the above method embodiment.

[0172] Specifically, the program 910 may include program codes, which include computer operation instructions.

[0173] The processor 902 may be a CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.

[0174] The memory 906 is used to store the program 910. The memory 906 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0175] The program 910 may include multiple computer instructions. Specifically, the program 910 may enable the processor 902 to execute operations corresponding to the method described in any of the aforementioned method embodiments through the multiple computer instructions.

[0176] The specific implementation of each step in program 910 can refer to the corresponding description of the corresponding steps and units in the above method embodiment, and has corresponding beneficial effects, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above method embodiment, which will not be repeated here.

[0177] The present application also provides a computer storage medium on which a computer program is stored, and when the program is executed by a processor, the method described in any of the above-mentioned multiple method embodiments is implemented. The computer storage medium includes but is not limited to: a compact disc read-only memory (CD-ROM), a random access memory (RAM), a floppy disk, a hard disk or a magneto-optical disk, etc.

[0178] An embodiment of the present application also provides a computer program product, including computer instructions, which instruct a computing device to execute operations corresponding to any one of the above-mentioned multiple method embodiments.

[0179] In addition, it should be noted that the user-related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to sample data used to train the model, data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0180] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.

[0181] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD-ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor or programmable or dedicated hardware (such as an application-specific integrated circuit (ASIC) or a field programmable gate array (FPGA)). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., a random access memory (RAM), a read-only memory (ROM), a flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown here, the execution of the code converts the general-purpose computer into a dedicated computer for executing the method shown here.

[0182] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.

[0183] The above implementation methods are only used to illustrate the embodiments of the present application, and are not limitations on the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application should be limited by the claims.

Claims

1. A data processing method, comprising: During the display of the target text page, text extraction is performed on the target text page to obtain text content information and text attribute information of each text in the target text page; Based on the text content information and text attribute information of each text, a scalable vector graphics rendering is performed to obtain a text editing area; the text editing area displays the scalable vector graphics corresponding to each text in the target text page; In response to a text editing operation in the text editing area, a rendering result in the text editing area is updated, the edited text is displayed in the text editing area, and original page data corresponding to the target text page is modified based on the updated rendering result.

2. The method according to claim 1, wherein: After obtaining the text content information and text attribute information of each text in the target text page, the method further includes: Analyzing the text content information and text attribute information of each text to generate text layout information in the target text page; The modifying the original page data corresponding to the target text page based on the updated rendering result includes: Based on the updated rendering result, the text layout information in the target text page is modified to obtain the edited text layout information for the target text page, and the original page data corresponding to the target text page is modified according to the edited text layout information.

3. The method according to claim 2, wherein: The analyzing the text content information and text attribute information of each text to generate the text layout information in the target text page includes: Analyzing the text content information and text attribute information of each text, splitting the target text page into multiple text blocks, and obtaining text layout information in each text block; The scalable vector graphics rendering is performed based on the text content information and text attribute information of each text to obtain a text editing area, including: In response to a text block selection operation, determining a text block to be edited from the multiple text blocks; Based on the text layout information in the text block to be edited, performing scalable vector graphics rendering in the text block to be edited to obtain a text editing area; The step of modifying the text layout information in the target text page based on the updated rendering result to obtain the edited text layout information for the target text page includes: Based on the updated rendering result, the text layout information in the text block to be edited is modified to obtain the edited text layout information for the text block to be edited.

4. The method according to claim 1, wherein: The text attribute information includes: text font information, text font information and text boundary information; The scalable vector graphics rendering is performed based on the text content information and text attribute information of each text to obtain a text editing area, including: Create a background overlay; Based on the text content information and text font information of each text, convert and obtain scalable vector graphics information corresponding to each text; Determine a rendering area of ​​each text in the background overlay layer according to text font information and text boundary information of each text; According to the scalable vector graphics information corresponding to each text and the rendering area of ​​each text in the background overlay layer, the scalable vector graphics rendering is performed in the background overlay layer to obtain a text editing area.

5. The method according to any one of claims 1 to 4, wherein: The updating of the rendering result in the text editing area in response to the text editing operation in the text editing area includes: In response to a text editing operation in the text editing area, determining editing position information of the text to be edited; According to the editing position information of the text to be edited, the rendering result in the text editing area is updated.

6. The method according to claim 5, wherein: The text editing operation is a text adding operation, and the determining of the editing position information of the to-be-edited text in response to the text editing operation in the text editing area includes: In response to a text adding operation in the text editing area, determining a text adding position of the text to be added; The updating of the rendering result in the text editing area according to the editing position information of the text to be edited includes: Determining the text font information of the text to be added according to the text font information of the text located in the same preset area as the text adding position; According to the text font information of the text to be added, a rendering operation of the text to be added is performed at the text adding position to update the rendering result in the text editing area.

7. A data processing method, applied to a client device, the method comprising: Sending a page data acquisition request for a target document to a server device; Receive the original page data returned by the server device, and display the target text page based on the original page data; Performing text extraction on the target text page to obtain text content information and text attribute information of each text in the target text page; performing scalable vector graphics rendering based on the text content information and text attribute information of each text to obtain a text editing area; In response to a text editing operation in the text editing area, updating a rendering result in the text editing area, and displaying edited text in the text editing area; According to the updated rendering result, the edited text layout information in the text editing area is generated, and the edited text layout information is sent to the server device, so that the server device updates the original page data based on the edited text layout information and saves the updated page data.

8. An electronic device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method according to any one of claims 1 to 7.

9. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. A computer program product, comprising computer instructions, wherein the computer instructions instruct a computing device to perform operations corresponding to the method according to any one of claims 1 to 7.