PDF (Portable Document Format) file cross-software sequence processing method and device and related medium
By performing structured parsing, logical structure reconstruction, and consistency marking on PDF files, the problem of inconsistent logical structure and layout styles when PDF files are transferred between different software is solved, achieving stable cross-platform transfer and editing.
Patent Information
- Application Number
- CN202511788848.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-01
- Publication Date
- 2026-02-17
AI Technical Summary
In existing technologies, PDF files cannot maintain consistency in logical structure and layout style when transferred between different software, making it difficult to completely and accurately describe structured and style information such as text, paragraphs, fonts, colors, line spacing, and hierarchical relationships when exchanging data across platforms.
By performing structured parsing on PDF files, a set of page object data is generated, non-text objects are filtered out, the logical structure is reconstructed, intermediate format serialization and deserialization are performed, and a version control data set is generated by combining consistency tags and reversibility control to achieve incremental updates.
Ensuring consistency in logical structure and layout style when transferring PDF files between different software improves the reliability of cross-platform editing and rendering, reduces data processing overhead, and enhances the efficiency of collaborative editing and version management.
Smart Images

Figure CN121543546A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, and related media for cross-software sequence processing of PDF files. Background Technology
[0002] In existing technologies, although PDF is widely used as a cross-platform document standard, its internal storage method, based on page drawing instructions and independent primitives, means that text, paragraphs, tables, etc., exist only as planar objects, lacking a stable logical semantic layer. Current cross-platform data exchange methods mainly rely on the conversion of PDF to formats such as HTML, XML, and RTF, or proprietary formats of various vendors. This process typically only roughly preserves the page layout appearance, making it difficult to fully and accurately describe the structured and style information such as text, paragraphs, fonts, colors, line spacing, and hierarchical relationships within a unified cross-software intermediate format. Furthermore, it lacks a reversible deserialization mechanism to match this intermediate format, resulting in a lack of consistency in logical structure and layout style when the same PDF file is transferred and edited between different software. Summary of the Invention
[0003] This invention provides a method, apparatus, and related medium for processing PDF files across software sequences, aiming to solve the technical problem in the prior art that the same PDF file cannot maintain consistency in logical structure and layout style when transferred between different software.
[0004] In a first aspect, embodiments of the present invention provide a method for processing PDF files across software sequences, including: The PDF file to be processed is subjected to structured parsing to obtain a set of page object data; The page object data set is subjected to non-text filtering to obtain the text object data set; The logical structure is reconstructed using the aforementioned text object data set to obtain the paragraph structure data set; The paragraph structure data set is serialized into an intermediate format to obtain a cross-software intermediate representation data set. The target paragraph data set is obtained by deserializing the cross-software intermediate representation data set. The target paragraph data set is subjected to consistency marking and reversibility control processing respectively to obtain the version control data set; Incremental updates are performed on the version control data set to generate the target PDF file processing result.
[0005] Secondly, embodiments of the present invention provide a PDF file cross-software sequence processing apparatus, comprising: The file parsing unit is used to perform structured parsing on the PDF file to be processed, and obtain a set of page object data. A data filtering unit is used to perform non-text filtering on the page object data set to obtain a text object data set. The logical reconstruction unit is used to reconstruct the logical structure using the text object data set to obtain the paragraph structure data set. The format processing unit is used to perform intermediate format serialization processing on the paragraph structure data set to obtain a cross-software intermediate representation data set. A sequence processing unit is used to perform deserialization processing on the cross-software intermediate representation data set to obtain a target paragraph data set. The data alignment unit is used to perform consistency marking and reversibility control processing on the target paragraph data set to obtain a version control data set. The incremental update unit is used to incrementally update the version control data set to generate the target processing result of the PDF file.
[0006] Thirdly, embodiments of the present invention provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the PDF file cross-software sequence processing method of the first aspect.
[0007] Fourthly, embodiments of the present invention provide a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, it implements the PDF file cross-software sequence processing method of the first aspect.
[0008] This invention provides a method for cross-software serial processing of PDF files, including: performing structured parsing on the PDF file to obtain a page object data set; performing non-text filtering on the page object data set to obtain a text object data set; reconstructing the logical structure using the text object data set to obtain a paragraph structure data set; performing intermediate format serialization on the paragraph structure data set to obtain a cross-software intermediate representation data set; performing deserialization on the cross-software intermediate representation data set to obtain a target paragraph data set; performing consistency marking and reversibility control processing on the target paragraph data set to obtain a version control data set; and incrementally updating the version control data set to generate the target PDF file processing result. This invention, by performing consistency marking and reversibility control processing on the calculated target paragraph data set to obtain a version control data set, and then incrementally updating the version control data set, ensures that the same PDF file maintains consistency in logical structure and layout style when transferred between different software.
[0009] This invention also provides a PDF file cross-software sequence processing apparatus, computer device, and storage medium, which have the same beneficial effects as described above. Attached Figure Description
[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 A flowchart illustrating a method for processing PDF files across software sequences, provided in an embodiment of the present invention; Figure 2 This is a schematic block diagram of a PDF file cross-software sequence processing device provided in an embodiment of the present invention. Detailed Implementation
[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0013] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0014] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0015] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0016] Please see below. Figure 1 , Figure 1 The flowchart of a PDF file cross-software sequence processing method provided in an embodiment of the present invention specifically includes steps S101 to S107.
[0017] S101. Perform structured parsing on the PDF file to be processed to obtain a set of page object data; S102. Perform non-text filtering on the page object data set to obtain a text object data set; S103. Reconstruct the logical structure using the text object data set to obtain the paragraph structure data set; S104. Perform intermediate format serialization processing on the paragraph structure data set to obtain a cross-software intermediate representation data set; S105. Perform deserialization processing on the cross-software intermediate representation data set to obtain the target paragraph data set; S106. Perform consistency marking and reversibility control processing on the target paragraph data set respectively to obtain the version control data set; S107. Incrementally update the version control data set to generate the target processing result of the PDF file.
[0018] In step S101, the PDF file to be processed is subjected to structured parsing. By reading the page content and identifying page objects such as text, images, and vector paths, and combining the coordinates, fonts, and layout attributes of the objects, the various objects are organized according to the page dimensions to obtain a set of page object data.
[0019] In one embodiment, step S101 includes: The PDF file to be processed is read and processed to obtain the page content stream data; The page content stream data is processed for object recognition to extract an initial object data set; By performing attribute parsing processing on the text objects in the initial object data set, a text position data set is obtained; The layout attributes of the text position data set are extracted to obtain the text attribute data set; The text attribute data set and the initial object data set are aggregated and organized to generate a page object data set.
[0020] In this embodiment, the PDF file to be processed undergoes content stream reading processing. The underlying parsing engine is invoked to sequentially traverse and parse the content stream of the PDF pages. The drawing instructions, resource references, and primitive descriptions of each page are loaded into memory in the order of their appearance, resulting in page content stream data containing all drawing instructions for that page. After obtaining the page content stream data, object recognition processing is performed. Based on PDF syntax, the drawing instructions in the content stream are classified and parsed, identifying text primitive objects, image primitive objects, vector path primitive objects, and form primitive objects, etc. Each object is assigned an object type, object identifier, and corresponding original data fragment, thereby extracting an initial object data set.
[0021] Furthermore, in the initial object data set, text objects related to the text content are selected. Combining the transformation instructions for text drawing in the PDF, the text transformation matrix parameters carried by the text objects are parsed to obtain a text position data set that represents the absolute position of characters or glyphs on the page. This text position data set includes at least the page coordinates, rotation angle, and scaling ratio calculated from the parameters in the text transformation matrix. After obtaining the text position data set, the layout attribute extraction process is further performed on the text position data set. The font description information, font subset identifier, font size, font weight, italic style attributes, foreground color, character width, line spacing, character spacing, and other layout-related parameters associated with the text objects are parsed and collected to form a text attribute data set that describes the text layout and style characteristics.
[0022] Furthermore, the text attribute data set and the initial object data set are aggregated and organized. On the one hand, text objects, image objects, vector path objects and form objects are uniformly merged at the page dimension. On the other hand, the text position and layout attributes corresponding to each text object are associated and stored according to the object identifier, thereby generating a page object data set containing all page objects and their layout information. This provides complete and structured basic data for subsequent non-text filtering, logical structure reconstruction and intermediate format serialization.
[0023] In step S102, based on information such as the spatial distribution, font features, transparency, and object type of the page object data set, non-text objects such as text and watermarks located in the header and footer areas are identified and filtered, and only objects related to the main text content are retained, thus obtaining the main text object data set for subsequent analysis.
[0024] In one embodiment, step S102 includes: The page object data set is parsed to determine the page height region, resulting in a page region division result. Based on the page region division results, the target region is marked with headers and footers to obtain a set of candidate header and footer objects. A threshold determination is performed on the text objects in the header and footer candidate object set to obtain the watermark candidate object set; By combining the watermark candidate object set with color space distribution, transparency and coordinate expansion range, abnormal watermarks are determined, and a text body candidate object set is obtained. The text body candidate object set and the page object data set are filtered by object type to obtain the main text object data set.
[0025] In this embodiment, the boundary coordinates of each page object in the page object data set are parsed, and the page height is calculated by combining the page's media frame and clipping frame information. Based on this, the page height area is divided according to a preset ratio. The first 5% of the page height is defined as the top area, the last 10% as the bottom area, and the rest as the middle area, resulting in the page area division. After completing the area division, text-type page objects falling into the top and bottom areas are uniformly marked and classified as suspected headers or footers, resulting in a set of candidate header / footer objects for subsequent filtering and judgment.
[0026] Furthermore, the font size, font name, transparency, and other layout attributes of each text object are extracted from the header and footer candidate object set. A threshold judgment is performed on each text object. When the font size of the text object is detected to be less than or equal to the preset threshold of 8 points, or its transparency is less than 0.3, the text object is marked as a watermark candidate object, and the watermark candidate object set is obtained. For abnormal watermarks with a large coverage area and light color but whose font size may not meet the above simple threshold conditions, a comprehensive judgment can be made based on the above set by combining the color space distribution characteristics, transparency distribution, and extension range on the page coordinate plane of the object. Text objects that meet the abnormal watermark characteristics are also included in the watermark candidate object set, so as to identify various forms of watermark objects as completely as possible.
[0027] After watermark determination, text objects not marked as headers, footers, or watermarks are uniformly included in the text body candidate object set as candidate content for subsequent text extraction. Then, the text body candidate object set and the original page object data set are subjected to object type filtering. In this process, only text objects are retained, while non-text objects such as image objects, vector path objects, and form objects are uniformly removed. This results in a text object data set containing only text-related objects, providing clean and reliable input data for subsequent logical structure reconstruction.
[0028] In step S103, based on the layout features such as the baseline position, line spacing, and horizontal projection relationship of the text object data set, character-level objects are aggregated into lines, and then lines are aggregated into paragraphs. The corresponding font styles, colors, and hierarchical information are recorded to complete the logical structure reconstruction and obtain the paragraph structure data set.
[0029] In one embodiment, step S103 includes: The text object data set is parsed at the character level to obtain a character object data set; The character object data set is aggregated to obtain the line object data set; The adjacent line spacing and horizontal projection overlap are calculated for the row object data set to obtain the paragraph block object data set. The paragraph block object data set is processed to record attributes, resulting in a paragraph attribute data set. Based on the paragraph attribute data set, a globally unique identifier is assigned to each paragraph, line, and character to generate a paragraph structure data set.
[0030] In this embodiment, based on the obtained text object data set, the text objects are parsed at the character level. The string content carried in each text drawing instruction is split into characters. Combining the baseline information, Y coordinate, character spacing and corresponding font parameters of the text object, a character-level data structure is constructed. For each character, information such as its page, the baseline position of the line, the coordinates of the character's bounding rectangle, the horizontal spacing between characters and the glyph index is recorded, thereby generating a character object data set and realizing a refined character-level representation of the text area.
[0031] After obtaining the character object data set, the data set is aggregated. Characters are sorted by page and line number, and the baseline position and Y-coordinate of the characters are used as the aggregation criteria. Adjacent characters whose baseline height difference is within the allowable deviation range (e.g., ±2pt) and whose horizontal spacing does not exceed a preset threshold are automatically grouped into the same line. A corresponding line object is then generated for each line. For each line object, attributes such as the start and end coordinates, line height, number of characters in the line, main font, and font size are recorded, resulting in a line object data set. Then, for the line object data set, the line spacing between adjacent lines is calculated according to the vertical order of the lines on the page. Combined with the line height of each line, it is determined whether the line spacing between two lines is less than or equal to 1.2 times the maximum line height. Simultaneously, the circumscribed rectangles of two adjacent lines in the horizontal direction are projected onto the X-axis, and the ratio of the projection overlap length to the joint projection length is calculated. When the X-projection overlap is greater than or equal to 70%, the two lines are considered to have high continuity in the horizontal layout. For adjacent lines that simultaneously meet the conditions of line spacing and X-projection overlap, they are merged into the same paragraph block, gradually forming a series of paragraph block objects within the page, constituting a paragraph block object data set, thereby completing the initial aggregation from line-level structure to paragraph-level structure.
[0032] After obtaining the paragraph block object data set, attribute recording processing is performed on each paragraph block object. This involves extracting and summarizing layout and content attributes related to the paragraph, such as font family, font size distribution, font weight (e.g., bold), italic style, foreground color, background color information, paragraph alignment (e.g., left alignment, center alignment), first-line indentation, paragraph spacing, line spacing type, and the paragraph's position on the page (including the paragraph's bounding rectangle, page number, and column information). This results in a paragraph attribute data set. Simultaneously, the text content within the paragraph is sequentially concatenated and standardized for encoding and storage, facilitating subsequent intermediate format serialization and retrieval.
[0033] Furthermore, based on the aforementioned paragraph attribute data set, a globally unique identifier is assigned to each paragraph, line, and character, preferably using a UUID (Universally Unique Identifier) mechanism. This ensures that references to the same paragraph, line, or character within the same document remain stable and consistent across different processing stages and software environments. Specifically, a paragraph-level UUID is generated for each paragraph object, a line-level UUID for each line object, and a character-level UUID for each character object. Simultaneously, style metadata such as bold, italics, and underline, along with their association with the UUID, is stored in the corresponding object structure. Through this identifier allocation and attribute recording process, a paragraph structure data set is ultimately constructed, with paragraphs at the core and lines and characters as hierarchical nodes. This provides a complete and traceable logical structural foundation for subsequent intermediate format serialization, consistency verification, and version control.
[0034] In step S104, the paragraph structure data set is serialized according to a preset intermediate format, and the paragraph hierarchy, layout parameters and style information are uniformly encapsulated into a cross-software intermediate representation for transmission and sharing between different applications, thus obtaining a cross-software intermediate representation data set.
[0035] In one embodiment, step S104 includes: Each paragraph and line in the paragraph structure data set is mapped to a first intermediate markup format and a second intermediate markup format, respectively, while retaining the font, font size, color, style, level, position, and globally unique identifier, to obtain the basic markup structure data set; Based on the paragraph nodes that have changed in the basic tag structure data set, update tags are generated, and each paragraph is mapped to a paragraph class tag or an inline tag to obtain the incremental tag structure data set. The incremental marker structure data set is subjected to font feature statistical processing to obtain a font identifier mapping data set; The font identifier mapping data set is subjected to attribute expansion processing to obtain an extended marker structure data set; The extended tag structure data set is subjected to cross-software intermediate encapsulation processing to generate a cross-software intermediate representation data set.
[0036] In this embodiment, for each paragraph object and line object in the paragraph structure data set, they are mapped to a first intermediate markup format and a second intermediate markup format according to a preset intermediate markup specification. The first intermediate markup format preferably uses a JSON structure for structured storage and program access within the software, while the second intermediate markup format preferably uses HTML markup language for cross-software display and interaction. During this mapping process, the font family, font size, color, weight, and italic styles, hierarchical structure (e.g., paragraph hierarchy and nesting relationships), position on the page or canvas, and the globally unique identifier (UUID) assigned to the paragraph, line, and characters in the preceding steps are extracted and preserved one by one. The paragraph node is serialized into a JSON object, and simultaneously mapped to HTML. tag, mapping a row or intra-row segment to Inline tags are used to generate a basic tag structure data set containing structural and style metadata. Based on this, to support efficient document updates during editing, modified paragraph nodes in the basic tag structure data set are traversed and identified. Update tags are generated only for modified nodes, organizing them into an intermediate tag structure in incremental patch form. The updated tags are then applied at the HTML level. or The label replaces or supplements the original node to obtain an incremental markup structure data set containing only the changed part, and realizes incremental serialization instead of whole-page rewriting.
[0037] Further, the incremental markup structure data set is subjected to font feature statistical processing, a unique font hash identification FontHash is generated according to the font name, font weight, italic attribute, character set support range and other features of each font, and a mapping relationship between FontHash and the original font description is established to obtain a font identification mapping data set for font matching and fallback between different software or different running environments; after obtaining the font identification mapping data set, attribute extension processing can also be performed according to application requirements, additional information related to collaborative editing and intelligent processing is also included in the mapping relationship, such as additional attributes of annotations, hyperlinks, AI tags and the like for paragraph or line nodes, and these additional attributes are associated with the corresponding UUID and FontHash to construct an extended markup structure data set containing structure information, style information, font mapping information and additional semantic information; finally, the extended markup structure data set is packaged according to a preset cross-software intermediate packaging specification, the structure description in JSON format, the visual markup in HTML format, the FontHash font mapping table and the incremental Patch information are organized into a unified cross-software intermediate representation data set, and metadata such as version number and timestamp is added, so that the intermediate representation can be stably transmitted and parsed between software of different manufacturers, thereby providing a unified data basis for subsequent deserialization reconstruction, consistency checking and collaborative editing.
[0038] In step S105, the target end reconstructs the hierarchical relationship between paragraphs, lines and characters and the page layout according to the markup information in the cross-software intermediate representation data set in combination with local font resources, and generates a target paragraph data set that can be rendered and edited in the target environment.
[0039] In an embodiment, the step S105 includes: reconstructing the hierarchical relationship of paragraphs, lines and characters according to the markup information in the cross-software intermediate representation data set to obtain a paragraph reconstruction data set; performing information matching in the target local font library by using the paragraph reconstruction data set to obtain a target paragraph initial data set; performing layout recovery processing on the target paragraph initial data set to obtain a target paragraph data set.
[0040] In this embodiment, the target end receives the cross-software intermediate representation data set generated by step S104, performs syntax analysis on the JSON / HTML mark data therein, identifies the paragraph-level tags (for example ), inline tags (e.g.) ) and the text nodes corresponding to the character sequence, combined with the hierarchical mark, the sequential index and the globally unique identifier UUID carried therein, the parent-child association between the nodes is reconstructed in the tree relationship of paragraphs, lines and characters in turn, and a paragraph reconstruction data set is generated to describe the logical structure of the document, so that each character can be traced back to the line object and the paragraph object to which it belongs.
[0041] After completing the logical level reconstruction, the font description information related to the font, such as FontHash, font name (fontfamily), font weight, italic, etc., is extracted from the paragraph reconstruction data set, and a matching process is initiated in the local font library of the target end. The local font resource corresponding to the source font is preferentially found according to FontHash, and when FontHash matching fails, the closest substitute font is selected in the local font library according to the font name and its attributes. If it still cannot be matched, a preset fallback font (fallbackfont) is enabled, so as to determine the actual font used in the target end environment for each paragraph, line and character, and obtain a target paragraph initial data set containing text content and local font information.
[0042] Further, based on the original layout parameters recorded in the target paragraph initial data set, the layout recovery processing is performed on the objects at all levels: on the one hand, the display position of each character in the target page coordinate system is recalculated according to the character absolute position, baseline information and line height parameters carried in the intermediate representation, and the line height of the line object is recovered; on the other hand, according to the layout information such as paragraph-level pre-paragraph and post-paragraph spacing, alignment mode and first-line indentation, the vertical spacing between paragraphs and the indentation structure are recovered, and the position and association relationship of the additional objects such as annotations, hyperlinks associated with paragraphs or lines are also added synchronously, so as to construct a target paragraph data set in the target end which not only maintains the original format characteristics but also can be rendered or edited.
[0043] In step S106, consistency marking and reversibility control processing is performed on the target paragraph data set, and identification and check information is established for the related objects, which is used to record the structure and style state, and support the subsequent undo and redo operations, and a version control data set is obtained.
[0044] In an embodiment, the step S106 comprises: The target paragraph data set is used for identification binding processing, and a paragraph style mark data set is obtained; The paragraph style mark data set is subjected to style feature hash calculation processing, and a consistency mark data set is obtained; When the target paragraph data set is subjected to deserialization reconstruction, consistency check is performed according to the consistency mark data set, and a check result data set is obtained; Based on the verification result data set, version snapshot generation and differential calculation processing are performed to obtain snapshot and differential data sets; Based on the snapshot and differential data sets, undo and redo operations are performed on the target paragraph data set to generate a version control data set.
[0045] In this embodiment, based on the obtained target paragraph data set, each paragraph, line, and character object is identified and bound. That is, a globally unique identifier (UUID) is assigned to each level of object, and during the binding process, the font family, font size, color, line spacing, character spacing, and style information such as bold and italics associated with the object are recorded simultaneously. The above UUID and style attributes are organized together into a paragraph style mark data set. On this basis, the paragraph style mark data set is processed by style feature hash calculation. The key style parameters such as font, font size, color, line spacing, and character spacing are encoded in a preset order and input into the hash function to generate a StyleHash (style hash value) to represent the style state of the object. Thus, a consistent mark data set with "UUID + StyleHash" tuple as the core is obtained, which provides an accurate structure and style fingerprint for subsequent consistency verification.
[0046] When performing a second deserialization and reconstruction on the target paragraph data set, the StyleHash for the current moment is first regenerated based on the reconstructed paragraphs, lines, and characters. Then, the hashes are compared one by one with the existing consistency marker data set according to the UUID. If the two hashes are consistent, and a UUID exists but the corresponding StyleHash is inconsistent, it is considered that the object has changed in structure or style. This forms a verification result data set for marking consistency, partial inconsistency, or missing states. Based on this verification result data set, version snapshot generation and differential calculation are performed on the current document state: on the one hand, at critical editing moments or when a preset time interval is reached, the target paragraph data set is organized into a complete state archive according to UUID, generating a version snapshot; on the other hand, based on the differences in UUID and StyleHash between adjacent snapshots and between the snapshot and the current state, a differential algorithm is used to extract newly added, deleted, and modified objects, resulting in a fine-grained snapshot and differential data set. Finally, when a user initiates an undo or redo operation, or when version rollback or version comparison is required, the system replays or reverses the corresponding differential operation according to the snapshot and differential data set in a time sequence. This restores the target paragraph data set to the previous version or several previous versions, or redoes the undone editing actions, thereby generating a version control data set that records the evolution relationship of each version and the history of reversible operations. This achieves a consistency verification and reversibility control mechanism based on UUID and StyleHash.
[0047] In step S107, when a document undergoes partial modification or is in a collaborative editing scenario, differential analysis is performed on the changed content based on the version control data set. Incremental data is generated only for the updated part and applied to the target document, thereby outputting the updated PDF file target processing result, realizing the structured representation and continuous and consistent editing processing of PDF files across different software.
[0048] Specifically, in scenarios involving partial document modification or collaborative editing, the system first identifies the set of nodes with content or style changes by comparing the UUID and StyleHash recorded in the version control dataset with the latest state of the target paragraph dataset. Each modified paragraph, line, or character object is marked as a node to be updated. Then, a corresponding incremental patch structure is generated for each node to be updated. Each incremental patch includes at least the operation type (insertion, deletion, replacement, etc.), the UUID of the target object, a summary of the content and style before and after the change, and metadata such as timestamps and editing sources. By generating patches for each modified node, only the differences from the previous version are recorded, avoiding a full rewrite of the entire document, thus forming an incremental patch sequence to drive document updates. After generating the incremental patch sequence, it is associated with and stored in the aforementioned version control dataset. During document synchronization or saving, the incremental patches are transmitted or applied first, allowing other collaborative terminals or persistent storage to reconstruct a document state consistent with the current editing terminal based solely on the patches, thereby improving synchronization efficiency and reducing data transfer volume.
[0049] Simultaneously, a patch stack or patch linked list is maintained in chronological order. By predefining reverse operations for each patch, users can apply the corresponding patches sequentially or in reverse order when performing Undo / Redo operations, achieving differential rollback and redo. This ensures data consistency during the editing process and supports on-demand rollback to historical versions. When the final document needs to be output, the system applies all valid incremental patches based on the current version control data set, cumulatively updating the target paragraph data set to reflect the latest editing results. Based on this, it calls the aforementioned intermediate format serialization and PDF rendering generation process to repackage and format the updated structured content, obtaining a PDF file target processing result that corresponds one-to-one with the latest version status.
[0050] In summary, this application utilizes structured parsing of PDF content streams, cross-software intermediate format serialization and deserialization reconstruction, and consistency verification technologies for unique identifiers and style signatures. It constructs a page object tree, including text objects, image objects, and vector path objects, by parsing the PDF content stream. This accurately obtains parameters such as character content, font resources (FontDescriptor), text matrix, and color space (ColorSpace). It then calculates the absolute coordinates, rotation angles, and scaling ratios of characters using matrix parameters (a, b, c, d, e, f). Based on this, it organizes objects according to the logical hierarchy of page, paragraph, line, and character, filtering out non-text elements such as watermarks, headers, and footers. Furthermore, it converts this object tree into a cross-software intermediate format such as JSON or HTML, encapsulating each node with UUID, FontHash, and metadata such as content, style, and coordinates, preserving complete hierarchical relationships and layout constraints. It also supports incremental patch serialization and extended attributes such as annotations, hyperlinks, and AI editing tags. On the target side, the object tree is reconstructed based on the aforementioned intermediate format. A locally available font is selected using UUID mapping and FontHash matching mechanisms. The original layout is then restored by combining stored absolute coordinates, line height, and paragraph spacing, achieving a unified presentation across desktop, web, and mobile devices. Simultaneously, globally unique identifiers are bound to paragraphs, lines, and characters, and StyleHashes are generated for font, size, color, line spacing, bold / italic styles, etc. After deserialization, the UUID and StyleHash are compared for reversibility verification and conflict resolution. Therefore, this application not only ensures a high degree of consistency in the structure and style of PDF documents during transmission and editing across different software, significantly improving the reliability of cross-platform editing and rendering, but also reduces data processing overhead through incremental serialization and differential updates, improving the efficiency of collaborative editing and version management. It solves problems such as structural information loss, difficulty in unifying styles, and irreversible reconstruction across software in existing technologies.
[0051] Combination Figure 2 As shown, Figure 2 This is a schematic block diagram of a PDF file cross-software sequence processing device 200 provided in an embodiment of the present invention. The PDF file cross-software sequence processing device 200 includes: The file parsing unit 201 is used to perform structured parsing processing on the PDF file to be processed, and obtain a set of page object data. Data filtering unit 202 is used to perform non-text filtering processing on the page object data set to obtain a text object data set; The logical reconstruction unit 203 is used to reconstruct the logical structure using the text object data set to obtain a paragraph structure data set. Format processing unit 204 is used to perform intermediate format serialization processing on the paragraph structure data set to obtain a cross-software intermediate representation data set; Sequence processing unit 205 is used to perform deserialization processing on the cross-software intermediate representation data set to obtain a target paragraph data set; The data alignment unit 206 is used to perform consistency marking and reversibility control processing on the target paragraph data set respectively to obtain a version control data set; The incremental update unit 207 is used to incrementally update the version control data set to generate the target processing result of the PDF file.
[0052] In this embodiment, the file parsing unit 201 performs structured parsing on the PDF file to be processed, obtaining a set of page object data; the data filtering unit 202 performs non-text filtering on the set of page object data, obtaining a set of text object data; the logic reconstruction unit 203 uses the set of text object data to reconstruct the logical structure, obtaining a set of paragraph structure data; the format processing unit 204 performs intermediate format serialization on the set of paragraph structure data, obtaining a cross-software intermediate representation data set; the sequence processing unit 205 performs deserialization on the set of cross-software intermediate representation data, obtaining a target paragraph data set; the data alignment unit 206 performs consistency marking and reversibility control processing on the target paragraph data set, respectively, obtaining a version control data set; and the incremental update unit 207 performs incremental updates on the version control data set to generate the target PDF file processing result.
[0053] In one embodiment, the file parsing unit 201 is specifically used for: The PDF file to be processed is read and processed to obtain the page content stream data; The page content stream data is processed for object recognition to extract an initial object data set; By performing attribute parsing processing on the text objects in the initial object data set, a text position data set is obtained; The layout attributes of the text position data set are extracted to obtain the text attribute data set; The text attribute data set and the initial object data set are aggregated and organized to generate a page object data set.
[0054] In one embodiment, the data filtering unit 202 is specifically used for: The page object data set is parsed to determine the page height region, resulting in a page region division result. Based on the page region division results, the target region is marked with headers and footers to obtain a set of candidate header and footer objects. A threshold determination is performed on the text objects in the header and footer candidate object set to obtain the watermark candidate object set; By combining the watermark candidate object set with color space distribution, transparency and coordinate expansion range, abnormal watermarks are determined, and a text body candidate object set is obtained. The text body candidate object set and the page object data set are filtered by object type to obtain the main text object data set.
[0055] In one embodiment, the logic reconstruction unit 203 is specifically used for: The text object data set is parsed at the character level to obtain a character object data set; The character object data set is aggregated to obtain the line object data set; The adjacent line spacing and horizontal projection overlap are calculated for the row object data set to obtain the paragraph block object data set. The paragraph block object data set is processed to record attributes, resulting in a paragraph attribute data set. Based on the paragraph attribute data set, a globally unique identifier is assigned to each paragraph, line, and character to generate a paragraph structure data set.
[0056] In one embodiment, the format processing unit 204 is specifically used for: Each paragraph and line in the paragraph structure data set is mapped to a first intermediate markup format and a second intermediate markup format, respectively, while retaining the font, font size, color, style, level, position, and globally unique identifier, to obtain the basic markup structure data set; Based on the paragraph nodes that have changed in the basic tag structure data set, update tags are generated, and each paragraph is mapped to a paragraph class tag or an inline tag to obtain the incremental tag structure data set. The incremental marker structure data set is subjected to font feature statistical processing to obtain a font identifier mapping data set; The font identifier mapping data set is subjected to attribute expansion processing to obtain an extended marker structure data set; The extended tag structure data set is subjected to cross-software intermediate encapsulation processing to generate a cross-software intermediate representation data set.
[0057] In one embodiment, the sequence processing unit 205 is specifically used for: Based on the tagging information in the cross-software intermediate representation data set, the hierarchical relationship of paragraphs, lines, and characters is reconstructed to obtain the paragraph reconstruction data set; The paragraph reconstruction dataset is used to perform information matching in the local font library of the target terminal to obtain the initial dataset of the target paragraph. The initial data set of the target paragraph is subjected to layout restoration processing to obtain the target paragraph data set.
[0058] In one embodiment, the data alignment unit 206 is used for: The target paragraph data set is used for identifier binding processing to obtain a paragraph style markup data set; The paragraph style tag data set is subjected to style feature hash calculation to obtain a consistency tag data set; When deserializing and reconstructing the target paragraph data set, a consistency check is performed based on the consistency marker data set to obtain a check result data set. Based on the verification result data set, version snapshot generation and differential calculation processing are performed to obtain snapshot and differential data sets; Based on the snapshot and differential data sets, undo and redo operations are performed on the target paragraph data set to generate a version control data set.
[0059] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.
[0060] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed, can perform the steps provided in the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0061] This invention also provides a computer device, which may include a memory and a processor. The memory stores a computer program, and when the processor calls the computer program in the memory, it can implement the steps provided in the above embodiments. Of course, the computer device may also include various network interfaces, a power supply, a graphics card, etc., to utilize the graphics card's performance to operate the model, such as for inference and training.
[0062] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
[0063] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A method for processing PDF files across software sequences, characterized in that, include: The PDF file to be processed is subjected to structured parsing to obtain a set of page object data; The page object data set is subjected to non-text filtering to obtain the text object data set; The logical structure is reconstructed using the aforementioned text object data set to obtain the paragraph structure data set; The paragraph structure data set is serialized into an intermediate format to obtain a cross-software intermediate representation data set. The target paragraph data set is obtained by deserializing the cross-software intermediate representation data set. The target paragraph data set is subjected to consistency marking and reversibility control processing respectively to obtain the version control data set; Incremental updates are performed on the version control data set to generate the target PDF file processing result.
2. The PDF file cross-software sequence processing method according to claim 1, characterized in that, The process involves performing structured parsing on the PDF file to be processed, resulting in a set of page object data, including: The PDF file to be processed is read and processed to obtain the page content stream data; The page content stream data is processed for object recognition to extract an initial object data set; By performing attribute parsing processing on the text objects in the initial object data set, a text position data set is obtained; The layout attributes of the text position data set are extracted to obtain the text attribute data set; The text attribute data set and the initial object data set are aggregated and organized to generate a page object data set.
3. The PDF file cross-software sequence processing method according to claim 1, characterized in that, The step of performing non-text filtering on the page object data set to obtain a text object data set includes: The page object data set is parsed to determine the page height region, resulting in a page region division result. Based on the page region division results, the target region is marked with headers and footers to obtain a set of candidate header and footer objects. A threshold determination is performed on the text objects in the header and footer candidate object set to obtain the watermark candidate object set; By combining the watermark candidate object set with color space distribution, transparency and coordinate expansion range, abnormal watermarks are determined, and a text body candidate object set is obtained. The text body candidate object set and the page object data set are filtered by object type to obtain the main text object data set.
4. The PDF file cross-software sequence processing method according to claim 1, characterized in that, The step of reconstructing the logical structure using the text object data set to obtain the paragraph structure data set includes: The text object data set is parsed at the character level to obtain a character object data set; The character object data set is aggregated to obtain the line object data set; The adjacent line spacing and horizontal projection overlap are calculated for the row object data set to obtain the paragraph block object data set. The paragraph block object data set is processed to record attributes, resulting in a paragraph attribute data set. Based on the paragraph attribute data set, a globally unique identifier is assigned to each paragraph, line, and character to generate a paragraph structure data set.
5. The PDF file cross-software sequence processing method according to claim 1, characterized in that, The step of performing intermediate format serialization processing on the paragraph structure data set to obtain a cross-software intermediate representation data set includes: Each paragraph and line in the paragraph structure data set is mapped to a first intermediate markup format and a second intermediate markup format, respectively, while retaining the font, font size, color, style, level, position, and globally unique identifier, to obtain the basic markup structure data set; Based on the paragraph nodes that have changed in the basic tag structure data set, update tags are generated, and each paragraph is mapped to a paragraph class tag or an inline tag to obtain the incremental tag structure data set. The incremental marker structure data set is subjected to font feature statistical processing to obtain a font identifier mapping data set; The font identifier mapping data set is subjected to attribute expansion processing to obtain an extended marker structure data set; The extended tag structure data set is subjected to cross-software intermediate encapsulation processing to generate a cross-software intermediate representation data set.
6. The PDF file cross-software sequence processing method according to claim 1, characterized in that, The step of deserializing the cross-software intermediate representation data set to obtain the target paragraph data set includes: Based on the tagging information in the cross-software intermediate representation data set, the hierarchical relationship of paragraphs, lines, and characters is reconstructed to obtain the paragraph reconstruction data set; The paragraph reconstruction dataset is used to perform information matching in the local font library of the target terminal to obtain the initial dataset of the target paragraph. The initial data set of the target paragraph is subjected to layout restoration processing to obtain the target paragraph data set.
7. The PDF file cross-software sequence processing method according to claim 1, characterized in that, The process of performing consistency marking and reversibility control on the target paragraph data set respectively yields a version control data set, including: The target paragraph data set is used for identifier binding processing to obtain a paragraph style markup data set; The paragraph style tag data set is subjected to style feature hash calculation to obtain a consistency tag data set; When deserializing and reconstructing the target paragraph data set, a consistency check is performed based on the consistency marker data set to obtain a check result data set. Based on the verification result data set, version snapshot generation and differential calculation processing are performed to obtain snapshot and differential data sets; Based on the snapshot and differential data sets, undo and redo operations are performed on the target paragraph data set to generate a version control data set.
8. A PDF file cross-software sequence processing apparatus, characterized in that, include: The file parsing unit is used to perform structured parsing on the PDF file to be processed, and obtain a set of page object data. A data filtering unit is used to perform non-text filtering on the page object data set to obtain a text object data set. The logical reconstruction unit is used to reconstruct the logical structure using the text object data set to obtain the paragraph structure data set. The format processing unit is used to perform intermediate format serialization processing on the paragraph structure data set to obtain a cross-software intermediate representation data set. A sequence processing unit is used to perform deserialization processing on the cross-software intermediate representation data set to obtain a target paragraph data set. The data alignment unit is used to perform consistency marking and reversibility control processing on the target paragraph data set to obtain a version control data set. The incremental update unit is used to incrementally update the version control data set to generate the target processing result of the PDF file.
9. A computer device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the PDF file cross-software sequence processing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the PDF file cross-software sequence processing method as described in any one of claims 1 to 7.