PDF keyword positioning method and device and storage medium

By reading and calculating keyword location information from PDF documents, the compatibility issue of keyword positioning in electronic signature platforms developed in Java language is resolved, achieving efficient signature positioning without the need for third-party software.

CN115270706BActive Publication Date: 2026-03-03SHANGHAI GENYAN NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210861835.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-20
Publication Date
2026-03-03
Estimated Expiration
2042-07-20

AI Technical Summary

Technical Problem

Existing PDF document signing platforms, especially those developed in Java, cannot effectively locate keywords, leading to compatibility issues and preventing third-party applications from using existing PDF reading software API interfaces.

Method used

This paper provides a method for locating keywords in PDF documents. By reading the content of the target PDF document, the method determines the keyword location information, calculates the first and second positions of the keywords, and locates them according to the page size and proportion. This method solves the compatibility problem of electronic signature platforms.

Benefits of technology

It enables accurate keyword location in PDF documents without the need to install third-party software, improving the efficiency and performance of electronic signatures and meeting the requirements for signature location.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115270706B_ABST
    Figure CN115270706B_ABST
Patent Text Reader

Abstract

The application provides a PDF keyword positioning method and related equipment, so that the demand for signature positioning during PDF signature can be better met, without the need to install third-party software for separate processing, and the performance is greatly improved. The method comprises the following steps: reading the content of a target PDF document; determining N keywords corresponding to the content of the target PDF document; calculating the position information of the target keywords; calculating the position information of a first position corresponding to the target keywords according to the position information; determining the position information of a second position corresponding to the target keywords according to the position information of the first position; determining a first proportion value of the first position to a target page and a second proportion value of the second position to the target page according to the page size of the target page, the position information of the first position and the position information of the second position; and positioning the target keywords according to the position information of the first position, the position information of the second position, the first proportion value and the second proportion value.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] This application belongs to the field of data processing, and specifically relates to a method, apparatus and storage medium for locating keywords in PDF. [Background Technology]

[0002] Specifying the signature location in PDF document signing primarily involves setting the signature position on the page. However, with the increasing popularity of SaaS electronic signature platforms, many business scenarios cannot directly set the signature location on the PDF document page. Instead, there is a growing demand to specify the signature location near the specified keywords. Since SaaS platforms are mostly developed using Java, there is currently no complete method on the market for implementing PDF document keyword search based on Java.

[0003] Software that implements PDF document keyword locating methods includes Adobe products, Foxit PDF Reader, and WPS Office. Libraries that implement PDF document keyword locating methods include ITEXT and PDFBOX, developed in Java, and MUPDF, developed in C.

[0004] However, the PDF reading software does not have an open API interface, so third-party applications cannot use this method. Furthermore, since it is not developed in Java, there are compatibility issues when embedding it into an electronic signature platform that is developed in Java. [Summary of the Invention]

[0005] This application provides a method, apparatus, and storage medium for locating keywords in PDFs, which can solve the compatibility problem of electronic signature platforms and locate keywords in PDF reading software through third-party applications.

[0006] The first aspect of this application provides a method for locating keywords in a PDF, including:

[0007] Read the content of the target PDF document;

[0008] Determine N keywords corresponding to the content of the target PDF document, where N is an integer greater than or equal to 1;

[0009] Calculate the location information corresponding to the target keyword, where the target keyword is any one of the N keywords;

[0010] Calculate the location information of the first location corresponding to the target keyword based on the location information;

[0011] The location information of the second position corresponding to the target keyword is determined based on the location information of the first position;

[0012] Based on the page size of the target page, the position information of the first position, and the position information of the second position, a first ratio value between the first position and the target page and a second ratio value between the second position and the target page are determined, wherein the target page is the page corresponding to the target keyword;

[0013] The target keyword is located based on the location information of the first position, the location information of the second position, the first ratio value, and the second ratio value.

[0014] A second aspect of this application provides a device for PDF keyword positioning, comprising:

[0015] The reading unit is used to read the content of the target PDF document.

[0016] The first determining unit is used to determine N keywords corresponding to the content of the target PDF document, wherein N is an integer greater than or equal to 1;

[0017] The first calculation unit is used to calculate the location information corresponding to the target keyword, wherein the target keyword is any one of the N keywords;

[0018] The second calculation unit is used to calculate the location information of the first location corresponding to the target keyword based on the location information;

[0019] The second determining unit is used to determine the location information of the second location corresponding to the target keyword based on the location information of the first location;

[0020] The third determining unit is used to determine a first ratio value between the first position and the target page and a second ratio value between the second position and the target page based on the page size of the target page, the position information of the first position and the position information of the second position, wherein the target page is the page corresponding to the target keyword;

[0021] The positioning unit is used to locate the target keyword based on the location information of the first location, the location information of the second location, the first ratio value, and the second ratio value.

[0022] In one possible design, the second computing unit is specifically used for:

[0023] The position information corresponding to the first position of the target keyword is calculated using the following formula, where the first position is the top-left point, bottom-left point, top-right point, and bottom-right point corresponding to the target keyword:

[0024]

[0025]

[0026] Among them, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 左下 ,Y 左下 ) represents the position information of the lower left point, (X) 右上 ,Y 右上 ) represents the position information of the upper right point, (X) 右上 ,Y 右上 (x1, y1) represents the position information of the lower right point, (x2, y2) represents the position information of the first character in the target keyword, and (x2, y2) represents the position information of the last character in the target keyword.

[0027] In one possible design, the second determining unit is specifically used for:

[0028] Based on the position information of the first position, it is determined whether the target keyword has a line break or a page break, so as to obtain the determination result;

[0029] Based on the judgment result, determine the location information of the second position corresponding to the target keyword.

[0030] In one possible design, the second determining unit determines the location information of the second position corresponding to the target keyword based on the judgment result, including:

[0031] If the determination result indicates that the target keyword has a line break or page break, then the position information of the second position is determined by the following formula, where the second position includes the left and right midpoints corresponding to the target keyword:

[0032]

[0033] Among them, (X) 左中 ,Y 左中 ) represents the position information of the left midpoint, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 右中 ,Y 右中 ) represents the position information of the right midpoint, (X) 右上 ,Y 右上 ) represents the position information of the upper right point;

[0034] If the determination result indicates that the target keyword does not have a line break or page break, then the second position information is determined by the following formula, where the second position includes the top center point, bottom center point, left center point, right center point, and middle center point corresponding to the target keyword:

[0035]

[0036]

[0037] Among them, (X) 上中 ,Y 上中 ) represents the position information of the upper midpoint, (X) 下中 ,Y 下中 ) represents the position information of the lower midpoint, (X) 左中 ,Y 左中 ) represents the position information of the left midpoint, (X) 右中 ,Y 右中 ) represents the position information of the right midpoint, (X) 中中 ,Y 中中 ) represents the position information of the midpoint, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 左下 ,Y 左下 ) represents the position information of the lower left point, (X) 右上 ,Y 右上 ) represents the position information of the upper right point, (X) 右上 ,Y 右上 ) represents the position information of the lower right point.

[0038] In one possible design, the second determining unit determines whether the target keyword needs a line break or page break based on the position information of the first position, and the determination result includes:

[0039] Determine whether the y-value of the lower left point is greater than the y-value of the upper right point;

[0040] If so, the judgment result is determined to be the target keyword line break;

[0041] Determine whether the page containing the first character of the target keyword is the same as the page containing the last character of the target keyword;

[0042] If not, the judgment result is determined to be a page break for the target keyword.

[0043] In one possible design, the third determining unit is specifically used for:

[0044] Determine the X coordinate value of the first position, the Y coordinate value of the first position, the X coordinate value of the second position, and the Y coordinate value of the second position;

[0045] The first ratio value is determined based on the X coordinate value of the first position, the Y coordinate value of the first position, and the page size of the target page, wherein the page size of the target page is the page height and the page width of the target page;

[0046] The second ratio value is determined based on the X coordinate value of the second position, the Y coordinate value of the second position, and the page size of the target page.

[0047] In one possible design, the first computing unit is specifically used for:

[0048] Based on the content of the target PDF document, determine the paragraph information corresponding to the target keyword and the attribute information corresponding to the target keyword;

[0049] Obtain the font information corresponding to the target keyword;

[0050] The location information corresponding to the target keyword is determined based on the paragraph information, the attribute information, and the font information.

[0051] A third aspect of this application provides a computer device including at least one connected processor, memory, and transceiver, wherein the memory is used to store program code, and the processor is used to call the program code in the memory to execute the steps of the PDF keyword location method described in the second aspect above.

[0052] A fourth aspect of this application provides a computer storage medium including instructions that, when executed on a computer, cause the computer to perform the steps of the PDF keyword locating method described in the second aspect above.

[0053] In summary, it can be seen that in the embodiments provided in this application, by calculating the position information corresponding to each of the N keywords, determining the first and second positions corresponding to each keyword, and determining the ratio of the first and second positions to the page, the target keyword can be located based on the position information of the first position, the position information of the second position, and the ratio of the first and second positions to the page. This can better meet the signature positioning requirements of PDF signing, and at the same time, it does not require the installation of third-party software for separate processing, greatly improving performance. [Attached Image Description]

[0054] Figure 1 A flowchart illustrating the PDF keyword locating method provided in this application embodiment;

[0055] Figure 2 A schematic diagram of an embodiment of the PDF keyword positioning method provided in this application;

[0056] Figure 3 A schematic diagram of another embodiment of the PDF keyword locating method provided in this application;

[0057] Figure 4A virtual structural diagram of the PDF keyword locating device provided in the embodiments of this application;

[0058] Figure 5 This is a schematic diagram of the hardware structure of the PDF keyword locator provided in an embodiment of the present invention;

[0059] Figure 6 A schematic diagram illustrating an embodiment of an electronic device provided by an embodiment of the present invention;

[0060] Figure 7 This is a schematic diagram of an embodiment of a computer-readable storage medium provided in this invention.

Detailed Implementation Methods

[0061] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.

[0062] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or modules is not necessarily limited to those explicitly listed, but may include other steps or modules not explicitly listed or inherent to these processes, methods, products, or devices. The division of modules appearing in this application is merely a logical division; in practical applications, other division methods may be used. For example, multiple modules may be combined or integrated into another system, or some feature vectors may be ignored or not executed. Additionally, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interface, and the indirect coupling or communication connection between modules may be electrical or other similar forms, none of which are limited in this application. Furthermore, the modules or sub-modules described as separate components may or may not be physically separate, may or may not be physical modules, or may be distributed among multiple circuit modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this application.

[0063] The PDF keyword positioning method provided in this application embodiment is described below from the perspective of a PDF keyword positioning device. Please refer to [link to relevant documentation]. Figure 1 , Figure 1 A flowchart illustrating the PDF keyword locating method provided in this application embodiment includes:

[0064] 101. Read the content of the target PDF document.

[0065] In this embodiment, the PDF keyword locator can read the content of the target PDF document. Specifically, it can read the content of the target PDF document page by page using Java language according to the PDF document specification. The content of the target PDF document is the content of the PDF document to be located for PDF keywords.

[0066] 102. Identify the N keywords corresponding to the content of the target PDF document.

[0067] In this embodiment, after reading the content of the target PDF document, the PDF keyword positioning device can match the target PDF document content according to the keywords selected by the user to determine N keywords, where N is an integer greater than or equal to 1.

[0068] 103. Calculate the location information corresponding to the target keyword.

[0069] In this embodiment, after determining the N keywords corresponding to the content of the target PDF document, the PDF keyword positioning device can calculate the position information corresponding to the target keyword. This position information is identified by the coordinates relative to the upper left point of the document page and is identified in the form of coordinates. The target keyword is any one of the N keywords.

[0070] In one embodiment, the PDF keyword location device calculates the location information corresponding to the target keyword by including:

[0071] Determine the paragraph information and attribute information corresponding to the target keywords based on the content of the target PDF document;

[0072] Obtain the font information corresponding to the target keyword;

[0073] The location information corresponding to the target keyword is determined based on paragraph information, attribute information, and font information.

[0074] In this embodiment, the PDF keyword positioning device can obtain the paragraph information and attribute information corresponding to the target keyword according to the PDF document specifications. The paragraph information indicates whether the keyword is contained within a paragraph or several paragraphs. The attribute information includes the position of the paragraph containing the target keyword, i.e., the coordinates of the paragraph relative to the left corner of the page, the width and height of the target keyword, the margins of the target keyword, and the page number of the target keyword. It also obtains the font information corresponding to the target keyword, including the font (such as SimSun, KaiTi, HeiTi, etc.), the character shape, style, and size of the target keyword. Finally, based on the paragraph information, attribute information, and font information, the approximate position of the target keyword is determined. Then, based on the number of characters in the paragraph containing the target keyword and the position of a specific character within the paragraph, the position information (i.e., the coordinates of each character in the target keyword) is calculated. The following is a combination of... Figure 2 Detailed explanation of location information:

[0075] Please see Figure 2 , Figure 2 This is a schematic diagram of an embodiment of the PDF keyword positioning method provided in this application. Figure 2 In this context, (ABC)Tj represents the target PDF text content; 40 50Td represents the location of ABC, that is, the location of ABC at the left vertex of the document, with a distance of 40 x and 50 y (40, 50); if the keyword is BC (assuming the font width is 10, the height is 12, and there are no margins), then the position of B (bottom right point) in the keyword is (40+20, 50+12) = (60, 62), and the position of C is (40+30, 50+12) = (70, 62).

[0076] 104. Calculate the location information of the first position corresponding to the target keyword based on the location information.

[0077] In this embodiment, after calculating the position information of each keyword in the target keywords, the PDF keyword positioning device can calculate the position information of the first position corresponding to the target keyword based on the position information. The first position is the top-left point, bottom-left point, top-right point, and bottom-right point corresponding to the target keyword. Specifically:

[0078] The position information of the first position corresponding to the target keyword is calculated using the following formula:

[0079]

[0080] Among them, (X) 左上 ,Y 左上 (X) represents the position information of the top-left point.左下 ,Y 左下 (X) represents the position information of the lower left point. 右上 ,Y 右上 (X) represents the position information of the upper right point. 右上 ,Y 右上 (x1, y1) represents the position information of the bottom right point, (x2, y2) represents the position information of the first character in the target keyword, and (x2, y2) represents the position information of the last character in the target keyword.

[0081] like Figure 3 As shown, Figure 3 This is a schematic diagram of another embodiment of the PDF keyword positioning method provided in this application, wherein "patent" is the target keyword, and the specific positions of the top left, top right, bottom left, and bottom right points are as follows: Figure 3 As shown.

[0082] 105. Determine the location information of the second position corresponding to the target keyword based on the location information of the first position.

[0083] In this embodiment, after determining the location information of the first position, the PDF keyword positioning device can determine the second position information corresponding to the target keyword based on the location information of the first position. Specifically, it can determine whether the target keyword has a line break or a page break based on the location information of the first position to obtain a judgment result; and determine the location information of the second position corresponding to the target keyword based on the judgment result.

[0084] It should be noted that when the PDF keyword positioning device determines whether a target keyword has a line break or page break based on the position information of the first position, it can determine whether the target keyword has a line break by judging whether the y-value of the lower left point is greater than the y-value of the upper right point. If the y-value of the lower left point corresponding to the target keyword is greater than the y-value of the upper right point corresponding to the target keyword, then a line break is determined to exist in the target keyword. If the y-value of the lower left point corresponding to the target keyword is not greater than the y-value of the upper right point corresponding to the target keyword, then a line break is determined to exist in the target keyword. At the same time, it can also determine whether the target keyword has a page break by judging whether the page containing the first character of the target keyword is the same as the page containing the last character of the target keyword. If the page containing the first character of the target keyword is not the same as the page containing the last character of the target keyword, then a page break is determined to exist in the target keyword.

[0085] In one embodiment, the PDF keyword location device determines the location information of the second position corresponding to the target keyword based on the judgment result, including:

[0086] If the determination result indicates that the target keyword contains a line break or page break, the position information of the second position is determined by the following formula, where the second position includes the left and right midpoints corresponding to the target keyword:

[0087]

[0088] Among them, (X) 左中 ,Y 左中 (X) represents the position information of the left midpoint. 左上 ,Y 左上 (X) represents the position information of the top-left point. 右中 ,Y 右中 (X) represents the position information of the right midpoint. 右上 ,Y 右上 () represents the position information of the upper right point;

[0089] If the determination result indicates that the target keyword does not have a line break or page break, the second position information is determined using the following formula. The second position includes the top center point, bottom center point, left center point, right center point, and middle center point corresponding to the target keyword:

[0090]

[0091]

[0092] Among them, (X) 上中 ,Y 上中 (X) represents the position information of the upper midpoint. 下中 ,Y 下中 (X) represents the position information of the lower midpoint. 左中 ,Y 左中 (X) represents the position information of the left midpoint. 右中 ,Y 右中 (X) represents the position information of the right midpoint. 中中 ,Y 中中 ) represents the location information of the midpoint, (X) 左上 ,Y 左上 (X) represents the position information of the top-left point. 左下 ,Y 左下 (X) represents the position information of the lower left point. 右上 ,Y 右上 (X) represents the position information of the upper right point. 右上 ,Y 右上 () represents the position information of the bottom right point.

[0093] It should be noted that the specific locations of the top midpoint, bottom midpoint, left midpoint, right midpoint, and center midpoint are as follows: Figure 3 As shown.

[0094] 106. Determine the first ratio between the first position and the target page and the second ratio between the second position and the target page based on the page size of the target page, the position information of the first position, and the position information of the second position.

[0095] In this embodiment, the PDF keyword positioning device can determine a first ratio value between the first position and the target page, and a second ratio value between the second position and the target page, based on the page size of the target page, the position information of the first position, and the position information of the second position. The target page is the page corresponding to the target keyword. Specifically, the X-coordinate value, Y-coordinate value, X-coordinate value, and Y-coordinate value of the second position are determined. The first ratio value is determined based on the X-coordinate value, Y-coordinate value, and the page size of the target page, where the page size is the page height and page width. The second ratio value is determined based on the X-coordinate value, Y-coordinate value, and the page size of the target page. In other words, when calculating the ratio of the keyword to the page, one ratio can be obtained by dividing the x-values ​​of the nine points in the target keyword by the page width of the target page, and another ratio can be obtained by dividing the y-values ​​of the nine points in the target keyword by the page height of the target page.

[0096] It should be noted that when using third-party software such as Foxit and WPS Office, the location information of the target keyword can be obtained by calling the corresponding API.

[0097] 107. Locate the target keyword based on the location information of the first position, the location information of the second position, the first ratio value, and the second ratio value.

[0098] In this embodiment, the PDF keyword positioning device can locate the target keyword based on the location information of the first position, the location information of the second position, the first ratio value, and the second ratio value.

[0099] In summary, it can be seen that in the embodiments provided in this application, by calculating the position information corresponding to each of the N keywords, determining the first and second positions corresponding to each keyword, and determining the ratio of the first and second positions to the page, the target keyword can be located based on the position information of the first position, the position information of the second position, and the ratio of the first and second positions to the page. This can better meet the signature positioning requirements for signatures, and at the same time, it does not require the installation of third-party software for separate processing, greatly improving performance.

[0100] Please see Figure 4 , Figure 4 This application provides a virtual structural intent for the PDF keyword locator 400, which includes:

[0101] Reading unit 401 is used to read the content of the target PDF document;

[0102] The first determining unit 402 is used to determine N keywords corresponding to the content of the target PDF document, wherein N is an integer greater than or equal to 1;

[0103] The first calculation unit 403 is used to calculate the location information corresponding to the target keyword, wherein the target keyword is any one of the N keywords;

[0104] The second calculation unit 404 is used to calculate the location information of the first location corresponding to the target keyword based on the location information;

[0105] The second determining unit 405 is used to determine the location information of the second position corresponding to the target keyword based on the location information of the first position;

[0106] The third determining unit 406 is used to determine a first ratio value between the first position and the target page and a second ratio value between the second position and the target page based on the page size of the target page, the position information of the first position and the position information of the second position, wherein the target page is the page corresponding to the target keyword;

[0107] The positioning unit 407 is used to locate the target keyword based on the location information of the first position, the location information of the second position, the first ratio value, and the second ratio value.

[0108] In one possible design, the second computing unit 403 is specifically used for:

[0109] The position information corresponding to the first position of the target keyword is calculated using the following formula, where the first position is the top-left point, bottom-left point, top-right point, and bottom-right point corresponding to the target keyword:

[0110]

[0111] Among them, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 左下 ,Y 左下 ) represents the position information of the lower left point, (X) 右上 ,Y 右上 ) represents the position information of the upper right point, (X) 右上 ,Y 右上 (x1, y1) represents the position information of the lower right point, (x2, y2) represents the position information of the first character in the target keyword, and (x2, y2) represents the position information of the last character in the target keyword.

[0112] In one possible design, the second determining unit 405 is specifically used for:

[0113] Based on the position information of the first position, it is determined whether the target keyword has a line break or a page break, so as to obtain the determination result;

[0114] Based on the judgment result, determine the location information of the second position corresponding to the target keyword.

[0115] In one possible design, the second determining unit 405 determines the location information of the second position corresponding to the target keyword based on the judgment result, including:

[0116] If the determination result indicates that the target keyword has a line break or page break, then the position information of the second position is determined by the following formula, where the second position includes the left and right midpoints corresponding to the target keyword:

[0117]

[0118]

[0119] Among them, (X) 左中 ,Y 左中 ) represents the position information of the left midpoint, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 右中 ,Y 右中 ) represents the position information of the right midpoint, (X) 右上 ,Y 右上 ) represents the position information of the upper right point;

[0120] If the determination result indicates that the target keyword does not have a line break or page break, then the second position information is determined by the following formula, where the second position includes the top center point, bottom center point, left center point, right center point, and middle center point corresponding to the target keyword:

[0121]

[0122] Among them, (X) 上中 ,Y 上中 ) represents the position information of the upper midpoint, (X) 下中 ,Y 下中 ) represents the position information of the lower midpoint, (X) 左中 ,Y 左中 ) represents the position information of the left midpoint, (X) 右中 ,Y 右中 ) represents the position information of the right midpoint, (X) 中中 ,Y 中中 ) represents the position information of the midpoint, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X)左下 ,Y 左下 ) represents the position information of the lower left point, (X) 右上 ,Y 右上 ) represents the position information of the upper right point, (X) 右上 ,Y 右上 ) represents the position information of the lower right point.

[0123] In one possible design, the second determining unit 405 determines whether the target keyword has a line break or page break based on the position information of the first position, and the determination result includes:

[0124] Determine whether the y-value of the lower left point is greater than the y-value of the upper right point;

[0125] If so, the judgment result is determined to be the target keyword line break;

[0126] Determine whether the page containing the first character of the target keyword is the same as the page containing the last character of the target keyword;

[0127] If not, the judgment result is determined to be a page break for the target keyword.

[0128] In one possible design, the third determining unit 406 is specifically used for:

[0129] Determine the X coordinate value of the first position, the Y coordinate value of the first position, the X coordinate value of the second position, and the Y coordinate value of the second position;

[0130] The first ratio value is determined based on the X coordinate value of the first position, the Y coordinate value of the first position, and the page size of the target page, wherein the page size of the target page is the page height and the page width of the target page;

[0131] The second ratio value is determined based on the X coordinate value of the second position, the Y coordinate value of the second position, and the page size of the target page.

[0132] In one possible design, the first computing unit 403 is specifically used for:

[0133] Based on the content of the target PDF document, determine the paragraph information corresponding to the target keyword and the attribute information corresponding to the target keyword;

[0134] Obtain the font information corresponding to the target keyword;

[0135] The location information corresponding to the target keyword is determined based on the paragraph information, the attribute information, and the font information.

[0136] above Figure 4 The PDF keyword locating device in this application embodiment has been described from the perspective of modular functional entities. The following is a detailed description of the PDF keyword locating device in this application embodiment from the perspective of hardware processing. Please refer to [link / reference]. Figure 5 One embodiment of the PDF keyword locating device 500 in this application includes:

[0137] Input device 501, output device 502, processor 503, and memory 504 (where the number of processors 503 can be one or more). Figure 5 (Taking a processor 503 as an example). In some embodiments of this application, the input device 501, output device 502, processor 503, and memory 504 can be connected via a bus or other means, wherein... Figure 5 Taking the example of a connection between China and Israel via a bus.

[0138] Specifically, by calling the operation instructions stored in memory 504, processor 503 executes the following steps:

[0139] Read the content of the target PDF document;

[0140] Determine N keywords corresponding to the content of the target PDF document, where N is an integer greater than or equal to 1;

[0141] Calculate the location information corresponding to the target keyword, where the target keyword is any one of the N keywords;

[0142] Calculate the location information of the first location corresponding to the target keyword based on the location information;

[0143] The location information of the second position corresponding to the target keyword is determined based on the location information of the first position;

[0144] Based on the page size of the target page, the position information of the first position, and the position information of the second position, a first ratio value between the first position and the target page and a second ratio value between the second position and the target page are determined, wherein the target page is the page corresponding to the target keyword;

[0145] The target keyword is located based on the location information of the first position, the location information of the second position, the first ratio value, and the second ratio value.

[0146] By calling the operation instructions stored in memory 504, processor 503 is also used to execute... Figure 1 Any of the methods in the corresponding embodiments.

[0147] Please see Figure 6 , Figure 6 A schematic diagram illustrating an embodiment of the electronic device provided in this application.

[0148] like Figure 6 As shown, this application provides an electronic device, including a memory 610, a processor 620, and a computer program 611 stored in the memory 620 and executable on the processor 620. When the processor 620 executes the computer program 611, it performs the following steps:

[0149] Read the content of the target PDF document;

[0150] Determine N keywords corresponding to the content of the target PDF document, where N is an integer greater than or equal to 1;

[0151] Calculate the location information corresponding to the target keyword, where the target keyword is any one of the N keywords;

[0152] Calculate the location information of the first location corresponding to the target keyword based on the location information;

[0153] The location information of the second position corresponding to the target keyword is determined based on the location information of the first position;

[0154] Based on the page size of the target page, the position information of the first position, and the position information of the second position, a first ratio value between the first position and the target page and a second ratio value between the second position and the target page are determined, wherein the target page is the page corresponding to the target keyword;

[0155] The target keyword is located based on the location information of the first position, the location information of the second position, the first ratio value, and the second ratio value.

[0156] In practical implementation, when the processor 620 executes the computer program 611, it can achieve... Figure 1 Any of the corresponding implementation methods in the embodiments.

[0157] Since the electronic device described in this embodiment is the device used to implement a PDF keyword positioning device in the embodiments of this application, those skilled in the art can understand the specific implementation method and various variations of the electronic device in this embodiment based on the method described in the embodiments of this application. Therefore, how the electronic device implements the method in the embodiments of this application will not be described in detail here. Any device used by those skilled in the art to implement the method in the embodiments of this application falls within the scope of protection of this application.

[0158] Please see Figure 7 , Figure 7 This is a schematic diagram illustrating an embodiment of a computer-readable storage medium provided in this application.

[0159] like Figure 7 As shown, this embodiment provides a computer-readable storage medium 700, on which a computer program 711 is stored. When the computer program 711 is executed by a processor, it performs the following steps:

[0160] Read the content of the target PDF document;

[0161] Determine N keywords corresponding to the content of the target PDF document, where N is an integer greater than or equal to 1;

[0162] Calculate the location information corresponding to the target keyword, where the target keyword is any one of the N keywords;

[0163] Calculate the location information of the first location corresponding to the target keyword based on the location information;

[0164] The location information of the second position corresponding to the target keyword is determined based on the location information of the first position;

[0165] Based on the page size of the target page, the position information of the first position, and the position information of the second position, a first ratio value between the first position and the target page and a second ratio value between the second position and the target page are determined, wherein the target page is the page corresponding to the target keyword;

[0166] The target keyword is located based on the location information of the first position, the location information of the second position, the first ratio value, and the second ratio value.

[0167] In practical implementation, when the computer program 711 is executed by the processor, it can achieve the following: Figure 1 Any of the corresponding implementation methods in the embodiments.

[0168] It should be noted that the descriptions of each embodiment in the above embodiments have different focuses. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0169] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0170] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0171] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0172] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0173] This application also provides a computer program product, which includes computer software instructions that, when executed on a processing device, cause the processing device to perform actions such as... Figure 1 The process of PDF keyword location method in the corresponding embodiment.

[0174] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0175] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0176] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.

[0177] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0178] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0179] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part 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 to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0180] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for locating keywords in a PDF, characterized in that, include: Read the content of the target PDF document; Determine N keywords corresponding to the content of the target PDF document, where N is an integer greater than or equal to 1; wherein, the N keywords are determined by matching the content of the target PDF document based on the keywords selected by the user. Calculate the location information corresponding to the target keyword, where the target keyword is any one of the N keywords; Calculate the location information of the first position corresponding to the target keyword based on the location information, where the first position is the top left point, bottom left point, top right point, and bottom right point corresponding to the target keyword; The location information of the second position corresponding to the target keyword is determined based on the location information of the first position; wherein, determining the location information of the second position corresponding to the target keyword based on the location information of the first position includes: judging whether the target keyword has a line break or page break based on the location information of the first position, so as to obtain a judgment result; and determining the location information of the second position corresponding to the target keyword based on the judgment result; Wherein, if the determination result is that the target keyword has a line break or page break, then the second position includes the left midpoint and the right midpoint corresponding to the target keyword; if the determination result is that the target keyword does not have a line break or page break, then the second position includes the top midpoint, bottom midpoint, left midpoint, right midpoint and center midpoint corresponding to the target keyword. Based on the page size of the target page, the position information of the first position, and the position information of the second position, a first ratio value between the first position and the target page and a second ratio value between the second position and the target page are determined, wherein the target page is the page corresponding to the target keyword; The target keyword is located based on the location information of the first position, the location information of the second position, the first ratio value, and the second ratio value; The step of calculating the location information of the first position corresponding to the target keyword based on the location information includes: calculating the location information of the first position corresponding to the target keyword using the following formula: Among them, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 左下 ,Y 左下 ) represents the position information of the lower left point, (X) 右上 ,Y 右上 ) represents the position information of the upper right point, (X) 右上 ,Y 右上 (x1, y1) represents the position information of the lower right point, (x2, y2) represents the position information of the first character in the target keyword, and (x2, y2) represents the position information of the last character in the target keyword. The step of determining the position information of the second position corresponding to the target keyword based on the judgment result includes: if the judgment result indicates that the target keyword has a line break or page break, then the position information of the second position is determined by the following formula: Among them, (X) 左中 ,Y 左中 ) represents the position information of the left midpoint, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 右中 ,Y 右中 ) represents the position information of the right midpoint, (X) 右上 ,Y 右上 ) represents the position information of the upper right point; If the determination result indicates that the target keyword does not have a line break or page break, then the second position information is determined by the following formula, where the second position includes the top center point, bottom center point, left center point, right center point, and middle center point corresponding to the target keyword: Among them, (X) 上中 ,Y 上中 ) represents the position information of the upper midpoint, (X) 下中 ,Y 下中 ) represents the position information of the lower midpoint, (X) 左中 ,Y 左中 ) represents the position information of the left midpoint, (X) 右中 ,Y 右中 ) represents the position information of the right midpoint, (X) 中中 ,Y 中中 ) represents the position information of the midpoint, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 左下 ,Y 左下 ) represents the position information of the lower left point, (X) 右上 ,Y 右上 ) represents the position information of the upper right point, (X) 右上 ,Y 右上 ) represents the position information of the lower right point.

2. The method according to claim 1, characterized in that, The step of determining whether the target keyword needs a line break or page break based on the position information of the first position, to obtain a determination result, includes: Determine whether the y-value of the lower left point is greater than the y-value of the upper right point; If so, the judgment result is determined to be the target keyword line break; Determine whether the page containing the first character of the target keyword is the same as the page containing the last character of the target keyword; If not, the judgment result is determined to be a page break for the target keyword.

3. The method according to any one of claims 1 to 2, characterized in that, Determining the first ratio value between the first position and the target page and the second ratio value between the second position and the target page based on the page size of the target page, the position information of the first position, and the position information of the second position includes: Determine the X coordinate value of the first position, the Y coordinate value of the first position, the X coordinate value of the second position, and the Y coordinate value of the second position; The first ratio value is determined based on the X coordinate value of the first position, the Y coordinate value of the first position, and the page size of the target page, wherein the page size of the target page is the page height and the page width of the target page; The second ratio value is determined based on the X coordinate value of the second position, the Y coordinate value of the second position, and the page size of the target page.

4. The method according to any one of claims 1 to 2, characterized in that, The location information corresponding to the target keyword includes: Based on the content of the target PDF document, determine the paragraph information corresponding to the target keyword and the attribute information corresponding to the target keyword; Obtain the font information corresponding to the target keyword; The location information corresponding to the target keyword is determined based on the paragraph information, the attribute information, and the font information.

5. A PDF keyword locator, characterized in that, include: The reading unit is used to read the content of the target PDF document. The first determining unit is used to determine N keywords corresponding to the content of the target PDF document, wherein N is an integer greater than or equal to 1; wherein the N keywords are determined by matching the content of the target PDF document according to the keywords selected by the user. The first calculation unit is used to calculate the location information corresponding to the target keyword, wherein the target keyword is any one of the N keywords; The second calculation unit is used to calculate the position information of the first position corresponding to the target keyword based on the position information, wherein the first position is the top left point, bottom left point, top right point, and bottom right point corresponding to the target keyword; The second determining unit is used to determine the location information of the second location corresponding to the target keyword based on the location information of the first location; Specifically, the second determining unit determines the position information of the second position corresponding to the target keyword based on the position information of the first position by: judging whether the target keyword has a line break or a page break based on the position information of the first position, so as to obtain a judgment result; and determining the position information of the second position corresponding to the target keyword based on the judgment result. Specifically, the second determining unit determines the position information of the second position corresponding to the target keyword based on the judgment result as follows: if the judgment result indicates that the target keyword has a line break or page break, then the second position includes the left midpoint and right midpoint corresponding to the target keyword; if the judgment result indicates that the target keyword does not have a line break or page break, then the second position includes the top midpoint, bottom midpoint, left midpoint, right midpoint, and center midpoint corresponding to the target keyword. The third determining unit is used to determine a first ratio value between the first position and the target page and a second ratio value between the second position and the target page based on the page size of the target page, the position information of the first position and the position information of the second position, wherein the target page is the page corresponding to the target keyword; A positioning unit is used to locate the target keyword based on the location information of the first location, the location information of the second location, the first ratio value, and the second ratio value; The second calculation unit is specifically used to: calculate the position information of the first position corresponding to the target keyword using the following formula, where the first position is the top-left point, bottom-left point, top-right point, and bottom-right point corresponding to the target keyword: Among them, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 左下 ,Y 左下 ) represents the position information of the lower left point, (X) 右上 ,Y 右上 ) represents the position information of the upper right point, (X) 右上 ,Y 右上 (x1, y1) represents the position information of the lower right point, (x2, y2) represents the position information of the first character in the target keyword, and (x2, y2) represents the position information of the last character in the target keyword. The second determining unit is specifically used to: determine whether the target keyword has a line break or page break based on the position information of the first position, so as to obtain a determination result; and determine the position information of the second position corresponding to the target keyword based on the determination result; The second determining unit determines the position information of the second position corresponding to the target keyword based on the judgment result, including: if the judgment result is that the target keyword has a line break or page break, then the position information of the second position is determined by the following formula, wherein the second position includes the left midpoint and right midpoint corresponding to the target keyword: Among them, (X) 左中 ,Y 左中 ) represents the position information of the left midpoint, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 右中 ,Y 右中 ) represents the position information of the right midpoint, (X) 右上 ,Y 右上 ) represents the position information of the upper right point; If the determination result indicates that the target keyword does not have a line break or page break, then the second position information is determined by the following formula, where the second position includes the top center point, bottom center point, left center point, right center point, and middle center point corresponding to the target keyword: Among them, (X) 上中 ,Y 上中 ) represents the position information of the upper midpoint, (X) 下中 ,Y 下中 ) represents the position information of the lower midpoint, (X) 左中 ,Y 左中 ) represents the position information of the left midpoint, (X) 右中 ,Y 右中 ) represents the position information of the right midpoint, (X) 中中 ,Y 中中 ) represents the position information of the midpoint, (X) 左上 ,Y 左上 ) represents the position information of the upper left point, (X) 左下 ,Y 左下 ) represents the position information of the lower left point, (X) 右上 ,Y 右上 ) represents the position information of the upper right point, (X) 右上 ,Y 右上 ) represents the position information of the lower right point.

6. A computer device, characterized in that, include: At least one connected processor, memory, and transceiver, wherein the memory is used to store program code, and the processor is used to invoke the program code in the memory to perform the steps of the PDF keyword location method according to any one of claims 1 to 4.

7. A computer storage medium, characterized in that, include: Instructions, when executed on a computer, cause the computer to perform the steps of the PDF keyword location method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Structural extracting method of table information, electronic device, and computer readable storage medium

    CN107818075A

  • A text metadata extraction method based on keyword expression

    CN109542845A