Document page blank area determination method and device

By using preset size raster scanning and merging technology on the document page, the blank area is accurately identified and determined, and the problem of blank area identification is solved, and the intelligence and automation level of document processing is improved.

CN120452004APending Publication Date: 2025-08-08AEROSPACE FOXIT SOFTWARE (BEIJING) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510950141.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-10
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

It is difficult for the prior art to accurately determine the blank areas of documents, which affects the efficiency and accuracy of automated processing of functions such as electronic signatures, annotations and content completion.

Method used

Use a preset size grid to scan the document page, identify and merge the scan areas, determine the target blank area, and accurately identify the page blank area through the preset margin and object position information.

Benefits of technology

It improves the accuracy and efficiency of the identification of blank areas of the document, supports intelligent processing of documents, improves the accuracy of automatic signatures, annotations and content completion, and improves the layout quality and user experience of the document.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120452004A_ABST
    Figure CN120452004A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for determining a blank area of a document page, and relates to the technical field of computers.The method comprises the steps that for any target page of a document, based on a preset edge distance, a grid of a preset size is adopted to scan the area, except the preset edge distance, in a rendered page corresponding to the target page, obtaining a plurality of scanning areas corresponding to the grids; and determining a page blank area of the target page based on each target blank area under the condition that each scanning area is determined to be the target blank area. The areas except the preset edge distance in the rendered page corresponding to the target page are scanned through the grids of the preset size, all the scanning areas are determined to be the target blank areas, accurate determination of the page blank areas is achieved, the accuracy and efficiency of the page blank areas are improved, support is provided for intelligent and automatic processing of documents, and the document processing efficiency is improved. And a basis is provided for content insertion and typesetting optimization, so that the document processing efficiency, the typesetting quality and the user experience are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for determining a blank area of a document. Background Art

[0002] With the widespread use of formatted documents in e-office fields such as e-government, finance, and contract management, the demand for automated and batch processing of such documents is also increasing. To improve the efficiency and accuracy of document processing, functions such as electronic signatures, batch signature positioning, intelligent annotations, and content completion are gradually becoming mainstream applications. For example, in the automatic signature scenario, the system needs to accurately identify the signature position and avoid overlapping with existing content; when automatically annotating, the system should determine the blank area to reasonably insert the annotation information; at the same time, for form documents, the system must also intelligently detect missing fields and automatically complete the blank spaces with key information such as table items, QR codes, numbers, and review comments. In addition, to improve the quality of document layout, it is also necessary to analyze the document structure, identify problems such as empty paragraphs, improper layout, and excessive white space, and provide optimization suggestions such as automatically compressing the number of pages, rearranging the layout, and reducing the gaps.

[0003] However, the common premise of all these applications is the accurate identification and analysis of blank areas on the page. Therefore, blank area detection technology has become one of the core basic capabilities to promote the intelligent processing of layout documents.

[0004] Therefore, how to accurately determine the blank area of a document is a technical problem that needs to be solved urgently. Summary of the Invention

[0005] The present invention provides a document blank area determination method and device, which are used to solve the problem of how to accurately determine the blank area of a document.

[0006] The present invention provides a method for determining a blank area of a document, comprising: For any target page of the document, based on a preset margin, a grid of a preset size is used to scan an area of a rendering page corresponding to the target page except for the preset margin, to obtain multiple scanning areas corresponding to the grid; In the case where each of the scanning areas is determined as a target blank area, a page blank area of the target page is determined based on each of the target blank areas.

[0007] According to a document blank area determination method provided by the present invention, the target page includes at least one target object; and the step of determining each of the scanning areas as a target blank area includes: Determine position information of a target area corresponding to each target object on the rendering page; For each of the scanning areas, based on the position information, determining whether the scanning area overlaps with the target area; In a case where the scanning area does not overlap with the target area, the scanning area is determined to be the target blank area.

[0008] According to a document blank area determination method provided by the present invention, determining the page blank area of the target page based on each target blank area includes: For each target blank area in any row, sorting each target blank area based on the horizontal coordinate of each target blank area; Merging the sorted target blank areas to obtain at least one first target merged blank area; Based on each of the first target merged blank areas, a page blank area of the target page is determined.

[0009] According to a document blank area determination method provided by the present invention, the merging manner includes at least one of the following: merging horizontally first and then vertically, merging vertically first and then horizontally, and merging horizontally and vertically in a crosswise manner.

[0010] According to a document blank area determination method provided by the present invention, when the merging method includes first merging horizontally and then merging vertically, merging the sorted target blank areas to obtain at least one first target merged blank area includes: Merging the sorted target blank areas horizontally to obtain at least one second target merged blank area; Each of the second target merged blank areas is vertically merged to obtain at least one first target merged blank area.

[0011] According to a document blank area determination method provided by the present invention, horizontally merging the sorted target blank areas to obtain at least one second target merged blank area includes: Based on any one of the sorted target blank areas, determining whether the target blank area has an adjacent blank area; In a case where the target blank area does not have the adjacent blank area, taking the target blank area as the second target merged blank area; In the case that the target blank area has the adjacent blank area, any one of the target blank areas is merged with the adjacent blank area to obtain a second merged blank area, and the second merged blank area is used as the target blank area for the next horizontal merger. The step of determining whether the target blank area has an adjacent blank area is repeatedly performed until the target blank area does not have the adjacent blank area, and the finally obtained second merged blank area is used as the second target merged blank area.

[0012] According to a document blank area determination method provided by the present invention, vertically merging each of the second target merged blank areas to obtain at least one first target merged blank area includes: For each of the second-target merged blank areas in any row, sorting the second-target merged blank areas based on the horizontal coordinates of the second-target merged blank areas; Based on the sorted second target merged blank areas, determining whether there is a target merged blank area horizontally aligned with the second target merged blank area in each of the second target merged blank areas in the next row adjacent to the any row; In a case where there is no target merging blank area that is horizontally aligned with the second target merging blank area, using the second target merging blank area as the first target merging blank area; In the case that there is a target merging blank area that is horizontally aligned with the second target merging blank area, the second target merging blank area and the horizontally aligned target merging blank area are merged to obtain a first merged blank area, and the first merged blank area is used as the target blank area for the next vertical merger, and the step of determining whether there is a target merging blank area that is horizontally aligned with the second target merging blank area in each of the second target merging blank areas in the next row adjacent to any row is repeated until there is no target merging blank area that is horizontally aligned with the second target merging blank area, and the first merged blank area finally obtained is used as the first target merging blank area.

[0013] According to a document blank area determination method provided by the present invention, the method further includes: Based on the size of the object to be inserted, traverse the sorted target blank areas in the page blank area of the target page to determine at least one target blank area that matches the size of the object to be inserted; Insert the object to be inserted into the at least one matching target blank area.

[0014] The present invention also provides a document page blank area determination device, comprising: A scanning module, configured to scan, for any target page of a document, an area of a rendering page corresponding to the target page, excluding the preset margins, using a grid of a preset size based on preset margins, to obtain a plurality of scanning areas corresponding to the grid; The first determining module is configured to determine the page blank area of the target page based on each target blank area when each scanning area is determined to be a target blank area.

[0015] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, any of the above-described methods for determining a blank area on a document page is implemented.

[0016] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-mentioned methods for determining a blank area on a document page.

[0017] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned methods for determining a blank area on a document page.

[0018] The present invention provides a document page blank area determination method and device. For any target page of a document, based on preset margins, a grid of preset size is used to scan the area of a rendered page corresponding to the target page, excluding the preset margins, to obtain multiple scan areas corresponding to the grid. After each of the scan areas is determined to be a target blank area, the page blank area of the target page is determined based on each of the target blank areas. By scanning the area of the rendered page corresponding to the target page, excluding the preset margins, using a grid of preset size, and determining each of the scan areas as a target blank area, accurate determination of the page blank area is achieved, improving the accuracy and efficiency of the page blank area, providing support for intelligent and automated document processing, and providing a basis for content insertion and typesetting optimization, thereby improving document processing efficiency, typesetting quality, and user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0020] Figure 1 This is one of the flow charts of the method for determining the blank area of a document page provided by the present invention.

[0021] Figure 2 Schematic diagram of a rendering page provided by the present invention.

[0022] Figure 3 Schematic diagram of multiple target blank areas provided by the present invention.

[0023] Figure 4 This is a schematic diagram of the result of first horizontal merging and then vertical merging provided by the present invention.

[0024] Figure 5 This is a schematic diagram of the result of first vertical merging and then horizontal merging provided by the present invention.

[0025] Figure 6 This is a schematic diagram of inserting a signature after first merging horizontally and then vertically, as provided by the present invention.

[0026] Figure 7 This is a schematic diagram of inserting a signature after vertical merging and horizontal merging provided by the present invention.

[0027] Figure 8 This is the second flow chart of the method for determining the blank area of a document page provided by the present invention.

[0028] Figure 9 It is a structural schematic diagram of the document page blank area determination device provided by the present invention.

[0029] Figure 10 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0030] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0031] The following combination Figures 1-8 The document page blank area determination method of the present invention is described.

[0032] Figure 1 This is one of the flow charts of the method for determining the blank area of a document page provided by the present invention. Figure 1 As shown, the method includes the following steps 101 and 102.

[0033] Step 101 : For any target page of a document, based on a preset margin, a grid of a preset size is used to scan an area of a rendering page corresponding to the target page except for the preset margin to obtain multiple scanning areas corresponding to the grid.

[0034] It should be noted that the document page blank area determination method provided by the present invention can be applied to the blank area detection scenario of the document, for example, the detection of the blank area of the PDF document or the OFD document; the execution subject of the method can be a document page blank area determination device, such as an electronic device, or a control module in the document page blank area determination device for executing the document page blank area determination method.

[0035] Specifically, the target page is any specified page in the document, such as page 1. The preset margins are preset left and right margins and / or top and bottom margins, for example, the preset left and right margins are 0, or the preset left and right margins are 120px. The preset grid size can be set and adjusted according to the actual scenario. The height and width of the preset grid size can be the same or different. For example, the height and width of the preset grid size are both 10, that is, gridSize=10.

[0036] Before scanning, the document's page layout is parsed and the content area of each page is read. The content of each page includes at least one target object, including but not limited to at least one of the following: text, image, annotation, table, signature, and QR code. For any target page of the document, the screen coordinate size of the rendered page, i.e., width viewWidth and height viewHeight, is calculated based on the document coordinate size of the target page. The target page is rendered to obtain the rendered page, i.e., the rendered viewport. Figure 2 is a schematic diagram of a rendering page provided by the present invention, such as Figure 2 Extract the target area corresponding to each target object (such as text, image, table, comment or signature) in the target page and put the target area into textBoxes.

[0037] A grid of preset size is used to scan the area of the rendering page corresponding to the target page, excluding the preset margins, to obtain multiple scanning areas corresponding to the grid. The scanning method can be from left to right and then from top to bottom, or from right to left and then from bottom to top, or other scanning methods are all possible, and there is no limitation on this. It should be noted that the scanning step size is the grid size gridSize. If the grid is not square, the side length corresponding to the grid in the scanning direction is taken as the step size. During scanning, multiple scanning areas corresponding to the grid can be obtained, for example, a dynamic scanning matrix box gridBox:{x:gx,y:gy,width:gridSize,height:gridSize}, where gx is the value of the x-coordinate from left to right, in the range of [0,viewWidth], and gy is the value of the y-coordinate from top to bottom, in the range of [0,viewHeight].

[0038] Step 102 : When each of the scan areas is determined to be a target blank area, determine a page blank area of the target page based on each of the target blank areas.

[0039] Specifically, a minimum width and a minimum height are preset for the target blank area, and only areas larger than or equal to the size are considered the target blank area, while areas smaller than the size are filtered out. For example, the minimum width and the minimum height of the target blank area are both preset to 0.

[0040] In the case where each scanning area is determined as a target blank area, the page blank area of the target page may be determined based on each target blank area.

[0041] The present invention provides a method for determining blank areas on a document page. For any target page of a document, based on preset margins, a grid of a preset size is used to scan the area of a rendered page corresponding to the target page, excluding the preset margins, to obtain multiple scan areas corresponding to the grid. Upon determining that each scan area is a target blank area, the blank area of the target page is determined based on each target blank area. By scanning the area of the rendered page corresponding to the target page, excluding the preset margins, using a grid of a preset size, and determining each scan area as a target blank area, accurate determination of the blank area is achieved, improving the accuracy and efficiency of the blank area, providing support for intelligent and automated document processing, and providing a basis for content insertion and typesetting optimization, thereby improving document processing efficiency, typesetting quality, and user experience.

[0042] Optionally, the target page includes at least one target object; and determining each of the scanning areas as a target blank area includes: Determine the position information of the target area corresponding to each target object on the rendering page; for each of the scanning areas, determine whether the scanning area overlaps with the target area based on the position information; if the scanning area does not overlap with the target area, determine that the scanning area is the target blank area.

[0043] Specifically, the target object includes but is not limited to at least one of the following: text, images, annotations, tables, and signatures; the location information includes the horizontal coordinate x, the vertical coordinate y, the width width, and the height height. When the target object is an object other than text, the location information of the target area corresponding to the target object on the rendering page can be directly obtained, for example, the lower left point of p1 (x, y), the lower right point of p2 (x+width, y), the upper right point of p3 (x+width, y), and the upper left point of p4 (x, y), recorded as the closed contour [p1, p2, p3, p4, p1]. From this, it can be obtained that the target area corresponding to other objects other than text on the rendering page can be represented as a rectangle {x, y, width, height}, and these coordinates are converted to view coordinates and placed in textBoxes.

[0044] If the target object is text, the rotation and scaling information can be obtained from the target page's two-dimensional affine transformation matrix. The two-dimensional affine transformation matrix is represented as [a,b,c,d,e,f], where a and b control the scaling and rotation in the x-direction (i.e., width and tilt), c and d control the scaling and rotation in the y-direction (i.e., height and tilt), and e and f are displacements (corresponding to the x / y position). Based on the rotation and scaling information, Math.hypot(a,b) can be used to calculate the length (i.e., modulus) of the x-vector (a,b): In the PDF affine transformation, the x-direction modulus represents the vertical font height, i.e., the font size. The y-direction modulus is calculated in the same way as the x-direction. The x-direction modulus represents the actual height (new_height) of the target area corresponding to the text on the rendered page. Based on new_height and the vertical coordinate y, yTop=y-new_height is used. Ascent determines the target vertical coordinate (yTop) of the target area corresponding to the text, where ascent represents a preset empirical value. It's important to note that because the document's height and font size (fontSize) are not equal to the visible height, an empirical value (ascent) is required. This empirical value depends on the text's font. The text's baseline coordinates cannot be used as a standard for the text's outline coordinates, so the target vertical coordinate of the target area must be recalculated. Based on the x coordinate, y coordinate, width, and target vertical coordinate (yTop), the position of the target area corresponding to the text on the rendered page can be determined. For example, p1's lower left point is (x, yTop), p2's lower right point is (x+width, yTop), p3's upper right point is (x+width, y), and p4's upper left point is (x, y), denoted as the closed contour [p1, p2, p3, p4, p1]. This indicates that the area occupied by the target area on the rendered page can be represented as a rectangle {x, yTop, width, new_height}. These coordinates are converted to view coordinates and placed in the textBoxes.

[0045] For each scanning area, based on the second position information, determine whether the scanning area coincides with the target area; if the scanning area does not coincide with the target area, determine that the scanning area is a target blank area, and add the target blank area to the blank area array blankGrid, Figure 3 is a schematic diagram of multiple target blank areas provided by the present invention, such as Figure 3 When the scanning area coincides with the target area, it is determined that the scanning area is not a target blank area.

[0046] Optionally, a specific implementation of step 102 includes: For each target blank area in any row, sort each target blank area based on the horizontal coordinate of each target blank area; merge the sorted target blank areas to obtain at least one first target merged blank area; and determine the page blank area of the target page based on each first target merged blank area.

[0047] Specifically, if Figure 3 As shown, although multiple target blank areas are obtained, they are too fragmented and inconvenient to use, and these target blank areas need to be merged.

[0048] For each target blank area in any row (i.e., with the same y value, ranging from [0 to viewHeight]), traverse each target blank area in each row, with a step size equal to the grid side length (gridSize, for example, 10px). Based on the x-coordinates of each target blank area in any row, sort the target blank areas from left to right according to their x-coordinates to facilitate identification of consecutive target blank areas. Merge the sorted target blank areas to obtain at least one first target merged blank area; each first target merged blank area is then determined as the page blank area of the target page.

[0049] Optionally, the merging method includes at least one of the following: merging horizontally first and then vertically, merging vertically first and then horizontally, and merging horizontally and vertically in a crosswise manner.

[0050] Specifically, in the horizontal merge followed by the vertical merge, the horizontal merge is to merge the adjacent target blank areas on the same row horizontally into a larger blank area, and add the merged larger blank area to the result array of the horizontal merge mergedHorizonta; in the vertical merge followed by the horizontal merge, the vertical merge is to further perform a "vertical merge" on the basis of the result array of the horizontal merge mergedHorizontal, that is, to merge the blank areas that are adjacent to each other and overlap in horizontal positions into a larger blank area, and put the merged blank areas into the result array mergedRects, until all blank areas in mergedHorizontal are processed.

[0051] Merging vertically and then horizontally is to first merge the blank areas that are adjacent to each other vertically and overlap in horizontal positions in the vertical direction to obtain a larger blank area, and put the merged blank areas into the result array mergedVertical until all the target blank areas in the array blankGrid to be merged are processed; after the vertical merge, the blank areas in the result array mergedVertical are merged horizontally, that is, the blank areas that are adjacent to each other horizontally and aligned in the top and bottom are further merged into a larger blank area, and the merged blank areas are added to the result array mergedRects until all the blank areas in mergedVertical are processed.

[0052] Cross-merging is to determine adjacent target blank areas that can be merged in the vertical direction or the horizontal direction, where the adjacent target blank areas can be vertically adjacent or horizontally adjacent target blank areas; merge the determined adjacent target blank areas that can be merged, and add the merged blank areas to the result array mergedRects.

[0053] It should be noted that all blank areas in the result array mergedRects are sorted from bottom to top, from top to bottom, from right to left, or from left to right, so as to facilitate subsequent processing. Figure 4 This is a schematic diagram of the result of first horizontal merging and then vertical merging provided by the present invention. Figure 5 This is a schematic diagram of the result of first vertical merging and then horizontal merging provided by the present invention, such as Figure 4 and 5 As shown, the blank areas in the text part are the blank areas obtained after merging, and the numbers are the numbers of the blank areas after sorting.

[0054] In addition, the two methods of "merge horizontally first and then vertically" and "merge vertically first and then horizontally" can be used as needed. That is, different methods can be used according to different types of documents, or they can be used in combination. The area to be inserted into the two merged results can be determined to improve the utilization of blank areas.

[0055] Optionally, when the merging method includes first merging horizontally and then merging vertically, merging the sorted target blank areas to obtain at least one first target merged blank area includes: The sorted target blank areas are merged horizontally to obtain at least one second target merged blank area; and the second target merged blank areas are merged vertically to obtain at least one first target merged blank area.

[0056] Specifically, when the merging method includes first horizontal merging and then vertical merging, the target blank areas sorted according to the horizontal coordinate x of the target blank area are horizontally merged to obtain at least one second target merged blank area, and the second target merged blank area represents the blank area after each row is merged; then, on the basis of the horizontal merging, the second target merged blank areas are vertically merged to obtain at least one first target merged blank area.

[0057] Optionally, horizontally merging the sorted target blank areas to obtain at least one second target merged blank area includes: Based on any one of the sorted target blank areas, determine whether the target blank area has an adjacent blank area; if the target blank area does not have the adjacent blank area, use the target blank area as the second target merged blank area; if the target blank area has the adjacent blank area, merge any one of the target blank areas with the adjacent blank area to obtain a second merged blank area, use the second merged blank area as the target blank area for the next horizontal merge, and repeat the step of determining whether the target blank area has an adjacent blank area until the target blank area does not have the adjacent blank area, and use the finally obtained second merged blank area as the second target merged blank area.

[0058] Specifically, based on any target blank area start in the sorted target blank areas, determine whether the target blank area has an adjacent blank area box; if the target blank area does not have an adjacent blank area, it means that other target blank areas before the target blank area have been merged or the target blank area is the last blank area, and the target blank area is taken as the second target merged blank area and added to the merged array mergedHorizontal.

[0059] When there is an adjacent blank area in the target blank area, any target blank area is merged with the adjacent blank area to obtain a second merged blank area, that is, the width of any target blank area start is expanded, and the second merged blank area is used as the target blank area for the next horizontal merge, and the step of determining whether there is an adjacent blank area in the target blank area is repeated until there is no adjacent blank area in the target blank area. The final second merged blank area is used as the second target merged blank area and added to the merged array mergedHorizontal.

[0060] Optionally, the vertically merging the second target merged blank areas to obtain at least one first target merged blank area includes: For each second-target merged blank area in any row, sort each second-target merged blank area based on the horizontal coordinate of each second-target merged blank area; based on any sorted second-target merged blank area, determine whether there is a target merged blank area horizontally aligned with the second target merged blank area in each second-target merged blank area in the next row adjacent to the any row; if there is no target merged blank area horizontally aligned with the second target merged blank area, use the second target merged blank area as the first target merged blank area; if there is a target merged blank area horizontally aligned with the second target merged blank area, merge the second target merged blank area and the horizontally aligned target merged blank area to obtain a first merged blank area, use the first merged blank area as the target blank area for the next vertical merge, and repeat the step of determining whether there is a target merged blank area horizontally aligned with the second target merged blank area in each second-target merged blank area in the next row adjacent to the any row until there is no target merged blank area horizontally aligned with the second target merged blank area, and use the first merged blank area finally obtained as the first target merged blank area.

[0061] Specifically, on the basis of horizontal merging, for each second target merged blank area in any row of the array mergedHorizontal, sort the second target merged blank areas from left to right based on the horizontal coordinate x of each second target merged blank area. If x is the same, sort them from top to bottom according to the vertical coordinate y. This makes it easy to find the second target merged blank areas that are adjacent above and below.

[0062] Based on any sorted second target merged blank area (i.e., the base rectangle base), the remaining second target merged blank areas in the array mergedHorizontal are then determined to determine whether there is a target merged blank area in each second target merged blank area in the next row adjacent to any row that is horizontally aligned with the second target merged blank area, and any second target merged blank area is deleted from the array mergedHorizontal. Horizontal alignment means that the horizontal coordinates x and widths width are the same (i.e., the widths are consistent). If there is no target merged blank area that is horizontally aligned with the second target merged blank area, it means that the other second target blank areas in the row before the corresponding row of the second target blank area have been merged or the second target blank area is the last blank area vertically. The second target merged blank area is then added to the merged array mergedRects as the first target merged blank area.

[0063] In the case that there is a target merged blank area that is horizontally aligned with the second target merged blank area, the second target merged blank area and the horizontally aligned target merged blank area are merged to obtain a first merged blank area, that is, the height of base is increased, and any second target merged blank area is deleted from the array mergedHorizontal. The first merged blank area is used as the target blank area for the next vertical merge, and the step of whether there is a target merged blank area that is horizontally aligned with the second target merged blank area in each second target merged blank area in the next row adjacent to any row is repeated until there is no target merged blank area that is horizontally aligned with the second target merged blank area, that is, all second target merged blank areas in mergeHorizontal are processed, and the first merged blank area finally obtained is used as the first target merged blank area.

[0064] Optionally, when the merging method includes first merging vertically and then merging horizontally, merging the sorted target blank areas to obtain at least one first target merged blank area includes: The sorted target blank areas are vertically merged to obtain at least one third target merged blank area; and the third target merged blank areas are horizontally merged to obtain at least one first target merged blank area.

[0065] Optionally, vertically merging the sorted target blank areas to obtain at least one third target merged blank area includes: For each sorted target blank area in any row, if the horizontal coordinates x of each target blank area are the same, they are sorted in ascending order according to the vertical coordinate y, and the vertically aligned target blank areas are arranged together to facilitate merging one by one.

[0066] Based on any target blank area (i.e., base) among the sorted target blank areas, determine whether there is a target merged blank area in the next row adjacent to any row that is horizontally aligned with the target merged blank area; if there is no target merged blank area that is horizontally aligned with the target merged blank area, use the target merged blank area as the third target merged blank area and delete it from the array blankGrid.

[0067] In the case that there is a target merged blank area that is horizontally aligned with the target merged blank area, the target merged blank area and the horizontally aligned target merged blank area are merged to obtain a second merged blank area, and the second merged blank area is used as the target blank area for the next vertical merge, that is, the base is expanded into a first higher rectangle, and the second merged blank area is added to the result array mergedVertical, and the steps of whether there is a target merged blank area horizontally aligned with the second target merged blank area in each target merged blank area in the next row adjacent to any row are repeated until there is no target merged blank area horizontally aligned with the target merged blank area, that is, until all target blank areas in the array blankGrid are processed, and the final second merged blank area is used as the third target merged blank area.

[0068] Optionally, horizontally merging the third target merged blank areas to obtain at least one first target merged blank area includes: Based on the horizontal coordinates of each third-target merged blank area, the third-target merged blank areas are sorted; based on any third-target blank area (i.e., base) among the third-target merged blank areas in the sorted mergedVertical, it is determined whether the third-target blank area has an adjacent blank area, that is, whether there is a blank area that is adjacent to the left and right and aligned with the top and bottom edges; if the third-target blank area does not have an adjacent blank area, the third-target blank area is used as the first-target merged blank area, and the third-target blank area is added to the result array mergedRects.

[0069] If there is an adjacent blank area in the third target blank area, merge any third target blank area with the adjacent blank area to obtain a third merged blank area, and use the third merged blank area as the third target blank area for the next horizontal merge, that is, expand base into a rectangle with a higher height, and repeat the step of determining whether there is an adjacent blank area in the third target blank area until there is no adjacent blank area in the third blank area, that is, all third target blank areas in mergedVertical are processed, and the final third merged blank area is used as the first target merged blank area, and the final third target blank area is added to the result array mergedRects.

[0070] Optionally, the method further includes: Based on the size of the object to be inserted, the sorted target blank areas in the page blank area of the target page are traversed to determine at least one target blank area that matches the size of the object to be inserted; and the object to be inserted is inserted into the at least one matching target blank area.

[0071] Specifically, the object to be inserted can be a signature, annotation, or QR code. The size of the signature is set based on the actual situation. For example, if the size of the signature is 120, it is a square. The sorted blank areas of the target page are denoted as sortedRects. As many signature rectangles (small squares) of 120 as possible are placed in sortedRects, ensuring that the signatures do not overlap.

[0072] Based on the size of the object to be inserted, the target blank areas of the target page are sorted and traversed to determine at least one target blank area that matches the size of the object to be inserted. The traversal order can be set according to actual conditions. For example, the traversal order can be set to start from the lower right corner of the page, traverse from right to left, and then from bottom to top. The traversal order can also be set to start from other corners of the page. The traversal step size is the side length (width) of the object to be inserted.

[0073] If the traversed target blank area is within the range contained by mergedRects, and the object to be inserted has not been inserted into this target blank area, then the object to be inserted is inserted at this position of the target blank area, that is, the object to be inserted is inserted into at least one matching target blank area.

[0074] Figure 6 This is a schematic diagram of inserting a signature after horizontal merging and vertical merging provided by the present invention. Figure 7 This is a schematic diagram of inserting a signature after vertical merging and horizontal merging provided by the present invention, as shown in FIG. Figure 6 and Figure 7 As shown, the signature area is represented by a dotted border, and the signature number is represented by a number, where: Figure 6 This is a diagram showing how to insert a signature after merging horizontally and vertically when the left and right margins are preset to 0. Figure 7 A diagram showing how to insert a signature after vertical merging and horizontal merging when the preset left and right margins are 120px.

[0075] Figure 8 This is a second flow chart of the method for determining the blank area of a document page provided by the present invention. Figure 8 As shown, the method includes steps 801 to 814.

[0076] Step 801: parse the page layout of the document and read the area containing content on each page.

[0077] Step 802: For any target page of the document, calculate the screen coordinate size of the rendered page according to the document coordinate size of the target page.

[0078] Step 803: Extract the target area corresponding to each target object in the target page.

[0079] Step 804 : Scan the area of the rendering page corresponding to the target page except for the preset margin using a grid of a preset size to obtain multiple scan areas corresponding to the grid.

[0080] Step 805: Preset a minimum width and a minimum height for the target blank area.

[0081] Step 806: Determine the location information of the target area corresponding to each target object on the rendering page.

[0082] Step 807 : For each scanning area, determine whether the scanning area overlaps with the target area based on the position information; if the scanning area does not overlap with the target area, go to step 808 ; if the scanning area overlaps with the target area, go to step 809 .

[0083] Step 808: Determine that the scan area is a target blank area.

[0084] Step 809: Determine whether the scan area is a target blank area.

[0085] Step 810 : sort the target blank areas in any row based on their horizontal coordinates.

[0086] Step 811 : Merge the sorted target blank areas by adopting at least one of horizontal merging first and then vertical merging, vertical merging first and then horizontal merging, and horizontal and vertical cross merging to obtain at least one first target merged blank area.

[0087] Step 812: Determine the page blank area of the target page based on the first target merged blank areas.

[0088] Step 813: Based on the size of the object to be inserted, traverse the sorted target blank areas in the page blank area of the target page to determine at least one target blank area that matches the size of the object to be inserted.

[0089] Step 814: Insert the object to be inserted into at least one matching target blank area.

[0090] The method for determining blank areas of document pages provided by the present invention can improve the automation processing capability, provide a spatial basis for inserting signatures, annotations, QR codes and other information into blank areas, and realize functions such as automatic signature and automatic annotation; it can ensure the reasonable layout of content, avoid overlapping of new content with the main text, and maintain the clarity and readability of the document content; it can assist in layout optimization, and by analyzing the distribution of blank areas, support page compression, re-typesetting, and removal of redundant gaps to improve the document typesetting quality; it can promote batch processing efficiency, and improve the efficiency and accuracy of automatic positioning and insertion in scenarios such as batch signatures and batch annotations; it can enhance the intelligent completion function, help the system identify insertable positions, and automatically fill in missing fields or elements; it can support structural verification and standardization inspection, discover problems such as excessive blank space and empty paragraphs, and contribute to document quality control, thereby significantly improving document processing efficiency, typesetting quality and user experience.

[0091] The document page blank area determination device provided by the present invention is described below. The document page blank area determination device described below and the document page blank area determination method described above can refer to each other.

[0092] Figure 9 Schematic diagram of the structure of the document page blank area determination device provided by the present invention, such as Figure 9 As shown, the document page blank area determination device 900 includes: a scanning module 901 and a first determination module 902; wherein, Scanning module 901 is configured to scan, for any target page of a document, an area of a rendering page corresponding to the target page excluding the preset margins using a grid of a preset size based on a preset margin, to obtain multiple scan areas corresponding to the grid; The first determining module 902 is configured to determine a page blank area of the target page based on each target blank area when each scanning area is determined to be a target blank area.

[0093] The document page blank area determination device provided by the present invention scans, for any target page of a document, an area of a rendered page corresponding to the target page, excluding the preset margins, using a grid of a preset size, to obtain multiple scan areas corresponding to the grid; and upon determining each of the scan areas as a target blank area, determines the page blank area of the target page based on each of the target blank areas. By scanning the area of the rendered page corresponding to the target page, excluding the preset margins, using a grid of a preset size, and determining each of the scan areas as a target blank area, accurate determination of the page blank area is achieved, improving the accuracy and efficiency of the page blank area, providing support for intelligent and automated document processing, and providing a basis for content insertion and typesetting optimization, thereby improving document processing efficiency, typesetting quality, and user experience.

[0094] Optionally, the target page includes at least one target object; the first determining module 902 is specifically configured to: Determine position information of a target area corresponding to each target object on the rendering page; For each of the scanning areas, based on the position information, determining whether the scanning area overlaps with the target area; In a case where the scanning area does not overlap with the target area, the scanning area is determined to be the target blank area.

[0095] Optionally, the first determining module 902 is further configured to: For each target blank area in any row, sorting each target blank area based on the horizontal coordinate of each target blank area; Merging the sorted target blank areas to obtain at least one first target merged blank area; Based on each of the first target merged blank areas, a page blank area of the target page is determined.

[0096] Optionally, the merging method includes at least one of the following: merging horizontally first and then vertically, merging vertically first and then horizontally, and merging horizontally and vertically in a crosswise manner.

[0097] Optionally, when the merging method includes first merging horizontally and then merging vertically, the first determining module 902 is further configured to: Merging the sorted target blank areas horizontally to obtain at least one second target merged blank area; Each of the second target merged blank areas is vertically merged to obtain at least one first target merged blank area.

[0098] Optionally, the first determining module 902 is further configured to: Based on any one of the sorted target blank areas, determining whether the target blank area has an adjacent blank area; In a case where the target blank area does not have the adjacent blank area, taking the target blank area as the second target merged blank area; In the case that the target blank area has the adjacent blank area, any one of the target blank areas is merged with the adjacent blank area to obtain a second merged blank area, and the second merged blank area is used as the target blank area for the next horizontal merger. The step of determining whether the target blank area has an adjacent blank area is repeatedly performed until the target blank area does not have the adjacent blank area, and the finally obtained second merged blank area is used as the second target merged blank area.

[0099] Optionally, the first determining module 902 is further configured to: For each of the second-target merged blank areas in any row, sorting the second-target merged blank areas based on the horizontal coordinates of the second-target merged blank areas; Based on the sorted second target merged blank areas, determining whether there is a target merged blank area horizontally aligned with the second target merged blank area in each of the second target merged blank areas in the next row adjacent to the any row; In a case where there is no target merging blank area that is horizontally aligned with the second target merging blank area, using the second target merging blank area as the first target merging blank area; In the case that there is a target merging blank area that is horizontally aligned with the second target merging blank area, the second target merging blank area and the horizontally aligned target merging blank area are merged to obtain a first merged blank area, and the first merged blank area is used as the target blank area for the next vertical merger, and the step of determining whether there is a target merging blank area that is horizontally aligned with the second target merging blank area in each of the second target merging blank areas in the next row adjacent to any row is repeated until there is no target merging blank area that is horizontally aligned with the second target merging blank area, and the first merged blank area finally obtained is used as the first target merging blank area.

[0100] Optionally, the document page blank area determination device 900 further includes: Based on the size of the object to be inserted, traverse the sorted target blank areas in the page blank area of the target page to determine at least one target blank area that matches the size of the object to be inserted; Insert the object to be inserted into the at least one matching target blank area.

[0101] Figure 10 This is a schematic diagram of the physical structure of an electronic device provided by the present invention, such as Figure 10As shown, the electronic device may include: a processor 1010, a communications interface 1020, a memory 1030, and a communications bus 1040, wherein the processor 1010, the communications interface 1020, and the memory 1030 communicate with each other via the communications bus 1040. The processor 1010 may call logic instructions in the memory 1030 to execute a document page blank area determination method, the method comprising: for any target page of the document, based on a preset margin, using a grid of a preset size to scan an area of a rendering page corresponding to the target page, excluding the preset margin, to obtain multiple scan areas corresponding to the grid; and when each of the scan areas is determined to be a target blank area, determining the page blank area of the target page based on each of the target blank areas.

[0102] Furthermore, the logic instructions in the aforementioned memory 1030 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0103] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the document page blank area determination method provided by the above methods, the method including: for any target page of the document, based on a preset margin, using a grid of a preset size to scan the area of the rendering page corresponding to the target page except the preset margin, to obtain multiple scanning areas corresponding to the grid; when each of the scanning areas is determined to be a target blank area, the page blank area of the target page is determined based on each of the target blank areas.

[0104] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the document page blank area determination method provided by the above-mentioned methods, the method comprising: for any target page of the document, based on a preset margin, using a grid of a preset size to scan the area of the rendering page corresponding to the target page except the preset margin, to obtain multiple scanning areas corresponding to the grid; when each of the scanning areas is determined to be a target blank area, determining the page blank area of the target page based on each of the target blank areas.

[0105] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0106] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.

[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A method for determining a blank area on a document page, characterized in that: include: For any target page of the document, based on a preset margin, a grid of a preset size is used to scan an area of a rendering page corresponding to the target page except for the preset margin, to obtain multiple scanning areas corresponding to the grid; In the case where each of the scanning areas is determined as a target blank area, a page blank area of the target page is determined based on each of the target blank areas.

2. The method for determining a blank area of a document page according to claim 1, wherein: The target page includes at least one target object; and determining each of the scanning areas as a target blank area includes: Determine position information of a target area corresponding to each target object on the rendering page; For each of the scanning areas, based on the position information, determining whether the scanning area overlaps with the target area; In a case where the scanning area does not overlap with the target area, the scanning area is determined to be the target blank area.

3. The method for determining a blank area of a document page according to claim 1, wherein: The determining of the page blank area of the target page based on each of the target blank areas includes: For each target blank area in any row, sorting each target blank area based on the horizontal coordinate of each target blank area; Merging the sorted target blank areas to obtain at least one first target merged blank area; Based on each of the first target merged blank areas, a page blank area of the target page is determined.

4. The method for determining a blank area of a document page according to claim 3, wherein: The merging method includes at least one of the following: merging horizontally first and then vertically, merging vertically first and then horizontally, and merging horizontally and vertically in a crosswise manner.

5. The method for determining a blank area of a document page according to claim 4, wherein: In the case where the merging method includes first merging horizontally and then merging vertically, merging the sorted target blank areas to obtain at least one first target merged blank area includes: Merging the sorted target blank areas horizontally to obtain at least one second target merged blank area; Each of the second target merged blank areas is vertically merged to obtain at least one first target merged blank area.

6. The method for determining a blank area of a document page according to claim 5, wherein: The horizontally merging the sorted target blank areas to obtain at least one second target merged blank area includes: Based on any one of the sorted target blank areas, determining whether the target blank area has an adjacent blank area; In a case where the target blank area does not have the adjacent blank area, taking the target blank area as the second target merged blank area; In the case that the target blank area has the adjacent blank area, any one of the target blank areas is merged with the adjacent blank area to obtain a second merged blank area, and the second merged blank area is used as the target blank area for the next horizontal merger, and the step of determining whether the target blank area has an adjacent blank area is repeatedly performed until the target blank area does not have the adjacent blank area, and the finally obtained second merged blank area is used as the second target merged blank area.

7. The method for determining a blank area of a document page according to claim 5, wherein: The vertically merging the second target merged blank areas to obtain at least one first target merged blank area includes: For each of the second-target merged blank areas in any row, sorting the second-target merged blank areas based on the horizontal coordinates of the second-target merged blank areas; Based on any sorted second target merged blank area, determining whether there is a target merged blank area horizontally aligned with the second target merged blank area in each of the second target merged blank areas in the next row adjacent to the any row; In a case where there is no target merging blank area that is horizontally aligned with the second target merging blank area, using the second target merging blank area as the first target merging blank area; In the case that there is a target merging blank area that is horizontally aligned with the second target merging blank area, the second target merging blank area and the horizontally aligned target merging blank area are merged to obtain a first merged blank area, and the first merged blank area is used as the target blank area for the next vertical merger, and the step of determining whether there is a target merging blank area that is horizontally aligned with the second target merging blank area in each of the second target merging blank areas in the next row adjacent to any row is repeated until there is no target merging blank area that is horizontally aligned with the second target merging blank area, and the first merged blank area finally obtained is used as the first target merging blank area.

8. The method for determining a blank area of a document page according to any one of claims 1 to 7, wherein: The method further comprises: Based on the size of the object to be inserted, traverse the sorted target blank areas in the page blank area of the target page to determine at least one target blank area that matches the size of the object to be inserted; Insert the object to be inserted into the at least one matching target blank area.

9. A device for determining blank area of a document page, characterized in that: include: A scanning module, configured to scan, for any target page of the document, an area of the rendering page corresponding to the target page, excluding the preset margins, using a grid of a preset size based on preset margins, to obtain a plurality of scanning areas corresponding to the grid; The first determining module is configured to determine the page blank area of the target page based on each target blank area when each scanning area is determined to be a target blank area.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the document page blank area determination method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Open fixed-layout document paragraph identification method

    CN106326854A

  • Image-text typesetting method and device and electronic equipment

    CN112434487A

  • Document paragraph position extraction method, electronic equipment and storage medium

    CN114495141A

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

    CN116451677A