Method and device for automatic processing of graphics within a word document

By splitting and combining graphic and line areas in a Word document, the anchor point position is automatically determined, solving the time-consuming and laborious problem caused by scattered graphic anchor points, and realizing accurate automatic graphic layout and efficient processing.

CN117217181BActive Publication Date: 2026-11-20SHANXI TONGFANG KNOWLEDGE NETWORK DIGITAL PUBLISHING TECH CO
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311135536.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-05
Publication Date
2026-11-20
Estimated Expiration
2043-09-05

AI Technical Summary

Technical Problem

In Word documents, the anchor points of graphics are scattered and inconsistent, requiring manual inspection and correction, which is time-consuming, labor-intensive, inaccurate, and prone to errors.

Method used

By splitting non-embedded graphics in a Word document, determining the positional relationship between the graphic area and the line area, automatically determining the graphic to be combined and the anchor position, and combining and embedding them, the process is automated.

Benefits of technology

It achieves precise automatic layout of graphics, reduces manual intervention, improves work efficiency, and reduces the error rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117217181B_ABST
    Figure CN117217181B_ABST
Patent Text Reader

Abstract

The application discloses an automatic processing method and device based on graphics in a word document, electronic equipment and a storage medium. In the method, the position relationship between the graphic regions of different graphics in a single-page document and the position relationship between the graphic regions and the line regions are determined to determine the graphics to be combined and the optimal anchor position, then the graphics to be combined are combined and embedded into the position corresponding to the anchor position in the word document, and finally the operation of automatically processing the graphics in the word document is realized. The method comprises the following steps: splitting a single-page document in which a non-embedded graphic is located from a word document; determining the graphic regions and the line regions of the graphics in the single-page document; determining the graphics to be combined and the anchor position according to the position relationship between the graphic regions of different graphics in the single-page document and the position relationship between the graphic regions and the line regions; and combining the graphics to be combined and embedding them into the position corresponding to the anchor position in the word document.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of Word graphic processing, and in particular to a method, apparatus, electronic device and storage medium for automatic processing of graphics within a Word document. Background Technology

[0002] Currently, in the process of processing Word documents, due to various layout methods such as floating and wrapping, the anchors of graphics within the same area may be scattered in different positions on the page. Therefore, to ensure the standardization of graphics in a Word document, it is necessary to manually check and correct each graphic before combining and embedding it into the correct position in the Word document. This process is time-consuming and labor-intensive. Therefore, there is an urgent need for an automated processing method to free people from this tedious work. Summary of the Invention

[0003] This application provides a method, apparatus, electronic device, and storage medium for automatic processing of graphics within a Word document. In this method, the graphics to be combined and the optimal anchor position are determined based on the positional relationship between the graphic regions of different graphics in the single-page document and the positional relationship between the graphic regions and the line regions. Then, the graphics to be combined are embedded in the Word document, thereby achieving automated processing of graphics within the Word document.

[0004] In a first aspect, embodiments of this application provide a method for automatic processing of graphics within a Word document, including:

[0005] Extract the single-page document containing non-embedded graphics from a Word document;

[0006] Determine the graphic area and line area of ​​the graphics in the single-page document;

[0007] Based on the positional relationship between the graphic regions of different graphics in the single-page document, and the positional relationship between the graphic regions and the row regions, determine the graphics to be combined and the anchor positions.

[0008] The graphics to be combined are combined and embedded into the Word document at the position corresponding to the anchor position.

[0009] In some embodiments, the step of determining the graphics to be combined based on the positional relationship between the graphic regions of different graphics in the single-page document, and the positional relationship between the graphic regions and the row regions, includes:

[0010] Obtain a target graphic from the graphics of the single-page document;

[0011] Determine the movable range of the target graphic;

[0012] The graphic area of ​​the target graphic is moved laterally within the movable range until it touches the target object, which includes the graphic areas of other graphics, the line area where the text lines in the single-page document are located, and the extreme position of the movable range.

[0013] If the target object touched is within the graphic area of ​​another graphic, then the graphic area before movement and the graphic area of ​​the other graphic touched are superimposed and expanded to obtain an expanded graphic area; the graphic in the expanded graphic area is identified as the graphic to be combined and labeled with the same combination number; the expanded graphic area is used as the graphic area of ​​the target graphic, and the step of determining the movable range of the target graphic is repeated.

[0014] In some embodiments, the method further includes:

[0015] If the target object touched is the line area where the text line is located in the single-page document or the limit position of the movable range, then the next target graphic is obtained from the graphic of the single-page document, and the step of determining the movable range of the target graphic is repeated.

[0016] In some embodiments, the step of determining the movable range of the target graphic includes:

[0017] Determine the position type of each text line in the single-page document, where the position type includes full-width, left column, and right column;

[0018] Based on the location type, determine the range to be compared; based on the overlapping area of ​​the target graphic's graphic region and the range to be compared, determine the movable range of the target graphic.

[0019] In some embodiments, the step of determining the movable range of the target graphic based on the overlapping area of ​​the graphic region of the target graphic and the range to be compared includes:

[0020] Compare the size of the overlapping area between the graphic region of the target graphic and the range to be compared corresponding to different location types;

[0021] If the overlapping area between the graphic area of ​​the target graphic and the comparison range corresponding to the full-width column is the largest, or if there is no overlap with any comparison range, then the movable range is determined to be the page width range in the single-page document.

[0022] If the overlap area between the graphic area of ​​the target graphic and the comparison range corresponding to the left column is the largest, then the movable range is determined to be the column width range of the left column.

[0023] If the overlap area between the graphic area of ​​the target graphic and the comparison range corresponding to the right column is the largest, then the movable range is determined to be the width range of the right column.

[0024] In some embodiments, the step of extracting the single-page document containing the non-embedded graphics from the Word document includes:

[0025] The graphics in the Word document are labeled according to their graphic types, which include embedded graphic types and graphic object types;

[0026] Determine whether the graphic object type graphic's wrapping type information conforms to the following types: four-sided wrapping, through wrapping, tight wrapping, top and bottom wrapping, default type, floating above text type, or below text type.

[0027] If the conditions are met, extract the page number of the graphic object type containing the graphic.

[0028] Extract the single-page document corresponding to the page number from the Word document.

[0029] In some embodiments, the step of determining the line region in a single-page document includes:

[0030] Obtain the top-left position, top-right position, and height of the text lines in the single-page document;

[0031] The lower right position is determined based on the upper right position and the height of the text line;

[0032] The row area is determined based on the upper left and lower right positions.

[0033] Secondly, embodiments of this application also provide an automatic graphics processing device based on Word documents, comprising:

[0034] Split Unit: Used to extract single-page documents containing non-embedded graphics from a Word document;

[0035] The first determining unit is used to determine the graphic area and line area of ​​the graphics in the single-page document;

[0036] The second determining unit is used to determine the graphic to be combined and the anchor position based on the positional relationship between the graphic regions of different graphics in the single-page document and the positional relationship between the graphic regions and the line regions.

[0037] The combination unit is used to combine the graphics to be combined and embed them into the Word document at the position corresponding to the anchor position.

[0038] Thirdly, embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the automatic processing method for graphics within a Word document.

[0039] Fourthly, embodiments of this application also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method for automatically processing graphics within a Word document.

[0040] The above embodiments provide an automatic image processing method based on Word documents. This method determines the images to be combined and the optimal anchor positions based on the positional relationships between the image regions of different images in a single-page document, as well as the positional relationships between the image regions and line regions. Then, the images to be combined are combined and embedded into the Word document at the position corresponding to the anchor position, ultimately achieving automated image processing within the Word document. The method includes: separating the single-page document containing non-embedded images from the Word document; determining the image regions and line regions of the images in the single-page document; determining the images to be combined and the anchor positions based on the positional relationships between the image regions of different images in the single-page document, as well as the positional relationships between the image regions and line regions; combining the images to be combined and embedding them into the Word document at the position corresponding to the anchor position. Attached Figure Description

[0041] Figure 1 An example diagram of a Word document is shown;

[0042] Figure 2 An exemplary flowchart illustrates a method for automatic processing of graphics within a Word document, according to some embodiments.

[0043] Figure 3 An exemplary flowchart illustrates yet another method for automatic processing of graphics within a Word document, according to some embodiments;

[0044] Figure 4 An exemplary schematic diagram of a graphic provided according to some embodiments is shown;

[0045] Figure 5 An exemplary flowchart illustrates yet another method for automatic processing of graphics within a Word document, according to some embodiments;

[0046] Figure 6 An exemplary diagram of a text line provided according to some embodiments is shown;

[0047] Figure 7 An exemplary flowchart illustrates yet another method for automatic processing of graphics within a Word document, according to some embodiments;

[0048] Figure 8 An exemplary flowchart illustrates yet another method for automatic processing of graphics within a Word document, according to some embodiments;

[0049] Figure 9 An exemplary diagram of a single-page document provided according to some embodiments is shown;

[0050] Figure 10 An exemplary diagram of a Word document provided according to some embodiments is shown;

[0051] Figure 11 An exemplary schematic diagram of a device for automatically processing graphics within a Word document, according to some embodiments, is shown. Detailed Implementation

[0052] To make the objectives and implementation methods of this application clearer, the exemplary implementation methods of this application will be clearly and completely described below with reference to the accompanying drawings of the exemplary embodiments of this application. Obviously, the exemplary embodiments described are only some embodiments of this application, and not all embodiments.

[0053] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.

[0054] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities, and do not necessarily imply a specific order or sequence, unless otherwise specified. It should be understood that such terms are interchangeable where appropriate.

[0055] The terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device that includes a range of components is not necessarily limited to all of the components that are clearly listed, but may include other components that are not clearly listed or that are inherent to such product or device.

[0056] Currently, in the processing of Word documents, due to various layout styles such as floating and wrapping, the anchors of graphics within the same area may be scattered across different positions on the page. Therefore, to ensure the standardization of graphics in a Word document, it is necessary to manually check and correct each graphic before combining and embedding it into the correct position. This process is time-consuming, labor-intensive, and has low accuracy, leading to a high rate of errors and rework. Therefore, there is an urgent need for an automated processing method to free people from this tedious work.

[0057] For example, Figure 1 An example diagram of a Word document is shown. Figure 1 The image displayed is anchor 101 with the selected image. Since anchors only appear when an image is selected, in reality... Figure 1 Each image in the document contains a corresponding anchor, but the anchor's position is arbitrary.

[0058] To address the aforementioned technical problems, this application provides a method for automatically processing graphics within a Word document. This method determines the graphics to be combined and the optimal anchor position based on the positional relationships between different graphic regions within a single-page document, as well as the positional relationships between the graphic regions and line regions. Then, the graphics to be combined are embedded into the Word document, ultimately achieving automated processing of graphics within the Word document.

[0059] Figure 2 An exemplary flowchart is shown of a method for automatic processing of graphics within a Word document according to some embodiments, the method comprising steps S100-S400.

[0060] S100. Extract the single-page document containing non-embedded graphics from a Word document.

[0061] In this embodiment of the application, in order to eliminate interference between the content of different pages in a Word document, the single-page document containing the non-embedded graphics is separated from the Word document. This allows for a more accurate determination of the graphic area and line area in the single-page document containing the non-embedded graphics in subsequent steps.

[0062] It should be noted that when multiple non-embedded graphics are located in the same single-page document, it is only necessary to split the document into a single page.

[0063] In some embodiments, Figure 3 An exemplary flowchart is shown for yet another method for automatic processing of graphics within a Word document, according to some embodiments, wherein the step of separating the single-page document containing non-embedded graphics from the Word document includes S101-S105.

[0064] S101. The graphics in the Word document are marked according to their graphic types, including embedded graphic types and graphic object types;

[0065] In this embodiment, the underlying data of the Word document can be parsed, and graphics of different graphic types can be marked accordingly. Specifically, embedded graphics (inlineshape) and shape objects (shape) in the Word document are marked separately. For example, inlineshape type graphics can be marked according to the order in which they appear in the Word document, and identified as inlineshape1, inlineshape2, etc. Shape type graphics can be marked according to the order in which they appear in the Word document, and identified as shape1, shape2, shape3, etc.

[0066] In this embodiment, the graphics in the Word document are marked according to their graphic type. This not only makes it easier to identify non-embedded graphic types, but also makes it easier to find images marked with the same identifier in the original Word document after identifying the images to be combined using a single-page document. The images with the same identifier in the original Word document are then combined and embedded.

[0067] S102. Determine whether the wrap type information of the graphic object conforms to the following types: WrapSquare, WrapThrough, WrapTight, WrapTopBottom, WrapNone, WrapFront, or WrapBeline.

[0068] S103. If the conditions are met, extract the page number of the graphic object type.

[0069] Specifically, the page number of the page containing the shape-type graphic is extracted using the WordApplication program.

[0070] S104. If the condition is met, do not perform the extraction of the page number of the graphic object type.

[0071] S105. Extract the single-page document corresponding to the page number from the Word document.

[0072] In this embodiment of the application, in order to ensure that the structure of the extracted single-page document is consistent with its structure in the original Word document, the OriginalPageInfo (original page information) is set for the single-page document during the splitting process.

[0073] In some embodiments, the step of extracting the single-page document corresponding to the page number from the Word document may include:

[0074] Extract the header and footer of the page corresponding to the page number from the Word document. Extract information such as first-line indent, left indent, right indent, space before, and space after of the first and last paragraphs. Based on the start and end attributes of the page range of the single-page document, filter the content before and after to form a single-page document.

[0075] S200. Determine the graphic area and row area of ​​the graphics in the single-page document.

[0076] In some embodiments, determining the graphic region of a graphic in a single-page document can be done by identifying and extracting the shapeinfo (graphic data) of each graphic in the single-page document. Using the marking information obtained in step S101 (e.g., shape1, shape2, etc.), the graphic region (PicRect) of the graphic is extracted, including four parameters: top, left, width, and height.

[0077] For example, Figure 4 An exemplary schematic diagram of a graphic provided according to some embodiments is shown. Figure 4 In the Word document 401, there is a graphic area 402 containing a graphic, with the horizontal axis ranging from (left, left+width) and the vertical axis ranging from (top, top+height).

[0078] In other embodiments, the graphic area of ​​a single-page document graphic can be an enlarged version of the graphic area determined by shapeinfo. For example, the horizontal coordinate range of the graphic area determined by shapeinfo is (left, left + width), and the vertical coordinate range is (top, top + height). The horizontal coordinate range of the enlarged graphic area is (a1 * left, b1 * (left + width)), where a1 is less than 1 and b1 is greater than 1; the vertical coordinate range of the enlarged graphic area is (c1 * top, d1 * (top + height)), where c1 is less than 1 and d1 is greater than 1.

[0079] In some embodiments, Figure 5A flowchart illustrating yet another method for automatic processing of graphics within a Word document, according to some embodiments, is provided. The step of determining the line region in a single-page document includes S201-S203.

[0080] S201. Obtain the top left position, top right position, and height of the text lines in the single-page document.

[0081] In this embodiment of the application, a corresponding line area is determined for each line of text in a single-page document.

[0082] In some embodiments, the steps for determining the top-left and top-right positions of text lines in the single-page document include:

[0083] Retrieve the first and last elements of the text lines in the single-page document. For example, if the text line is "Extract an image", then the first element is "extract" and the last element is "image". In some embodiments, the step of retrieving the first and last elements of the text lines in the single-page document includes: obtaining the first and last elements of the text lines using HomeKey and EndKey with the type WdUnits.wdLine.

[0084] The first and last elements are marked. Based on the marked first element, the top-left position of the text line is extracted; based on the marked last element, the top-right position of the text line is extracted.

[0085] S202. Determine the lower right position based on the upper right position and the height of the text line. Figure 6 An exemplary illustration shows a schematic diagram of a text line according to some embodiments, in Figure 6 In the text action "Extract an image", point A is the top left position, point B is the top right position, point C is the bottom right position, and H is the height of the text line.

[0086] S203. Determine the row area based on the upper left and lower right positions.

[0087] In this embodiment, a coordinate system can be established with the top left corner of the single-page document as the origin. The top left, top right, and bottom right positions can be represented using coordinates.

[0088] For example, if the top left position is (m, n) and the bottom right position is (j, k), then the horizontal coordinate range of the row area is (m, j) and the vertical coordinate range is (n, k).

[0089] In other embodiments, the row area in a single-page document is an expanded row area determined by the upper-left and lower-right positions described above. The horizontal coordinate range of the expanded row area is (a2*m, b2*j), where a2 is less than 1 and b2 is greater than 1; the vertical coordinate range of the expanded graphic area is (c2*n, d2*k), where c2 is less than 1 and d2 is greater than 1.

[0090] S300. Based on the positional relationship between the graphic regions of different graphics in the single-page document, and the positional relationship between the graphic regions and the row regions, determine the graphics to be combined and the anchor positions.

[0091] In this embodiment, the graphic area can be moved, and the positional relationship between the moved graphic area and other graphic areas and row areas can be used to determine the graphics in adjacent positions, which are then used as the graphics to be combined.

[0092] In some embodiments, Figure 7 The flowchart of another method for automatic processing of graphics within a Word document, according to some embodiments, is illustrated. The step of determining the graphics to be combined and the anchor positions based on the positional relationships between different graphic regions in the single-page document, and the positional relationships between the graphic regions and line regions, includes steps S301-S305.

[0093] S301. Obtain a target graphic from the graphics in the single-page document.

[0094] Specifically, one graphic from the single-page document can be selected as the target graphic according to a preset order.

[0095] In this embodiment, the preset order can be from top to bottom or from left to right. It should be noted that the obtained graphic can be an embedded graphic or a non-embedded graphic.

[0096] S302. Determine the movable range of the target graphic.

[0097] In some embodiments, Figure 8 A flowchart illustrating yet another method for automatic processing of graphics within a Word document, according to some embodiments, is provided. The step of determining the movable range of the target graphic includes S3021-S3023.

[0098] S3021. Determine the position type of each text line in the single-page document, wherein the position type includes full-width, left column, and right column.

[0099] Specifically, each line of text in a single-page document is bookmarked line by line. The first and last elements of each line are obtained using the HomeKey and EndKey operations of type WdUnits.wdLine, and marked with the "line" feature.

[0100] When columns exist, the position type of the text line is distinguished by calculating the coordinate information of the text line and the column range.

[0101] Specifically, a coordinate system is established with the top-left corner of the single-page document as the origin. Let x be the horizontal coordinate of the text line, w be the width of the text line, pw be the page width of the single-page document, plm be the left margin of the single-page document, and prm be the right margin of the single-page document.

[0102] When the sum of the horizontal coordinate of a text line and its width is greater than or equal to a preset width, the text line is determined to belong to the left column. The preset width is the page width of a single-page document minus half of the left and right margins. Specifically, it can be determined using the following formula: x + w ≤ (pw - plm - prm) / 2;

[0103] When the horizontal coordinate of a text line is greater than or equal to the preset width, the text line is determined to belong to the right column. Specifically, it can be determined using the following formula: x≥(pw-plm-prm) / 2.

[0104] The left column text line is marked with the "line_left" feature, and the right column text line is marked with the "line_right" feature.

[0105] For example, Figure 9 An exemplary schematic diagram of a single-page document provided according to some embodiments is shown. Figure 9 It includes single-page documents that contain marked text lines and graphics.

[0106] S3022. Determine the range to be compared based on the location type.

[0107] If the text line is positioned as a full-width column, the comparison range corresponding to the full-width column is determined based on the horizontal coordinate of the text line, the page width of the single-page document, and the height of the text line. It can be understood that a rectangular range can be formed using the horizontal coordinate of the text line, the page width, and the text line height; this rectangular range can be determined as the comparison range corresponding to the full-width column.

[0108] If the text line is located in either the left or right column, the comparison range corresponding to the left or right column is determined based on the horizontal coordinate, column width, and text line height of the text line. It can be understood that a rectangular range can also be formed using the horizontal coordinate, column width, and text line height, and this rectangular range can be used to determine the comparison range corresponding to the left or right column.

[0109] S3023. Determine the movable range of the target graphic based on the overlapping area of ​​the graphic region of the target graphic and the range to be compared.

[0110] In this embodiment, the position of the target graphic is determined based on the overlapping area of ​​the graphic area of ​​the target graphic and the comparison range determined based on the text lines. If most of the graphic area is located in the entire column or does not overlap with any comparison range, the target graphic is determined to be movable within the entire page width; if most of the graphic area is located in the left column, the target graphic is determined to be movable within the width of the left column; if most of the graphic area is located in the right column, the target graphic is determined to be movable within the width of the right column.

[0111] In some embodiments, the step of determining the movable range of the target graphic based on the overlapping area of ​​the graphic region of the target graphic and the range to be compared includes:

[0112] The size of the overlapping area between the graphic region of the target graphic and the comparison range corresponding to different position types is compared. In this embodiment, the graphic region may occupy multiple lines, and the graphic region may overlap with the comparison range corresponding to multiple text lines.

[0113] If the overlapping area between the target graphic's graphic area and the comparison area corresponding to the full-width column is the largest, or if there is no overlap with any comparison area, then the movable range is determined to be the page width range in the single-page document. In this way, the graphic area of ​​the target graphic can move horizontally within the page width range.

[0114] If the overlap between the target graphic's graphic area and the comparison area corresponding to the left column is the largest, then the movable range is determined to be the width of the left column. In this way, the target graphic's graphic area can move horizontally within the width of the left column.

[0115] If the overlap between the target graphic's graphic area and the comparison area corresponding to the right column is the largest, then the movable range is determined to be the width of the right column. In this way, the target graphic's graphic area can move horizontally within the width of the right column.

[0116] S303. Move the graphic area of ​​the target graphic horizontally within the movable range until it touches the target object, wherein the target object includes the graphic areas of other graphics, the line area where the text lines in the single-page document are located, and the extreme position of the movable range.

[0117] In some embodiments, after appropriate expansion, the graphic region PicRect of each graphic in a single-page document is moved horizontally within its column range or the entire page width to form a moving rectangle MoveRect. If it touches the graphic region PicRect of another graphic, causing region interference, it is allowed to be added, and the horizontal moving rectangle MoveRect is also superimposed and expanded accordingly. If the moving matrix MoveRect touches the line region LineRect horizontally or vertically, the combination and merging ends. After repeating this process to interfere with the moving regions of the unmerged graphics, a complete set of combined graphics for that region is obtained, and a unified combination number is recorded in the respective graphic ShapeInfo.

[0118] S304. If the target object touched is the graphic area where other graphics are located, then the graphic area before moving and the graphic area where other graphics are touched are superimposed and expanded to obtain an expanded graphic area; the graphics in the expanded graphic area are identified as the graphics to be combined and labeled with the same combination number; the expanded graphic area is used as the graphic area of ​​the target graphic, and the step of determining the movable range of the target graphic is repeated.

[0119] In this embodiment of the application, multiple graphic regions located in adjacent positions are determined as the graphic to be combined.

[0120] S305. If the target object touched is the line area where the text line in the single-page document is located or the limit position of the movable range, then obtain the next target graphic from the graphic of the single-page document and repeat the step of determining the movable range of the target graphic.

[0121] In this embodiment of the application, if the graphic area of ​​the target graphic touches the limit position of the row area or the movable range, it means that there is no adjacent graphic area around the target graphic. Then, other graphics in the single-page document that have not been determined to be combined and have not been obtained before are obtained and used as the target graphic. The step of determining the movable range of the target graphic is repeated.

[0122] In some embodiments, the anchor position is determined based on the graphic area and line area of ​​the graphic in the single-page document.

[0123] In this embodiment of the application, the anchor position can be determined based on a graphic to be assembled.

[0124] For example, a wraparound graphic will be placed alongside the text lines on the left and right, and the anchor for the image will be determined based on the relationship between the line range of each text line in that paragraph and the graphic area. For instance, if paragraph A has 5 lines that intersect the graphic area horizontally, while paragraph B has only 1 line, then the anchor will be positioned on paragraph A.

[0125] If there are no lines of text around the graphic to be combined, the anchor position may be set on the blank paragraph around the image.

[0126] If there are titles around the graphics to be combined, the anchor position is set in the paragraph containing the title.

[0127] S400. Combine the graphics to be combined and embed them into the Word document at the position corresponding to the anchor position.

[0128] In this embodiment, based on the combination number corresponding to the graphics to be combined, graphics with the same combination number are combined in Word, and then embedded into the Word document according to the anchor position. For example, Figure 10 An exemplary diagram of a Word document according to some embodiments is shown. Figure 10 The document displays a Word document with embedded combined graphics.

[0129] In this embodiment, the document structure information of the single page in the original Word document is set according to the extracted OriginalPageInfo.

[0130] In this embodiment, non-embedded graphics and other graphics can be combined and embedded into a single image, avoiding the situation of randomly placed anchors. The graphics can be accurately combined, embedded, and positioned in the correct location, meeting the requirements for accurate automatic graphic layout and achieving automated processing. This frees up manpower and improves work efficiency.

[0131] The above embodiments provide an automatic image processing method based on Word documents. This method determines the images to be combined and the optimal anchor positions based on the positional relationships between the image regions of different images in a single-page document, as well as the positional relationships between the image regions and line regions. Then, the images to be combined are combined and embedded into the Word document at the position corresponding to the anchor position. This ultimately automates the processing of images within the Word document, achieving the goals of maximizing resource utilization and minimizing task time. It effectively configures the corresponding process engine according to the quality requirements of the output, thereby ensuring quality. The method includes: separating the single-page document containing non-embedded images from the Word document; determining the image regions and line regions of the images in the single-page document; determining the images to be combined and the anchor positions based on the positional relationships between the image regions of different images in the single-page document, as well as the positional relationships between the image regions and line regions; combining the images to be combined and embedding them into the Word document at the position corresponding to the anchor position.

[0132] Furthermore, as Figure 2 , 3 The specific implementation of methods 5 and 7-8, in this application embodiment, provides an automatic graphics processing device based on Word documents, such as... Figure 11 As shown, it includes:

[0133] Splitting unit 1101 is used to split the single-page document containing non-embedded graphics from a Word document;

[0134] The first determining unit 1102 is used to determine the graphic area and line area of ​​the graphics in the single-page document;

[0135] The second determining unit 1103 is used to determine the graphic to be combined and the anchor position based on the positional relationship between the graphic regions of different graphics in the single-page document and the positional relationship between the graphic region and the row region.

[0136] Combination unit 1104 is used to combine the graphics to be combined and embed them into the Word document at the position corresponding to the anchor position.

[0137] It should be noted that other corresponding descriptions of the functional units involved in the automatic image processing device based on Word documents provided in this embodiment can be found in the following references. Figure 2 , 3 The corresponding descriptions in 5 and 7-8 will not be repeated here.

[0138] In a specific application scenario, the second determining unit includes:

[0139] The acquisition unit is used to acquire a target image from the images in the single-page document;

[0140] A movable range determining unit is used to determine the movable range of the target graphic;

[0141] A moving unit is used to move the graphic area of ​​the target graphic laterally within the movable range until it touches the target object, the target object including the graphic areas of other graphics, the line area where the text lines in the single-page document are located, and the extreme position of the movable range.

[0142] If the target object touched is within the graphic area of ​​another graphic, then the graphic area before movement and the graphic area of ​​the other graphic touched are superimposed and expanded to obtain an expanded graphic area; the graphic in the expanded graphic area is identified as the graphic to be combined and labeled with the same combination number; the expanded graphic area is used as the graphic area of ​​the target graphic, and the step of determining the movable range of the target graphic is repeated.

[0143] It should be noted that other corresponding descriptions of the functional units involved in the automatic image processing device based on Word documents provided in this embodiment can be found in the following references. Figure 2 , 3 The corresponding descriptions in 5 and 7-8 will not be repeated here.

[0144] In specific application scenarios, the second determining unit is further specifically used for:

[0145] If the target object touched is the line area where the text line is located in the single-page document or the limit position of the movable range, then the next target graphic is obtained from the graphic of the single-page document, and the step of determining the movable range of the target graphic is repeated.

[0146] It should be noted that other corresponding descriptions of the functional units involved in the automatic image processing device based on Word documents provided in this embodiment can be found in the following references. Figure 2 , 3 The corresponding descriptions in 5 and 7-8 will not be repeated here.

[0147] In specific application scenarios, the movable range determination unit includes:

[0148] The position type determination unit is used to determine the position type of each text line in the single-page document, wherein the position type includes full-width, left column and right column;

[0149] The comparison range determination unit is used to determine the comparison range based on the location type.

[0150] The final determination unit is used to determine the movable range of the target graphic based on the overlapping area of ​​the graphic region of the target graphic and the range to be compared.

[0151] It should be noted that other corresponding descriptions of the functional units involved in the automatic image processing device based on Word documents provided in this embodiment can be found in the following references. Figure 2 , 3 The corresponding descriptions in 5 and 7-8 will not be repeated here.

[0152] In specific application scenarios, the final determination unit is specifically used for:

[0153] Compare the size of the overlapping area between the graphic region of the target graphic and the range to be compared corresponding to different location types;

[0154] If the overlapping area between the graphic area of ​​the target graphic and the comparison range corresponding to the full-width column is the largest, or if there is no overlap with any comparison range, then the movable range is determined to be the page width range in the single-page document.

[0155] If the overlap area between the graphic area of ​​the target graphic and the comparison range corresponding to the left column is the largest, then the movable range is determined to be the column width range of the left column.

[0156] If the overlap area between the graphic area of ​​the target graphic and the comparison range corresponding to the right column is the largest, then the movable range is determined to be the width range of the right column.

[0157] It should be noted that other corresponding descriptions of the functional units involved in the automatic image processing device based on Word documents provided in this embodiment can be found in the following references. Figure 2 , 3 The corresponding descriptions in 5 and 7-8 will not be repeated here.

[0158] In specific application scenarios, the splitting unit is specifically used for:

[0159] The graphics in the Word document are labeled according to their graphic types, which include embedded graphic types and graphic object types;

[0160] Determine whether the graphic object type graphic's wrapping type information conforms to the following types: four-sided wrapping, through wrapping, tight wrapping, top and bottom wrapping, default type, floating above text type, or below text type.

[0161] If the conditions are met, extract the page number of the graphic object type containing the graphic.

[0162] Extract the single-page document corresponding to the page number from the Word document.

[0163] It should be noted that other corresponding descriptions of the functional units involved in the automatic image processing device based on Word documents provided in this embodiment can be found in the following references. Figure 2 , 3 The corresponding descriptions in 5 and 7-8 will not be repeated here.

[0164] In specific application scenarios, the first determining unit is specifically used for:

[0165] Obtain the top-left position, top-right position, and height of the text lines in the single-page document;

[0166] The lower right position is determined based on the upper right position and the height of the text line;

[0167] The row area is determined based on the upper left and lower right positions.

[0168] It should be noted that other corresponding descriptions of the functional units involved in the automatic image processing device based on Word documents provided in this embodiment can be found in the following references. Figure 2 , 3 The corresponding descriptions in 5 and 7-8 will not be repeated here.

[0169] Based on the above, Figure 2 , 3 Accordingly, embodiments of this application also provide a storage medium storing a computer program thereon, which, when executed by a processor, implements the methods described above. Figure 2 , 3 The automatic processing methods for graphics within Word documents are shown in 5 and 7-8.

[0170] Based on this understanding, the technical solution of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, or portable hard drive) and includes several instructions to cause an electronic device (such as a personal computer, server, or network device) to execute the methods described in the various implementation scenarios of this application.

[0171] Based on the above, Figure 2 , 3 The methods shown in 5 and 7-8, and Figure 11To achieve the above objectives, this application also provides a physical device for automatically processing graphics within a Word document, as illustrated in the virtual device embodiment. Specifically, this physical device can be a computer, smartphone, tablet, smartwatch, server, or network device, etc. The physical device includes a storage medium and a processor; the storage medium stores a computer program; the processor executes the computer program to achieve the above-described... Figure 2 , 3 The automatic processing methods for graphics within Word documents are shown in 5 and 7-8.

[0172] Optionally, the physical device may also include a user interface, a network interface, a camera, radio frequency (RF) circuitry, sensors, audio circuitry, a Wi-Fi module, etc. The user interface may include a display screen, input units such as a keyboard, etc., and optional user interfaces may also include USB interfaces, card reader interfaces, etc. The network interface may optionally include standard wired interfaces, wireless interfaces (such as Wi-Fi interfaces), etc.

[0173] Those skilled in the art will understand that the electronic device structure provided in this embodiment does not constitute a limitation on the electronic device, and may include more or fewer components, or combine certain components, or have different component arrangements.

[0174] The storage medium may also include an operating device and a network communication module. The operating device is a program that manages and stores the hardware and software resources of the electronic device, supporting the operation of information processing programs and other software and / or programs. The network communication module is used to enable communication between various controls within the storage medium, as well as communication with other hardware and software within the physical device.

[0175] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platform, or it can be implemented by hardware.

[0176] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of a preferred embodiment, and the units or processes shown in the drawings are not necessarily essential for implementing this application. Those skilled in the art will understand that the units in the apparatus of the embodiment can be distributed within the apparatus of the embodiment as described, or can be located in one or more apparatuses different from this embodiment, with corresponding changes. The units of the above-described embodiment can be combined into one unit, or further divided into multiple sub-units.

[0177] The serial numbers in this application are for descriptive purposes only and do not represent the superiority or inferiority of any particular implementation scenario. The above disclosures are merely a few specific implementation scenarios of this application; however, this application is not limited thereto, and any variations conceived by those skilled in the art should fall within the protection scope of this application.

Claims

1. A method for automatic processing of graphics within a Word document, characterized in that, include: Extract the single-page document containing non-embedded graphics from a Word document; Determine the graphic area and line area of ​​the graphics in the single-page document; Based on the positional relationship between the graphic regions of different graphics in the single-page document, and the positional relationship between the graphic regions and the row regions, determine the graphics to be combined and the anchor positions. The graphics to be combined are combined and embedded into the Word document at the position corresponding to the anchor position; The step of determining the graphics to be combined based on the positional relationships between the graphic regions of different graphics in the single-page document, and the positional relationships between the graphic regions and the line regions, includes: obtaining a target graphic from the graphics in the single-page document; determining the movable range of the target graphic; moving the graphic region of the target graphic horizontally within the movable range until it touches a target object, the target object including the graphic regions of other graphics, the line regions where the text lines in the single-page document are located, and the extreme position of the movable range; if the touched target object is the graphic region where other graphics are located, then the graphic region before movement and the graphic region where other graphics are touched are superimposed and expanded to obtain an expanded graphic region; determining the graphics in the expanded graphic region as the graphics to be combined, and labeling them with the same combination number; using the expanded graphic region as the graphic region of the target graphic, and repeating the step of determining the movable range of the target graphic.

2. The method according to claim 1, characterized in that, Also includes: If the target object touched is the line area where the text line is located in the single-page document or the limit position of the movable range, then the next target graphic is obtained from the graphic of the single-page document, and the step of determining the movable range of the target graphic is repeated.

3. The method according to claim 1, characterized in that, The step of determining the movable range of the target graphic includes: Determine the position type of each text line in the single-page document, where the position type includes full-width, left column, and right column; Based on the location type, determine the range to be compared; based on the overlapping area of ​​the target graphic's graphic region and the range to be compared, determine the movable range of the target graphic.

4. The method according to claim 3, characterized in that, The step of determining the movable range of the target graphic based on the overlapping area of ​​the graphic region of the target graphic and the range to be compared includes: Compare the size of the overlapping area between the graphic region of the target graphic and the range to be compared corresponding to different location types; If the overlapping area between the graphic area of ​​the target graphic and the comparison range corresponding to the full-width column is the largest, or if there is no overlap with any comparison range, then the movable range is determined to be the page width range in the single-page document. If the overlap area between the graphic area of ​​the target graphic and the comparison range corresponding to the left column is the largest, then the movable range is determined to be the column width range of the left column. If the overlap area between the graphic area of ​​the target graphic and the comparison range corresponding to the right column is the largest, then the movable range is determined to be the width range of the right column.

5. The method according to claim 1, characterized in that, The steps for extracting the single-page document containing non-embedded graphics from a Word document include: The graphics in the Word document are labeled according to their graphic types, which include embedded graphic types and graphic object types; Determine whether the graphic object type graphic's wrapping type information conforms to the following types: four-sided wrapping, through wrapping, tight wrapping, top and bottom wrapping, default type, floating above text type, or below text type. If the conditions are met, extract the page number of the graphic object type containing the graphic. Extract the single-page document corresponding to the page number from the Word document.

6. The method according to claim 1, characterized in that, The steps for determining the line region in a single-page document include: Obtain the top-left position, top-right position, and height of the text lines in the single-page document; The lower right position is determined based on the upper right position and the height of the text line; The row area is determined based on the upper left and lower right positions.

7. An automatic graphics processing device based on Word documents, characterized in that, include: Split Unit: Used to extract single-page documents containing non-embedded graphics from a Word document; The first determining unit is used to determine the graphic area and line area of ​​the graphics in the single-page document; The second determining unit is used to determine the graphic to be combined and the anchor position based on the positional relationship between the graphic regions of different graphics in the single-page document and the positional relationship between the graphic regions and the line regions. A combination unit is used to combine the graphics to be combined and embed them into the Word document at the position corresponding to the anchor position. The second determining unit includes: an acquisition unit, configured to acquire a target graphic from the graphics of the single-page document; a movable range determining unit, configured to determine the movable range of the target graphic; and a moving unit, configured to move the graphic area of ​​the target graphic laterally within the movable range until it touches a target object, wherein the target object includes the graphic areas of other graphics, the line area where the text lines in the single-page document are located, and the extreme position of the movable range; if the touched target object is the graphic area where other graphics are located, then the graphic area before the movement and the graphic area where other graphics are touched are superimposed and expanded to obtain an expanded graphic area; the graphics in the expanded graphic area are determined as graphics to be combined and labeled with the same combination number; the expanded graphic area is used as the graphic area of ​​the target graphic, and the step of determining the movable range of the target graphic is repeated.

8. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the automatic graphics processing method in a Word document as described in any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the automatic graphics processing method in a Word document as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Automatically placing an anchor for an object in a document

    US20110179350A1

  • Positioning graphical objects within previously formatted text

    US20130007601A1

  • Automatic grouping of document objects for reflowed layout

    US20160292132A1