Multi-dimensional comparison method and device of PDF document and electronic equipment

By performing multi-dimensional comparison of PDF documents, including analysis and comparison of areas such as text, images, tables and mathematical formulas, the problem of ignoring multi-dimensional differences in the existing technology is solved, and high-precision and high-efficiency document comparison is achieved.

CN119514518AActive Publication Date: 2025-02-25BEIJING RENHE HUIZHI INFORMATION TECH CO LTD

Patent Information

Application Number
CN202510090485.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-21
Publication Date
2025-02-25
Estimated Expiration
2045-01-21

AI Technical Summary

Technical Problem

The existing PDF document comparison technology mainly focuses on text content, ignoring the differences in multiple dimensions such as images, tables, mathematical formulas, paragraph layout, fonts and page structure, resulting in the possibility of neglecting key changes in complex document processing, especially in high-demand scenarios such as legal document review, academic paper version control, and contract review.

Method used

Provide a multi-dimensional comparison method for PDF documents. By dividing PDF documents into multiple object areas, including text areas, image areas, table areas and mathematical formula areas, these areas are parsed and compared, differential information is determined, and the difference type and index information are synchronized in the document.

Benefits of technology

It realizes comprehensive, accurate and automated comparison of PDF documents, improves the accuracy and efficiency of document processing, and can meet the needs of complex application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119514518A_ABST
    Figure CN119514518A_ABST
Patent Text Reader

Abstract

The invention provides a multi-dimensional comparison method and device for PDF documents and electronic equipment, and the method comprises the steps: dividing a first PDF document and a second PDF document which are to be compared into a plurality of object regions; analyzing the plurality of object areas to obtain object contents to be compared; aiming at each piece of first object content in the first PDF document, determining that the first object content corresponds to second object content to be compared in a second PDF document; comparing the first object content with the second object content to determine difference information; synchronously marking the difference type and the index information of the difference information in the first PDF document and the second PDF document. According to the method and the device, differences of contents of multiple dimensions of texts, images, tables and formulas in the two PDF documents can be comprehensively, accurately and automatically compared and marked, so that the accuracy and the efficiency of document processing are improved, and the requirements of complex application scenes are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of document processing technology, and in particular to a multi-dimensional comparison method, device and electronic device for PDF documents. Background Art

[0002] As PDF (Portable Document Format) becomes the mainstream document format and is widely used in academia, law, business and other fields, the importance of document version management and difference detection has become increasingly prominent. However, existing PDF document comparison technology mainly focuses on text content, ignoring multi-dimensional differences such as images, tables, mathematical formulas, paragraph layout, fonts and page structure. This limitation often leads to key changes being ignored when processing complex documents, especially in high-demand scenarios such as legal document review, academic paper version control, and contract review, which may lead to serious consequences.

[0003] Existing technologies are inefficient and inaccurate when it comes to large-scale document comparison tasks, and cannot meet the high standards of modern document processing. Manual review of documents is not only time-consuming and labor-intensive, but also prone to errors and low accuracy. Summary of the invention

[0004] The purpose of this application is to provide a multi-dimensional comparison method, device and electronic device for PDF documents, which can comprehensively, accurately and automatically compare and mark the differences in multiple dimensions of content such as text, images, tables and formulas in two PDF documents, improve the accuracy and efficiency of document processing, and meet the needs of complex application scenarios.

[0005] In a first aspect, the present application provides a multi-dimensional comparison method for PDF documents, the method comprising: for a first PDF document and a second PDF document to be compared, both are divided into multiple object areas; the multiple object areas include at least one of the following: a text area, an image area, a table area, and a mathematical formula area; the multiple object areas are parsed to obtain object contents to be compared; for each first object content in the first PDF document, it is determined that the first object content corresponds to a second object content to be compared in the second PDF document; the first object content and the second object content are compared to determine difference information; in the first PDF document and the second PDF document, the difference type and index information of the difference information are synchronously marked.

[0006] Furthermore, the above-mentioned step of parsing multiple object areas to obtain the object content to be compared includes: for the text area, extracting the text content in the text area; for adjacent text contents distributed in different columns or across pages, merging the text contents when they are judged to be the same paragraph to obtain the text content to be compared.

[0007] Furthermore, the step of determining that the first object content corresponds to the second object content to be compared in the second PDF document includes: determining, according to the first position information of the first object content in the first PDF document, the target object content at the position corresponding to the first position information in the second PDF document; taking the target object content as a reference, extending forward and backward a specified number of region contents of the same object type respectively; calculating the similarity between the first object content and the plurality of region contents, and taking the region content corresponding to the highest similarity as the second object content to be compared in the second PDF document corresponding to the first object content.

[0008] Furthermore, the above-mentioned step of comparing the first object content and the second object content to determine the difference information includes: for the two text contents to be compared, performing the following text content difference analysis steps: dividing the two text contents according to character units; comparing the character units of the two text contents one by one, and calculating the minimum edit distance between the two text contents; the minimum edit distance is characterized by the minimum number of editing operations required to convert one text into another text; the operations include inserting characters, deleting characters, and replacing characters; after comparing all character units, obtaining a sequence of editing operations from one text content to another text content; and determining the difference information of the two text contents based on the editing operation sequence.

[0009] Furthermore, the above-mentioned step of determining the difference information of the two text contents according to the editing operation sequence includes: if the editing operation type of the target comparison segment is inserting characters, determining the difference type of the target comparison segment as an inserting segment type; and merging multiple consecutive comparison segments of the inserting segment type to determine a first difference area; if the editing operation type of the target comparison segment is deleting characters, determining the difference type of the target comparison segment as a deleting segment type; and merging multiple consecutive comparison segments of the deleting segment type to determine a second difference area; if the difference type of the target comparison segment is the same segment type, comparing the font, font size and glyph of the text of the target comparison segment, and marking the same segment type for the target comparison segment.

[0010] Furthermore, the above-mentioned step of comparing the first object content and the second object content to determine the difference information includes: for the two images to be compared, normalizing the size and resolution of the two images respectively; traversing each pixel at the same position in the two images; for each pixel, comparing the values ​​of the four channels of red, green, blue and transparency respectively; if there is a difference in the value of any channel, marking the pixel as different; after traversing all the pixels, counting the number of difference pixels between the two images; based on the number of difference pixels, determining the similarity of the two images; merging continuous difference pixels to determine the difference area.

[0011] Furthermore, the above-mentioned step of comparing the first object content and the second object content to determine the difference information includes: for the two formulas to be compared, obtaining formula character information corresponding to the two formulas; aligning according to the Y coordinate of the formula character information to make the vertical order of the two formula character information consistent; sorting the two formula character information according to the X coordinate, and combining the formula characters into corresponding formula text strings; performing a text content difference analysis step on the formula text string to determine the difference area and the difference type.

[0012] Furthermore, the above-mentioned step of comparing the first object content and the second object content to determine the difference information includes: for the two tables to be compared, obtaining the text content in the two tables; splicing the text content in the order of rows and / or columns to obtain a spliced ​​text string; performing a text content difference analysis step on the text string to determine the difference area and difference type.

[0013] In a second aspect, the present application also provides a multi-dimensional comparison device for PDF documents, the device comprising: a document division module, for dividing a first PDF document and a second PDF document to be compared into multiple object areas; the multiple object areas include at least one of the following: a text area, an image area, a table area, and a mathematical formula area; a region parsing module, for parsing the multiple object areas to obtain object contents to be compared; a comparison content determination module, for determining, for each first object content in the first PDF document, that the first object content corresponds to a second object content to be compared in the second PDF document; a difference determination module, for comparing the first object content and the second object content to determine difference information; and a difference marking module, for synchronously marking the difference type and index information of the difference information in the first PDF document and the second PDF document.

[0014] In a third aspect, the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method described in the first aspect above.

[0015] In the multi-dimensional comparison method, device and electronic device of PDF documents provided by the present application, the first PDF document and the second PDF document to be compared are divided into multiple object areas; the multiple object areas include at least one of the following: text area, image area, table area and mathematical formula area; the multiple object areas are parsed to obtain the object content to be compared; for each first object content in the first PDF document, it is determined that the first object content corresponds to the second object content to be compared in the second PDF document; the first object content and the second object content are compared to determine the difference information; in the first PDF document and the second PDF document, the difference type and index information of the difference information are synchronously marked. The present application can comprehensively, accurately and automatically compare and mark the differences in the content of multiple dimensions of text, images, tables and formulas in two PDF documents, improve the accuracy and efficiency of document processing, and meet the needs of complex application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0017] Figure 1 A flowchart of a multi-dimensional comparison method of PDF documents provided in an embodiment of the present application; Figure 2 A schematic diagram of PDF document area division provided in an embodiment of the present application; Figure 3 A structural block diagram of a multi-dimensional comparison device for PDF documents provided in an embodiment of the present application; Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0018] The technical solution of the present application will be described clearly and completely below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0019] In view of the problems of low efficiency and insufficient precision in the prior art when facing large-scale document comparison tasks, and the problem that manual review of documents is not only time-consuming and labor-intensive, but also prone to errors and low accuracy, the embodiments of the present application provide a multi-dimensional PDF content comparison method, covering comprehensive analysis of text, images, tables, mathematical formulas, paragraph layout, fonts and page structure, and is suitable for document version management, difference detection and content review, such as legal documents, academic papers, contracts, etc., which require accurate identification of changes.

[0020] To facilitate understanding of this embodiment, a multi-dimensional PDF content comparison method disclosed in an embodiment of the present application is first introduced in detail. Figure 1 A flowchart of a multi-dimensional comparison method of a PDF document provided in an embodiment of the present application, the method specifically comprises the following steps: Step S102, dividing the first PDF document and the second PDF document to be compared into a plurality of object areas; the plurality of object areas include at least one of the following: a text area, an image area, a table area, and a mathematical formula area; A fine-tuned layout language model LayoutLM is used to perform preliminary layout analysis and segmentation on PDF documents. LayoutLM is a large language model based on deep learning, which is specifically used to understand the layout and content structure of documents. Through the LayoutLM model, PDF documents are divided into multiple coarse-grained areas, including text areas, image areas, table areas, and mathematical formula areas. Each area retains its position coordinate information on the page to ensure the accuracy of subsequent processing.

[0021] Step S104, parsing multiple object regions to obtain the object contents to be compared; For each divided object area, the specific content in the object area is extracted based on its coordinate information on the page. The text area is extracted and merged to obtain the text content to be compared; the table area is parsed to obtain the table to be compared; the image area is parsed to obtain the image to be compared; the formula area is parsed to obtain the formula to be compared.

[0022] Step S106, for each first object content in the first PDF document, determining whether the first object content corresponds to a second object content to be compared in the second PDF document; This step is to complete the matching of the comparison objects. For each object content in the first document, the corresponding object content to be compared must be found in the second document. Here, a comparison range and similarity threshold can be set, for example, the second object content to be compared with the first object content is the one with the highest similarity among the adjacent specified objects of the same type.

[0023] Step S108, comparing the first object content and the second object content to determine difference information; In this step, a comparison is actually performed on the elements in the specific object content to accurately determine the differences between the two documents.

[0024] Step S110 : synchronously marking the difference type and index information of the difference information in the first PDF document and the second PDF document.

[0025] By synchronizing the marking of difference information, a comprehensive difference report can be generated in the end, detailing all changes in the document.

[0026] In the multi-dimensional comparison method of PDF documents provided by the present application, the first PDF document and the second PDF document to be compared are divided into multiple object areas; the multiple object areas include at least one of the following: text area, image area, table area and mathematical formula area; the multiple object areas are parsed to obtain the object content to be compared; for each first object content in the first PDF document, it is determined that the first object content corresponds to the second object content to be compared in the second PDF document; the first object content and the second object content are compared to determine the difference information; in the first PDF document and the second PDF document, the difference type and index information of the difference information are synchronously marked. The present application can comprehensively, accurately and automatically compare and mark the differences in the content of multiple dimensions of text, images, tables and formulas in two PDF documents, improve the accuracy and efficiency of document processing, and meet the needs of complex application scenarios.

[0027] The embodiment of the present application also provides another multi-dimensional comparison method of PDF documents, which is implemented on the basis of the above embodiment; this embodiment focuses on describing the region parsing process, the comparison object matching process, and the difference analysis process in each dimension.

[0028] (1) Regional analysis process: like Figure 2 As shown, after the PDF document is divided into multiple object areas, the object area parsing process is further performed: For the text area, the text content in the text area is extracted; for adjacent text content distributed in different columns or across pages, the text content is merged when it is determined to be the same paragraph to obtain the text content to be compared.

[0029] In specific implementation, for text areas, content extraction includes obtaining character information, font type, font size information, and other related text attributes. According to the font size of the extracted characters and their floating distance relative to the baseline, it is determined whether the characters are superscripts and subscripts. Among them, characters with smaller font sizes and obvious floating up and down positions are usually identified as superscripts and subscripts. By analyzing the thickness and tilt angle of the text, it is determined whether the text is bold or italic. Specifically, by detecting the thickness and tilt of the character outline, bold characters and italic characters are identified and marked. This step ensures that the content information extracted from the PDF document not only accurately reflects the characters and basic attributes of the text, but also includes more detailed style information, such as superscripts and subscripts, bold, italics, etc., which lays the foundation for accurate comparison and analysis of documents.

[0030] Then, regional correction and merging are performed: for adjacent text regions distributed in different columns, the preset rules and natural language processing technology are used to determine whether these regions belong to the same paragraph. If so, these text region blocks are regionally corrected and merged. For adjacent text region blocks across pages, rules and natural language technology are also used to analyze whether they belong to the same paragraph or sentence, and then merge them. This step ensures that the integrity of the paragraph is maintained when the document content is split across pages or multiple columns.

[0031] Generate structured content representation for the merged and corrected region blocks, and output comprehensive information data including content text, style, location coordinates and region type. These data will serve as the basis for subsequent content comparison and analysis.

[0032] (2) Object matching process: That is, the step of determining that the first object content corresponds to the second object content to be compared in the second PDF document includes: According to the first position information of the first object content in the first PDF document, the target object content at the position corresponding to the first position information in the second PDF document is determined; based on the target object content, a specified number of regional contents of the same object type are respectively extended forward and backward; the similarity between the first object content and the plurality of regional contents is calculated, and the regional content corresponding to the highest similarity is used as the second object content to be compared in the second PDF document corresponding to the first object content.

[0033] In this embodiment, according to the results of the above layout analysis and content parsing, the object areas in the PDF document are classified into corresponding comparison object types for one-by-one matching, and these objects include text paragraphs, tables, images, etc. The specific process is as follows: (2.1) Text paragraph comparison and matching: Before performing text paragraph comparison, the text is first normalized. This includes unifying half-width and full-width punctuation marks and removing unnecessary blank characters. The purpose of this step is to ensure the consistency of the text content in form, thereby improving the accuracy of similarity calculation. After the normalization process is completed, the text content is matched for similarity. The similarity is evaluated by calculating the cosine similarity between each pair of text paragraphs. Cosine similarity measures the similarity between two paragraphs by representing the text as a vector and calculating the cosine value of the angle between the vectors. The higher the score, the more similar the content of the two paragraphs is.

[0034] (2.2) Table matching: Perform structured analysis on the table area blocks to extract information such as the table rows, columns, cell contents and their locations. Extract the text content in each cell row by row, and completely splice these text contents in row order to form a spliced ​​text string representing the entire table. This splicing process retains the content order and structural characteristics of the table, ensuring that the overall consistency of the table content can be reflected during the comparison. Calculate the similarity of the spliced ​​text content. Use a cosine similarity calculation method similar to text paragraph comparison to evaluate the similarity of the text content of two tables. By comparing the similarity of the spliced ​​text strings, the similarities and differences of the table contents can be effectively judged.

[0035] (2.3) Image matching: First, the size and resolution of the two images to be compared are normalized. This may include scaling or cropping the images to ensure that the two images have the same size; it may also include adjusting the resolution of the images to ensure that the two images are compared under the same standard. Then, traverse each pixel of the image and compare the pixel values ​​of the two images at the same position one by one. For each pixel, compare the values ​​of its four channels: red, green, blue, and transparency. If there is a difference in the value of any channel, the pixel is marked as different. After completing the comparison of all pixels, the difference information between the two images is counted, and the image similarity percentage is calculated based on the number of pixels marked as different. The higher the similarity percentage, the closer the content of the two images is.

[0036] (2.4) Matching strategy and threshold setting: To avoid deviation or omission of matching results, set the matching span threshold, which is set to 20 regions by default. That is, during the comparison process, each match is allowed to find the matching object with the highest similarity in the 20 adjacent regions before and after. When matching objects, if the similarity is less than 60%, these contents are considered to be newly added. In actual applications, the threshold can be adjusted according to the complexity of the document and user needs to optimize the matching effect.

[0037] (3) Difference analysis process of each dimension: (3.1) Text content comparison: For two text contents to be compared, the following text content difference analysis steps are performed: the two text contents are divided into character units; the character units of the two text contents are compared one by one, and the minimum edit distance between the two text contents is calculated; the minimum edit distance is characterized by the minimum number of editing operations required to convert one text into another text; the operations include inserting characters, deleting characters, and replacing characters; after comparing all character units, a sequence of editing operations from one text content to another is obtained; and the difference information of the two text contents is determined according to the editing operation sequence.

[0038] Furthermore, the above-mentioned step of determining the difference information of the two text contents according to the editing operation sequence includes: if the editing operation type of the target comparison segment is inserting characters, determining the difference type of the target comparison segment as an inserting segment type; and merging multiple consecutive comparison segments of the inserting segment type to determine a first difference area; if the editing operation type of the target comparison segment is deleting characters, determining the difference type of the target comparison segment as a deleting segment type; and merging multiple consecutive comparison segments of the deleting segment type to determine a second difference area; if the difference type of the target comparison segment is the same segment type, comparing the font, font size and glyph of the text of the target comparison segment, and marking the same segment type for the target comparison segment.

[0039] In the specific implementation, first, the input text is divided into character units. Each character unit can be a letter, number, symbol or other special character. Then, an optimized dynamic programming method is used to calculate the minimum edit distance between the character units of the two texts by comparing them one by one, which represents the minimum number of operations required to convert one text into another. These operations include inserting characters, deleting characters, and replacing characters. Each step in the dynamic programming records the minimum number of edit operations required to reach the current character position. By backtracking these steps, the specific sequence of edit operations from one text to another can be determined.

[0040] The fragments of the comparison results can be divided into three categories: "insertion", "deletion" and "identical". For "identical" fragments, it is necessary to further compare the font, font size and glyph information of the text block to ensure the consistency of the text style. For "insertion" and "deletion" fragments, they are merged and split according to their position information in the document, and continuous adjacent text blocks of the same difference type are merged and spliced ​​into complete difference areas, and the difference types of these areas are recorded in detail (insertion, deletion or the same text content but different style). In this way, the difference areas between texts can be accurately identified and recorded, providing accurate and detailed difference information for subsequent document processing and analysis.

[0041] (3.2) Image comparison: For the two images to be compared, the size and resolution of the two images are normalized respectively; each pixel at the same position in the two images is traversed; for each pixel, the values ​​of the four channels of red, green, blue and transparency are compared respectively; if there is a difference in the value of any channel, the pixel is marked as different; after traversing all the pixels, the number of difference pixels between the two images is counted; based on the number of difference pixels, the similarity of the two images is determined; and continuous difference pixels are merged to determine the difference area.

[0042] The difference in resolution or size of images may affect the comparison results, so the size and resolution of the images need to be unified.

[0043] Unify resolution: If the resolutions of the two images are different, select the smaller resolution of the two images as the reference resolution and adjust the other image to the reference resolution. This can preserve all the original image information and avoid blurring and distortion caused by interpolating and enlarging the smaller image. At the same time, a smaller resolution means less calculation and higher image comparison efficiency.

[0044] Unify the size: First compare the aspect ratio of the two images. If the aspect ratio of the two images is the same, use the smaller size as a reference and scale the size of the other image in the same proportion. If the aspect ratio of the two images is inconsistent, crop the larger image to keep the aspect ratio consistent with the smaller image.

[0045] In image difference comparison, the difference between two images is identified in detail by comparing each pixel one by one. First, each pixel position of the image is traversed and the values ​​of the corresponding pixels in the four channels of red, green, blue and transparency are compared. For pixels with inconsistent values ​​in any channel, their position information is recorded to capture the difference points in the image.

[0046] Then, these difference points are processed, and continuous difference pixels are merged to form a complete difference area. At the same time, these difference areas can be marked on the image so that the differences between the images can be displayed intuitively. This method can accurately locate and display subtle differences in images and is suitable for application scenarios that require high-precision image comparison.

[0047] (3.3) Formula comparison: For two formulas to be compared, formula character information corresponding to the two formulas is obtained; the formula character information is aligned according to the Y coordinate so that the vertical order of the two formula character information is consistent; the two formula character information is sorted according to the X coordinate, and the formula characters are combined into corresponding formula text strings; and a text content difference analysis step is performed on the formula text string to determine the difference area and the difference type.

[0048] When processing character information in mathematical formulas, the characters are first sorted according to their Y coordinates to ensure that the vertical order of the text is consistent. In the case of the same Y coordinate, the characters are further sorted by X coordinate to combine these characters into corresponding formula text strings. Then, these formula text strings are compared using the above text content difference comparison algorithm to accurately identify the differences between formulas.

[0049] (3.4) Table comparison: For two tables to be compared, the text contents in the two tables are obtained; the text contents are spliced ​​in the order of rows and / or columns to obtain a spliced ​​text string; and a text content difference analysis step is performed on the text string to determine the difference area and the difference type.

[0050] When performing table difference comparison, the table is first sorted according to its structure, with rows as the first sorting rule and columns as the second sorting rule, and the text content of each cell is spliced. The spliced ​​text content is then compared using the above text difference comparison algorithm to identify and record the differences between the table contents. This method ensures accuracy in table comparison, so that text, formulas, and table contents can all be comprehensively and accurately analyzed for differences.

[0051] (4) Differential marking: In the process of recording text difference information, the index position of each difference segment in the corresponding comparison text can be recorded at the same time. Through these index positions, the specific difference areas in the text blocks or images in the original PDF document can be accurately located, and the corresponding difference areas can be found in the comparison PDF document. For each identified difference area, the difference in the same position in the two documents or images can be clearly displayed through bidirectional mapping. In addition, the difference area is synchronously located and marked in the two documents or images. When the user views a difference area in one document or image, the corresponding area in the other document or image is automatically located and highlighted. This bidirectional positioning method ensures that users can quickly and accurately identify and analyze the differences in documents or images, so as to more intuitively understand the difference between the two.

[0052] The multi-dimensional comparison method of PDF documents provided in the embodiment of the present application first parses the PDF document to be compared and extracts content information of each dimension; then, different algorithms are used to accurately compare elements such as text, images, tables, mathematical formulas, and the differences in paragraph layout, font changes, and page structure are analyzed; finally, a comprehensive difference report is generated, which details all changes in the document.

[0053] Based on the above method embodiment, the present application embodiment also provides a multi-dimensional comparison device for PDF documents, see Figure 3 As shown, the apparatus includes: a document division module 302, which is used to divide the first PDF document and the second PDF document to be compared into multiple object areas; the multiple object areas include at least one of the following: a text area, an image area, a table area, and a mathematical formula area; a region parsing module 304, which is used to parse the multiple object areas to obtain the object content to be compared; a comparison content determination module 306, which is used to determine, for each first object content in the first PDF document, that the first object content corresponds to the second object content to be compared in the second PDF document; a difference determination module 308, which is used to compare the first object content and the second object content to determine the difference information; and a difference marking module 310, which is used to synchronously mark the difference type and index information of the difference information in the first PDF document and the second PDF document.

[0054] Furthermore, the region analysis module 304 is used to extract text content in a text region; for adjacent text content distributed in different columns or across pages, the text content is merged when it is determined to be the same paragraph to obtain text content to be compared.

[0055] Furthermore, the comparison content determination module 306 is used to determine the target object content at the position corresponding to the first position information of the first object content in the first PDF document; based on the target object content, expand the region content of the same object type forward and backward respectively; calculate the similarity between the first object content and the plurality of region contents, and use the region content corresponding to the highest similarity as the second object content to be compared in the second PDF document corresponding to the first object content.

[0056] Furthermore, the above-mentioned difference determination module 308 is used to perform the following text content difference analysis steps for the two text contents to be compared: divide the two text contents into character units; compare the character units of the two text contents one by one, and calculate the minimum editing distance between the two text contents; the minimum editing distance is characterized by the minimum number of editing operations required to convert one text into another text; the operations include inserting characters, deleting characters, and replacing characters; after comparing all character units, obtain a sequence of editing operations from one text content to another text content; determine the difference information of the two text contents based on the editing operation sequence.

[0057] Furthermore, the above-mentioned difference determination module 308 is used to determine that the difference type of the target comparison segment is an insertion segment type if the editing operation type of the target comparison segment is inserting characters; and merge multiple consecutive comparison segments of the insertion segment type to determine a first difference area; if the editing operation type of the target comparison segment is deleting characters, determine that the difference type of the target comparison segment is a deletion segment type; and merge multiple consecutive comparison segments of the deletion segment type to determine a second difference area; if the difference type of the target comparison segment is the same segment type, compare the font, font size and glyph of the text of the target comparison segment, and mark the same segment type for the target comparison segment.

[0058] Furthermore, the above-mentioned difference determination module 308 is used to normalize the size and resolution of the two images to be compared; traverse each pixel at the same position in the two images; for each pixel, compare the values ​​of the four channels of red, green, blue and transparency respectively; if there is a difference in the value of any channel, the pixel is marked as different; after traversing all the pixels, count the number of difference pixels between the two images; determine the similarity of the two images based on the number of difference pixels; merge continuous difference pixels to determine the difference area.

[0059] Furthermore, the above-mentioned difference determination module 308 is used to obtain formula character information corresponding to two formulas to be compared; align the formula character information according to the Y coordinate to make the vertical order of the two formula character information consistent; sort the two formula character information according to the X coordinate, and combine the formula characters into corresponding formula text strings; perform a text content difference analysis step on the formula text string to determine the difference area and difference type.

[0060] Furthermore, the above-mentioned difference determination module 308 is used to obtain the text content in the two tables to be compared; splice the text content in the order of rows and / or columns to obtain a spliced ​​text string; and perform a text content difference analysis step on the text string to determine the difference area and difference type.

[0061] The device provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the embodiment of the device, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0062] The present application also provides an electronic device, such as Figure 4 As shown, it is a schematic diagram of the structure of the electronic device, wherein the electronic device includes a processor 41 and a memory 40, the memory 40 stores computer executable instructions that can be executed by the processor 41, and the processor 41 executes the computer executable instructions to implement the above method.

[0063] exist Figure 4 In the illustrated embodiment, the electronic device further includes a bus 42 and a communication interface 43 , wherein the processor 41 , the communication interface 43 and the memory 40 are connected via the bus 42 .

[0064] Among them, the memory 40 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 43 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 42 can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 42 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0065] The processor 41 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 41. The above processor 41 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor 41 reads the information in the memory and completes the steps of the method of the above embodiment in combination with its hardware.

[0066] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above method. The specific implementation can be found in the aforementioned method embodiment, which will not be repeated here.

[0067] The computer program products of the methods, devices, and electronic devices provided in the embodiments of the present application include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.

[0068] Unless otherwise specifically stated, the relative steps, numerical expressions and values ​​of the components and steps set forth in these embodiments do not limit the scope of the present application.

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

[0070] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present application. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0071] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A multi-dimensional comparison method for PDF documents, characterized in that: The method comprises: The first PDF document and the second PDF document to be compared are divided into a plurality of object areas; the plurality of object areas include at least one of the following: a text area, an image area, a table area, and a mathematical formula area; Parse multiple object regions to obtain the contents of the objects to be compared; For each first object content in the first PDF document, determining that the first object content corresponds to a second object content to be compared in the second PDF document; Comparing the first object content with the second object content to determine difference information; In the first PDF document and the second PDF document, the difference type and index information of the difference information are synchronously marked.

2. The method according to claim 1, characterized in that The step of parsing multiple object regions to obtain the contents of the objects to be compared includes: For a text area, the text content in the text area is extracted; for adjacent text contents distributed in different columns or across pages, the text contents are merged when they are determined to be the same paragraph to obtain the text content to be compared.

3. The method according to claim 1, characterized in that The step of determining that the first object content corresponds to the second object content to be compared in the second PDF document includes: According to first position information of the first object content in the first PDF document, determining target object content at a position corresponding to the first position information in the second PDF document; Taking the target object content as a reference, expanding the content of a specified number of regions of the same object type forward and backward respectively; The similarities between the first object content and a plurality of region contents are calculated, and the region content corresponding to the highest similarity is used as the second object content to be compared in the second PDF document corresponding to the first object content.

4. The method according to claim 1, characterized in that: The step of comparing the first object content and the second object content to determine difference information includes: For the two text contents to be compared, perform the following text content difference analysis steps: Split the two text contents into character units; Compare the character units of the two text contents one by one, and calculate the minimum edit distance between the two text contents; the minimum edit distance is characterized by the minimum number of editing operations required to convert one text into another text; the operations include inserting characters, deleting characters, and replacing characters; After all character units are compared, an editing operation sequence from one text content to another text content is obtained; and difference information of the two text contents is determined according to the editing operation sequence.

5. The method according to claim 4, characterized in that The step of determining difference information of two text contents according to the editing operation sequence comprises: If the editing operation type of the target comparison segment is inserting a character, determining the difference type of the target comparison segment is an insert segment type; and merging a plurality of consecutive comparison segments of the insert segment type to determine a first difference region; If the editing operation type of the target comparison segment is to delete characters, determining the difference type of the target comparison segment is a deletion segment type; and merging a plurality of consecutive comparison segments of the deletion segment type to determine a second difference region; If the difference type of the target comparison segment is the same segment type, the font, font size and font style of the text of the target comparison segment are compared, and the same segment type is marked for the target comparison segment.

6. The method according to claim 1, characterized in that The step of comparing the first object content and the second object content to determine difference information includes: For the two images to be compared, normalize the size and resolution of the two images respectively; Traverse each pixel at the same position in the two images; for each pixel, compare the values ​​of the four channels of red, green, blue and transparency respectively; if there is a difference in the value of any channel, mark the pixel as different; after traversing all pixels, count the number of difference pixels between the two images; based on the number of difference pixels, determine the similarity of the two images; merge continuous difference pixels to determine the difference area.

7. The method according to claim 4, characterized in that The step of comparing the first object content and the second object content to determine difference information includes: For two formulas to be compared, formula character information corresponding to the two formulas is obtained; the formula character information is aligned according to the Y coordinates so that the vertical order of the two formula character information is consistent; the two formula character information is sorted according to the X coordinates, and the formula characters are combined into a corresponding formula text string; The text content difference analysis step is performed on the formula text string to determine the difference area and the difference type.

8. The method according to claim 4, characterized in that The step of comparing the first object content and the second object content to determine difference information includes: For two tables to be compared, obtain text contents in the two tables; concatenate the text contents in the order of rows and / or columns to obtain a concatenated text string; The text content difference analysis step is performed on the text string to determine the difference area and the difference type.

9. A multi-dimensional comparison device for PDF documents, characterized in that: The device comprises: A document division module is used to divide the first PDF document and the second PDF document to be compared into a plurality of object areas; the plurality of object areas include at least one of the following: a text area, an image area, a table area, and a mathematical formula area; A region analysis module is used to analyze multiple object regions to obtain the content of the object to be compared; A comparison content determination module, configured to determine, for each first object content in the first PDF document, whether the first object content corresponds to a second object content to be compared in the second PDF document; a difference determination module, configured to compare the first object content with the second object content to determine difference information; The difference marking module is used to synchronously mark the difference type and index information of the difference information in the first PDF document and the second PDF document.

10. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Self-duplicate-checking method for typeset document content based on teaching aid book publishing

    CN111563372A

  • Document comparison analysis method and system based on table structure analysis

    CN114021543A

  • Document comparison method and device, equipment and medium

    CN115937888A

  • Document comparison method and device, equipment and medium

    CN115937891A

  • PDF (Portable Document Format) document processing method and device, equipment and medium

    CN117173729A

Cited By

  • Electronic document difference analysis method, system and equipment and storage medium

    CN120087354A

  • Engineering drawing content difference identification method and device, equipment and storage medium

    CN120748002A

  • Automatic data comparison method and device, terminal equipment and storage medium

    CN121456012A