Marking line editing method and device based on PDF text and related medium
By parsing the PDF text content, identifying and updating the index and font information of the mark lines, the problem of cumbersome mark line editing in the existing technology is solved, and efficient PDF text mark line editing is realized.
Patent Information
- Application Number
- CN202410933893.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-09-27
AI Technical Summary
Existing PDF text editing tools are cumbersome and inefficient when editing mark lines (underlines and strikethroughs), and require frequent switching of editing modes.
By parsing the PDF text content, establishing the text object structure, identifying the starting and ending character index of the marker line, obtaining the position information and font information of the character object, creating a path object, and updating the font information according to the path object, achieving simultaneous editing of the marker line .
The operating steps have been optimized to improve the user's editing efficiency, making markline editing of PDF text more intuitive and efficient.
Smart Images

Figure CN118709659A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text processing, and in particular to a method and device for editing marked lines based on PDF text and related media. Background Art
[0002] With the popularity of digital office, PDF text has become an important tool for daily office due to its wide compatibility. Users often need to edit PDF text to update information or mark content. Although PDF text editing tools on the market can perform basic modifications and annotations on text content, these PDF text editing tools have obvious shortcomings when processing text deletion and underline editing.
[0003] Current technologies mainly use annotations to add or modify underlines and strikethroughs (hereinafter referred to as "marking lines") in PDF text. This method usually separates the marking operation from the text editing, resulting in cumbersome and inefficient operations. Users need to frequently switch between different editing modes during the editing process, which increases the complexity of the operation and affects the user's editing efficiency. Summary of the invention
[0004] The embodiments of the present invention provide a method, device and related medium for editing mark lines based on PDF text, aiming to solve the problem in the prior art that the mark lines of PDF text need to be edited separately and the operation is cumbersome.
[0005] In a first aspect, an embodiment of the present invention provides a marking line editing method based on PDF text, comprising:
[0006] Parse the content of PDF text and create a text object structure;
[0007] Identify a marking line in the PDF text, obtain a start character index and an end character index corresponding to the marking line, and record the start character index and the end character index into the text object structure;
[0008] Acquire a corresponding character object based on the text object structure, and respectively acquire position information and font information of the character object;
[0009] Creating a path object using the location information;
[0010] The font information is updated into the PDF text according to the path object.
[0011] In a second aspect, an embodiment of the present invention provides a marking line editing device based on PDF text, comprising:
[0012] The text parsing unit is used to parse the content of the PDF text and establish a text object structure;
[0013] An index recognition unit, used for recognizing a marking line in the PDF text, obtaining a start character index and an end character index corresponding to the marking line, and recording the start character index and the end character index into the text object structure;
[0014] An information acquisition unit, used to acquire corresponding character objects based on the text object structure, and respectively acquire position information and font information of the character objects;
[0015] A path object unit, used to create a path object using the location information;
[0016] A data updating unit is used to update the font information into the PDF text according to the path object.
[0017] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the PDF text-based marking line editing method of the first aspect when executing the computer program.
[0018] In a fourth aspect, an embodiment of the present invention provides 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, the marking line editing method based on PDF text of the first aspect is implemented.
[0019] The embodiment of the present invention provides a method for editing a marking line based on a PDF text, comprising parsing the content of the PDF text and establishing a text object structure; identifying a marking line in the PDF text, obtaining a start character index and an end character index corresponding to the marking line, and recording the start character index and the end character index to the text object structure; obtaining a corresponding character object based on the text object structure, and respectively obtaining the position information and font information of the character object; creating a path object using the position information; and updating the font information to the PDF text according to the path object. The present invention creates a path object using the position information of the character object, and updates the font information of the character object to the PDF text according to the path object, so that the marking lines of the PDF text can be edited at the same time, and the operation steps are optimized, greatly improving the editing efficiency of the user.
[0020] The embodiment of the present invention also provides a marking line editing device, a computer device and a storage medium based on PDF text, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0022] Figure 1 A schematic diagram of a flow chart of a method for editing a marking line based on a PDF text provided by an embodiment of the present invention;
[0023] Figure 2 A schematic block diagram of a marking line editing device based on PDF text provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0026] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0027] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0028] See below Figure 1 , Figure 1 A flowchart of a method for editing a marking line based on a PDF text provided by an embodiment of the present invention specifically includes steps S101 to S105.
[0029] S101, parsing the content of the PDF text and establishing a text object structure;
[0030] S102, identifying a marking line in the PDF text, obtaining a start character index and an end character index corresponding to the marking line, and recording the start character index and the end character index into the text object structure;
[0031] S103, acquiring corresponding character objects based on the text object structure, and respectively acquiring position information and font information of the character objects;
[0032] S104, creating a path object using the location information;
[0033] S105: Update the font information into the PDF text according to the path object.
[0034] In step S101, first, the target PDF text is loaded and its content is parsed. During the parsing process, the structure and metadata of the PDF text, such as page layout, font information, and text layer, are first identified. Subsequently, the text data in the PDF text is read byte by byte, including characters, character positions, and attributes (such as fonts and sizes). The purpose of this step is to extract clear and operable text content from the complex structure of the PDF format. After the parsing is completed, the extracted text content is converted into text objects. Each text object represents a continuous piece of text, and these text objects contain basic information and editable properties of the text. For example, a text object may contain the following information: text content, starting position, ending position, font, color, and other text format attributes.
[0035] To support efficient editing operations, each text object is also associated with its position index in the original PDF text. This structured representation not only facilitates subsequent editing operations, such as adding or modifying strikethroughs and underlines, but also facilitates quick location and update of related tags when the text content changes.
[0036] In one embodiment, the step S101 includes:
[0037] Open the specified PDF file through the file reading interface and perform format verification on the PDF file;
[0038] Calling a PDF parsing library to identify and analyze a page tree in the PDF file; wherein the page tree includes a plurality of pages;
[0039] Using a text extraction function on each page to obtain the text parsed content;
[0040] The text object is initialized using the text parsing content to obtain the text object structure.
[0041] In this embodiment, a PDF file specified by a user is opened through a file reading interface. After the PDF file is opened, a preliminary format verification is performed to confirm whether the PDF file is in a valid PDF format and to check whether the file is damaged or encrypted. This step ensures the smooth progress of subsequent processing and prevents exceptions caused by processing non-standard files. Then, the integrated PDF parsing library is used to identify and analyze the page tree structure in the PDF file. The PDF parsing library will identify each page contained in the PDF file one by one and prepare the necessary information for subsequent text extraction. The text extraction function is used for each page. This function extracts text data and its attributes, such as font, size, and color, from each page by parsing the content of each page. During the text extraction process, the system also records the specific location of the text on the page, which is crucial for subsequent editing and formatting. Finally, using the text parsing content obtained above, the system starts to initialize the text object. Each text object is constructed based on the parsed text data, which contains the specific content of the text and its location and format attributes on the page of the original PDF file. In addition, the text object also designs an interface to support text editing operations, such as adding or deleting text, and modifying the format of the text.
[0042] In step S102, the text layer in the PDF text is first analyzed, especially the marked text lines (such as underlines and strikethroughs) are identified. After the marked lines are identified, the start character index and the end character index of the text corresponding to these marked lines are then determined. This process involves calculating the text range covered by the marked lines to locate the start character and the end character. After obtaining the start character index and the end character index, the system records these indexes in the corresponding text object structure. The index recording process includes not only simple numerical recording, but also updating the text object structure so that the marked lines can be adjusted and displayed correctly in real time when the text is edited or the mark is updated.
[0043] In one embodiment, the step S102 includes:
[0044] Acquire the edited content of the user, and identify at least one of the marking lines;
[0045] Recording a start character index and an end character index corresponding to at least one of the marking lines to obtain at least one text object;
[0046] At least one of the text objects is recorded in the text object structure, and the text object structure is updated.
[0047] In this embodiment, when the user performs text editing in the PDF editing software, such as adding, deleting or modifying text, the system first captures the content of these editing operations. This includes new text entered by the user, or modification and deletion instructions for existing text. After the user edits the content, the system automatically scans the editing area to identify whether there are any marking lines (such as underlines or strikethroughs). If marking lines are detected, the system further determines the text range corresponding to these marking lines. For each identified marking line, the system calculates and records the corresponding starting character index and ending character index. These indexes are calculated based on the position of the text on the PDF page to ensure that the marking line accurately covers the corresponding text part. The acquired editing content and marking line index information are used to initialize or update the text object. Each text object contains not only text content and format information, but also marking line information related to it. When a new editing operation occurs or an existing text object is updated, the text object structure is also updated accordingly to reflect the latest text status and marking status.
[0048] In one embodiment, before step S102, the method further includes:
[0049] Get the user's edited content;
[0050] Determine whether the user's editing content contains a marking line. If not, end the current judgment process and re-judge; if so, end the current judgment process and record the marking line to obtain the corresponding character index; wherein the marking line includes the original marking line and the current marking line.
[0051] In this embodiment, all editing operations performed by the user in the PDF text are monitored and captured, including operations such as adding, deleting, and modifying text. Each editing operation is captured instantly by the system for subsequent processing and analysis. After capturing the user's editing content, the system automatically analyzes to determine whether the editing content contains marking lines. Marking lines refer to visual marks added to text, such as underlines or strikethroughs, used to highlight or mark text. The judgment process includes the following three steps:
[0052] Step 1: Check the original marking line
[0053] The system first checks whether the text editing area contains any original marking lines, that is, the marking lines that existed before the user edited them, and then checks the current marking lines.
[0054] Step 2: Check the current marking line
[0055] The system checks whether the user has added new markers in the current editing session. If no markers are detected in the user's edited content (either the original markers or the current markers), the system ends the current judgment process and waits for the next user operation; if markers are detected, the system proceeds to the next step.
[0056] Step 3: Record the marker line and get the character index
[0057] After determining that the edited content contains marker lines, the system will record these marker lines and obtain their corresponding character indexes, which refer to the specific character positions where the marker lines start and end. Recording these indexes is very important for subsequent text editing and marker synchronization, which can help ensure that the positions of marker lines are correctly updated as the text is edited.
[0058] In one embodiment, obtaining the corresponding character index includes:
[0059] When the user inserts the current marking line before the original marking line, the corresponding number of inserted characters is added to the original starting point and the original ending point of the original marking line to obtain the starting character index and the ending character index;
[0060] When the position of the current marking line inserted by the user is on the original marking line, the original starting point of the original marking line is used as the starting character index, and the corresponding number of inserted characters is added to the original ending point of the original marking line to obtain the ending character index;
[0061] When the position where the user inserts the current marking line is after the original marking line, the original starting point of the original marking line is used as the starting character index, and the original ending point of the original marking line is used as the ending character index.
[0062] In this embodiment, the specific position where the user inserts the mark line in the text is determined. This position has three different situations relative to the existing original mark line (such as the previous underline or strikethrough): before the position of the original mark line, in the position of the original mark line, or after the position of the original mark line. According to the insertion position of the mark line, the system uses the following corresponding methods to update the start and end character indexes of the mark line:
[0063] When the marker line is located before the original marker line, and the user inserts new text before the original marker line, the system will adjust the start and end indexes of the original marker line according to the number of characters inserted. That is, the number of characters inserted is added to the original start point and the original end point of the original marker line, respectively, to obtain the updated start character index and end character index.
[0064] When the marker line is within the original marker line, if the user inserts new text on the original marker line, the system will keep the original starting point of the original marker line unchanged as the new starting character index. At the same time, the number of characters inserted is added to the original ending point to get the new ending character index.
[0065] When the marker line is located after the original marker line, the system does not adjust the index of the original marker line when the insertion operation occurs after the original marker line. That is, the start point and end point of the original marker line remain unchanged and are used as the new start character index and end character index respectively.
[0066] After the character index is calculated and determined, these indexes are updated to the corresponding text object. This ensures that the index information in the text object structure changes in real time as the user edits, supporting subsequent rendering and other editing operations.
[0067] In one embodiment, obtaining the corresponding character index further includes:
[0068] When the user deletes the position of the current marking line before the original marking line, the corresponding number of inserted characters is deleted at the original starting point and the original ending point of the original marking line respectively to obtain the starting character index and the ending character index;
[0069] When the user deletes the position of the current marking line on the original marking line, the original starting point of the original marking line is used as the starting character index, and the corresponding number of inserted characters is deleted at the original ending point of the original marking line to obtain the ending character index;
[0070] When the user deletes the position of the current marking line after the original marking line, the original starting point of the original marking line is used as the starting character index, and the original ending point of the original marking line is used as the ending character index.
[0071] In this embodiment, the deletion operations of the user in the PDF text are monitored, and the positions of these operations relative to the existing marking lines (such as underlines or strikethroughs) are determined. According to the position of the deletion operation, there can be three situations: before the position of the original marking line, in the position of the original marking line, or after the position of the original marking line. According to the position of the deletion operation, the following method is used to update the start and end character indexes of the marking line:
[0072] When the deletion position is before the original marking line, if the user deletes text before the original marking line, the system will subtract the number of deleted characters from the original starting point and the original ending point of the original marking line. This is done to adjust the position of the marking line to reflect the changes in the text structure.
[0073] When the deletion position is within the original marking line, if the deletion operation occurs within the range of the original marking line, the system will keep the original starting point of the original marking line unchanged as the new starting character index, and subtract the number of deleted characters from the original ending point to get the new ending character index. In this case, the ending point of the marking line needs to be adjusted to match the new boundary of the text.
[0074] When the deletion position is after the original marking line, when the deletion operation is performed completely after the original marking line, the index of the original marking line remains unchanged. That is, the start and end points of the original marking line remain unchanged as new character indexes, because this part of the deletion operation does not affect the coverage of the marking line.
[0075] After the character indexes are updated, they are updated to the corresponding text objects. This update process ensures that the index information in the text object structure changes in real time as the user edits, supporting subsequent rendering and other editing operations.
[0076] In step S103, a specific character object is first retrieved from the text object structure. The text object structure is a complex data structure that records each character and its attributes in the PDF text in detail, and each text object contains one or more character objects. These character objects include not only the text content of the character, but also the format and position information of the character. The system obtains the corresponding character objects one by one according to the text paragraph to be edited or rendered as needed. For each retrieved character object, the system obtains its position information. The position information generally includes the coordinates of the character on the PDF page (for example, X and Y coordinates), which define the precise position of the character on the page. This information is obtained to ensure that the characters can be correctly displayed and arranged in the view of the PDF text. In addition to the position information, the font information of the character needs to be obtained. This includes the type, size, style (such as bold, italic) and color of the font. Font information is crucial to maintaining the visual consistency of the text during the rendering process, ensuring that the text is displayed according to the original design intent. Through these steps, the present invention can effectively extract and utilize the key information of the character object from the text object structure, which not only supports high-quality text rendering, but also optimizes the user experience during text editing.
[0077] In one embodiment, the step S103 includes:
[0078] Traversing the text object structure to obtain the current text object operated by the user;
[0079] Identify a corresponding character object according to the current text object;
[0080] Identify the coordinate position of the character object on the PDF text to obtain the position information;
[0081] The font attributes in the PDF text are traversed, and the font attributes are associated with the character objects to obtain the font information.
[0082] In this embodiment, the entire text object structure is first traversed, which is a hierarchical data structure containing all text elements and their attributes in the PDF text. Through this traversal, the text object currently being operated by the user can be located. These text objects include single characters, phrases or entire texts, and each object has a detailed attribute record. After locating the current text object, the system then identifies all character objects contained in this text object. Each character object represents a character in the text and contains detailed information about the character, such as its text content and format attributes. For each identified character object, the system will determine its coordinate position on the PDF text. This position information usually exists in the form of page coordinates (e.g., X and Y coordinates), indicating the exact position of the character on the page. This position information is obtained by analyzing rendering instructions and layout parameters to ensure that the characters can be accurately displayed according to the design intent. The font attribute information in the PDF text is further traversed, which includes the type, size, style (such as bold, italic), color, etc. of the font. For each character object, the system associates these font attributes with it. This association process involves matching the formatting requirements of the glyph objects with the font resources available in the document, ensuring that the visual presentation of each glyph is consistent with the overall style of the document.
[0083] In step S104, position information is extracted from the acquired character object. This position information includes the precise coordinates of each character on the PDF page, such as X and Y coordinates. These coordinates locate the specific position of the character and provide the necessary data for the subsequent path object creation. Using the acquired position information, the system then creates a path object. Path objects are structures used to draw complex graphics and lines in PDF text. They can define a series of points that are connected into lines to form a path.
[0084] In step S105, previously created path objects are first used. These path objects are based on the user's editing activities in the PDF text, such as adding or modifying marking lines. Each path object is associated with a specific text object, which contains basic information and font properties of the characters. During the path object creation process, the system also checks the font information of the text object associated with it. This information includes font type, size, style (such as bold, italic), color, etc., which are all visual attributes that are crucial in PDF editing. Using the path object and the extracted font information, the system will perform the following update operations:
[0085] Font type and size updates: If a path object represents a segment of text that requires special emphasis (for example, a heading or a highlighted section), the system will adjust the font size or type to improve readability or visual effect based on design requirements.
[0086] Style and color adjustment: For text that requires special formatting, such as underlining or striking through, the system will adjust the font style and color of the text according to the properties of the path object (such as line thickness or color) to ensure that the marking of the text is clear and visible.
[0087] Synchronous update to PDF document: After the font properties are determined, the system updates these font properties to the corresponding text paragraphs in the PDF document. This involves modifying the internal structure of the PDF, such as content streams and resource dictionaries, to ensure the display consistency of the document on various devices and readers.
[0088] After updating the font information, the system will render these changes so that the updated text is displayed on the PDF page with the new font properties. This rendering process ensures that the text changes are seamlessly integrated with the rest of the PDF text.
[0089] Combination Figure 2 As shown, Figure 2 A schematic block diagram of a marking line editing device based on a PDF text provided by an embodiment of the present invention, the marking line editing device 200 based on a PDF text comprises:
[0090] The text parsing unit 201 is used to parse the content of the PDF text and establish a text object structure;
[0091] An index recognition unit 202 is used to recognize a marking line in the PDF text, obtain a start character index and an end character index corresponding to the marking line, and record the start character index and the end character index into the text object structure;
[0092] An information acquisition unit 203, used to acquire corresponding character objects based on the text object structure, and respectively acquire position information and font information of the character objects;
[0093] A path object unit 204, configured to create a path object using the location information;
[0094] The data updating unit 205 is used to update the font information into the PDF text according to the path object.
[0095] In this embodiment, the text parsing unit 201 parses the content of the PDF text and establishes a text object structure; the index recognition unit 202 recognizes the marking line in the PDF text, obtains the start character index and the end character index corresponding to the marking line, and records the start character index and the end character index to the text object structure; the information acquisition unit 203 obtains the corresponding character object based on the text object structure, and obtains the position information and the font information of the character object respectively; the path object unit 204 creates a path object using the position information; and the data update unit 205 updates the font information to the PDF text according to the path object.
[0096] In one embodiment, the text parsing unit 201 includes:
[0097] A verification unit, used to open a specified PDF file through a file reading interface and perform format verification on the PDF file;
[0098] A parsing unit, used for calling a PDF parsing library to identify and analyze a page tree in the PDF file; wherein the page tree includes a plurality of pages;
[0099] An extraction unit, used for using a text extraction function on each page to obtain the text parsed content;
[0100] The initialization unit is used to initialize the text object using the text parsing content to obtain the text object structure.
[0101] In one embodiment, the index identification unit 202 includes:
[0102] An editing unit, used to obtain the editing content of the user and identify at least one of the marking lines;
[0103] A marking unit, used to record a start character index and an end character index corresponding to at least one of the marking lines, to obtain at least one text object;
[0104] A recording unit is used to record at least one of the text objects into the text object structure and update the text object structure.
[0105] In one embodiment, before the index identification unit 202, the method further includes:
[0106] User unit, used to obtain the user's edited content;
[0107] A judgment unit is used to judge whether the user's editing content contains a marking line. If not, the current judgment process is terminated and re-judgment is carried out; if so, the current judgment process is terminated and the marking line is recorded to obtain the corresponding character index; wherein the marking line includes the original marking line and the current marking line.
[0108] In one embodiment, the determining unit includes:
[0109] An adding unit, used for adding a corresponding number of inserted characters to the original starting point and the original ending point of the original marking line respectively when the user inserts the current marking line before the original marking line, to obtain the starting character index and the ending character index;
[0110] An inserting unit, configured to, when the position of the current marking line inserted by the user is on the original marking line, use the original starting point of the original marking line as the starting character index, and add the corresponding number of inserted characters to the original ending point of the original marking line to obtain the ending character index;
[0111] The index unit is used to use the original starting point of the original marking line as the starting character index and the original ending point of the original marking line as the ending character index when the user inserts the current marking line after the original marking line.
[0112] In one embodiment, the determining unit further includes:
[0113] A character unit, used for deleting the corresponding number of inserted characters at the original starting point and the original ending point of the original marking line respectively when the user deletes the position of the current marking line before the original marking line, to obtain the starting character index and the ending character index;
[0114] An original unit, used for, when the user deletes the position of the current marking line on the original marking line, using the original starting point of the original marking line as the starting character index, and deleting the corresponding number of inserted characters at the original ending point of the original marking line to obtain the ending character index;
[0115] The deleting unit is used to use the original starting point of the original marking line as the starting character index and the original ending point of the original marking line as the ending character index when the user deletes the current marking line after the original marking line.
[0116] In one embodiment, the information acquisition unit 203 includes:
[0117] An acquisition unit, used for traversing the text object structure to acquire a current text object operated by a user;
[0118] A recognition unit, used for recognizing a corresponding character object according to the current text object;
[0119] A coordinate unit, used for identifying the coordinate position of the character object on the PDF text to obtain the position information;
[0120] The traversal unit is used to traverse the font attributes in the PDF text and associate the font attributes with the character object to obtain the font information.
[0121] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0122] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0123] The embodiment of the present invention also provides a computer device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the computer device may also include various network interfaces, power supplies and other components.
[0124] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
[0125] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A marking line editing method based on PDF text, characterized in that: include: Parse the content of PDF text and create a text object structure; Identify a marking line in the PDF text, obtain a start character index and an end character index corresponding to the marking line, and record the start character index and the end character index into the text object structure; Acquire a corresponding character object based on the text object structure, and respectively acquire position information and font information of the character object; Creating a path object using the location information; The font information is updated into the PDF text according to the path object.
2. The marking line editing method based on PDF text according to claim 1, characterized in that: The process of parsing the content of the PDF text and establishing a text object structure includes: Open the specified PDF file through the file reading interface and perform format verification on the PDF file; Calling a PDF parsing library to identify and analyze a page tree in the PDF file; wherein the page tree includes a plurality of pages; Using a text extraction function on each page to obtain the text parsed content; The text object is initialized using the text parsing content to obtain the text object structure.
3. The marking line editing method based on PDF text according to claim 1, characterized in that: The identifying the marking line in the PDF text, obtaining the starting character index and the ending character index corresponding to the marking line, and recording the starting character index and the ending character index to the text object structure includes: Acquire the edited content of the user, and identify at least one of the marking lines; Recording a start character index and an end character index corresponding to at least one of the marking lines to obtain at least one text object; At least one of the text objects is recorded in the text object structure, and the text object structure is updated.
4. The marking line editing method based on PDF text according to claim 1, characterized in that: The step of identifying the marking line in the PDF text, obtaining the start character index and the end character index corresponding to the marking line, and recording the start character index and the end character index to the text object structure also includes: Get the user's edited content; Determine whether the user's editing content contains a marking line. If not, end the current judgment process and re-judge; if so, end the current judgment process and record the marking line to obtain the corresponding character index; wherein the marking line includes the original marking line and the current marking line.
5. The marking line editing method based on PDF text according to claim 4, characterized in that: The obtaining of the corresponding character index includes: When the user inserts the current marking line before the original marking line, the corresponding number of inserted characters is added to the original starting point and the original ending point of the original marking line to obtain the starting character index and the ending character index; When the position of the current marking line inserted by the user is on the original marking line, the original starting point of the original marking line is used as the starting character index, and the corresponding number of inserted characters is added to the original ending point of the original marking line to obtain the ending character index; When the position where the user inserts the current marking line is after the original marking line, the original starting point of the original marking line is used as the starting character index, and the original ending point of the original marking line is used as the ending character index.
6. The marking line editing method based on PDF text according to claim 4, characterized in that: The obtaining of the corresponding character index further includes: When the user deletes the position of the current marking line before the original marking line, the corresponding number of inserted characters is deleted at the original starting point and the original ending point of the original marking line respectively to obtain the starting character index and the ending character index; When the user deletes the position of the current marking line on the original marking line, the original starting point of the original marking line is used as the starting character index, and the corresponding number of inserted characters is deleted at the original ending point of the original marking line to obtain the ending character index; When the user deletes the position of the current marking line after the original marking line, the original starting point of the original marking line is used as the starting character index, and the original ending point of the original marking line is used as the ending character index.
7. The marking line editing method based on PDF text according to claim 1, characterized in that: The obtaining of the corresponding character object based on the text object structure, and respectively obtaining the position information and font information of the character object, includes: Traversing the text object structure to obtain the current text object operated by the user; Identify a corresponding character object according to the current text object; Identify the coordinate position of the character object on the PDF text to obtain the position information; The font attributes in the PDF text are traversed, and the font attributes are associated with the character objects to obtain the font information.
8. A marking line editing device based on PDF text, characterized in that: include: The text parsing unit is used to parse the content of the PDF text and establish a text object structure; An index recognition unit, used for recognizing a marking line in the PDF text, obtaining a start character index and an end character index corresponding to the marking line, and recording the start character index and the end character index into the text object structure; An information acquisition unit, used to acquire corresponding character objects based on the text object structure, and respectively acquire position information and font information of the character objects; A path object unit, used to create a path object using the location information; A data updating unit is used to update the font information into the PDF text according to the path object.
9. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the PDF text-based marking line editing method as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the marking line editing method based on PDF text according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
RAG-based multi-format data rapid query method
CN119415544A
