A method, device, equipment and storage medium for accurately cutting PDF
By using anchor algorithms to match and cut target information in the coordinate system of PDF files, the problems of low efficiency and high error rate in the prior art PDF file information search are solved, and the precise positioning and cutting target information is achieved, and the user's work efficiency is improved.
Patent Information
- Application Number
- CN202210840545.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-18
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2042-07-18
AI Technical Summary
The prior art is inefficient in finding and positioning target information in PDF files, has a high error rate, and requires manual verification, resulting in large workload and low efficiency.
By using the anchor algorithm in the coordinate system of the PDF file, the matching information is generated and the original PDF file is cut to generate the target PDF file.
It realizes accurate positioning and cutting of target information in PDF files, reduces user workload, improves work efficiency, and allows users to obtain target information more intuitively.
Smart Images

Figure CN115116070B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of document cutting technology, and in particular to a method, device, equipment and storage medium for accurately cutting PDF. Background Art
[0002] Currently, when there is information that needs to be verified in a PDF file, it is necessary to manually traverse and search the PDF. If the PDF has many pages and the information is scattered, it is difficult to locate it intuitively, which makes manual operation time-consuming and labor-intensive.
[0003] In the prior art, each page of a PDF file is usually converted into an image first, and then identified and located with the help of OCR. If there are multiple pieces of data information that need to be checked against other information, a manual distinction and verification process is required.
[0004] The existing technology uses OCR to identify and locate, but the error rate is high. In addition, the manual differentiation and verification process results in a large workload for users and low work efficiency. Summary of the invention
[0005] The present invention provides a method, device, equipment and storage medium for accurately cutting PDF, so as to realize accurate cutting of target information in PDF.
[0006] According to one aspect of the present invention, a method for accurately cutting a PDF is provided, comprising:
[0007] Get the original PDF file and establish a coordinate system for the original PDF file;
[0008] Acquire target information, and match the target information with the original PDF file in the coordinate system based on the anchor point algorithm to generate matching information, wherein the matching information includes coordinate domain and area information;
[0009] Cutting the original PDF file according to the matching information to generate a cutting target, wherein the cutting target includes region information;
[0010] Generate target PDF file according to cutting target.
[0011] According to another aspect of the present invention, there is provided a device for accurately cutting a PDF, comprising:
[0012] A PDF coordinate system establishment module is used to obtain an original PDF file and establish a coordinate system for the original PDF file;
[0013] The target information matching module is used to obtain the target information, and match the target information with the original PDF file in the coordinate system based on the anchor point algorithm to generate matching information, wherein the matching information includes the coordinate domain and the area information;
[0014] A cutting target generating module, used for cutting the original PDF file according to the matching information to generate a cutting target, wherein the cutting target includes area information;
[0015] The target file generation module is used to generate a target PDF file according to the cutting target.
[0016] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute a method for accurately cutting a PDF as described in any embodiment of the present invention.
[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement a method for accurately cutting a PDF as described in any embodiment of the present invention when executed.
[0021] The technical solution of the embodiment of the present invention realizes accurate positioning of target information by matching the anchor point algorithm in the coordinate system of the original PDF file, cuts the original PDF file to generate a cutting target by matching the information, and then generates a target PDF file based on the cutting target, which can enable the user to grasp the target information more intuitively, while reducing the user's workload and improving the user's work efficiency.
[0022] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0024] Figure 1 is a flowchart of a method for accurately cutting PDF provided according to the first embodiment of the present invention;
[0025] Figure 2 is a flow chart of a method for accurately cutting PDF provided according to the second embodiment of the present invention;
[0026] Figure 3 2 is a schematic diagram of a device for accurately cutting PDF according to a third embodiment of the present invention;
[0027] Figure 4 It is a structural schematic diagram of an electronic device for implementing a method for accurately cutting PDF according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] Embodiment 1
[0031] Figure 1 A flowchart of a method for accurately cutting PDF is provided for the first embodiment of the present invention. This embodiment can be applied to the case of intercepting target information in PDF, such as Figure 1 As shown, the method includes:
[0032] S110 , obtaining an original PDF file, and establishing a coordinate system for the original PDF file.
[0033] Among them, PDF is a universal file format that can save all fonts, formats, colors and graphics of any source document regardless of the application and platform used to create the document; the coordinate system refers to a two-dimensional plane rectangular coordinate system, including the x-axis, y-axis and origin. The coordinate system is established to use coordinates to represent the specific location of the content in the PDF file, so that users can locate the content in the PDF file when using it.
[0034] Preferably, obtaining the original PDF file and establishing a coordinate system for the original PDF file includes: obtaining the original PDF file, paging the original PDF file through a pager to obtain PDF pages; and establishing a coordinate system for each PDF page.
[0035] Specifically, the method of obtaining the original PDF file can be input by the user on the controller. The user can select the original PDF file on the terminal device connected to the controller. The user refers to the staff or technician operating the controller. The input original PDF file can be one or more, or it can be automatically captured by the controller according to the actual scenario. For example, the user's current usage scenario is to query the student information list. At this time, the controller will automatically capture all PDF files related to the student information list as the original PDF file. The pager separates each individual page of all pages in the original PDF file to obtain PDF paging, and assigns a page number to each PDF paging. Establishing a coordinate system for the original PDF file is to establish a coordinate system for each PDF paging. Exemplarily, the upper left corner of each PDF paging is used as the coordinate origin, the positive semi-axis of the x-axis is the axis extending to the right from the origin, and the positive semi-axis of the y-axis is the axis extending downward from the origin, with every 0.5 cm as the spacing, that is, every 0.5 cm represents the number 1. In this embodiment, only the upper left corner of the PDF paging is used as the coordinate origin as an example for explanation, and the specific establishment method of the coordinate system is not limited.
[0036] Preferably, after obtaining the original PDF file, the method further includes: establishing a processing tool that matches the original PDF file, wherein the processing tool includes a file interpreter tool, a page aggregator tool and a device tool.
[0037] Specifically, after obtaining the original PDF file, it is necessary to read the binary file stream of the original PDF file. The purpose of reading the binary file stream is to facilitate the subsequent processing of the original PDF file. The binary file stream saves space compared to ordinary text, which can greatly speed up the reading speed and improve efficiency. For example, the binary file stream can be expressed as: 00000111 11010001; after reading the binary file stream of the original PDF file, a processing tool matching the original PDF file is established, namely, a file interpreter tool, a page aggregator tool and a device tool, and the above-established processing tools can be used to perform relevant segmentation processing on the original PDF file.
[0038] S120 , acquiring target information, and matching the target information with the original PDF file in a coordinate system based on an anchor point algorithm to generate matching information.
[0039] Among them, the target information refers to the information that the user wants to view or needs to query. The user can choose to directly input the target information through the terminal device connected to the controller, or can indirectly input it by clicking on the target information list. The input content is usually in text form. The target information list can be automatically captured by the controller according to the scene in the original PDF file. The captured target information list can be displayed to the user after the user opens the original PDF file. For example, the original PDF file is a personnel attendance sheet for a certain month. The controller can automatically capture the date of each day in that month as a target information list and display it to the user for the user to choose. The user can enter the target information he wants to find by clicking on the target information list. The anchor algorithm is a comparison algorithm. Based on the anchor algorithm, the target information can be compared with the original PDF file in the coordinate system to generate matching information. The matching information includes coordinate domain and area information.
[0040] Preferably, the target information is obtained, and the target information is matched with the original PDF file in a coordinate system based on an anchor point algorithm to generate matching information, including: obtaining the target information and establishing an anchor point according to the target information; obtaining the coordinate system, page layout and page label of each PDF page in the original PDF file through a file interpreter tool; calculating the intersection and union ratio with the content in each PDF page through the anchor point; taking the coordinates corresponding to the content whose intersection and union ratio is greater than a preset threshold as a coordinate domain; reading the text of the content as area information through a device tool; and taking the coordinate domain and the area information as matching information.
[0041] Specifically, the target information input by the user can be used as an anchor point, and the anchor point can be text or a picture. If a text anchor point is used, the target information input by the user can be directly used as the anchor point. If a picture anchor point is used, the text in the target information can be converted into a picture through optical character recognition (OCR), and then the converted picture is used as the anchor point. Then, the coordinate system, page layout and page label of each PDF page in the original PDF file are obtained through a file interpreter tool. The file interpreter tool mainly classifies and parses the original PDF file. After obtaining the coordinate system, page layout and page label of each PDF page, the content in each PDF page is traversed through the anchor point loop, and the intersection-and-union ratio of the anchor point and the content in each PDF page is calculated. The intersection-and-union ratio refers to the ratio of the intersection area of the anchor point and the content boundary in the PDF page to the union area. The intersection-and-union ratio is a value between 0 and 1. The closer the value is to 1, the closer it matches the target information. The matching information includes a coordinate domain and region information. After calculating the intersection-and-union ratio, the coordinates corresponding to the content whose intersection-and-union ratio is greater than a preset threshold value can be used as the coordinate domain. At this time, the coordinate domain is determined according to the page layout and the page label, and the coordinates of the row or segment where the information whose intersection-and-union ratio matching the anchor point is greater than the preset threshold value is output as the coordinate domain. The preset threshold value can be preset by the user as needed. For example, the preset threshold value can be set to 0.9. When the intersection-and-union ratio of the content in the PDF paging is greater than 0.9, the coordinate domain and region information corresponding to the content can be output as matching information. The range of the region information can be determined by the controller according to the page layout, or can be set by the user. The user can set the row or paragraph where the output region information is located as the range of the region information. The coordinates of the range of the region information are the coordinate domain, which is generally represented by four coordinates, that is, the coordinates of the four vertices of the upper left corner, the lower left corner, the upper right corner and the lower right corner of the region information are used as the coordinate domain, and then the text in the coordinate domain is read as the region information by the device tool.
[0042] Exemplarily, the target information input by the user is "Zhang San". Through matching, it is determined that there is content with an intersection-and-union ratio of 1 in a PDF paging, which is greater than a preset threshold value of 0.9. Through page layout, it can be obtained that the text content of the row where "Zhang San" is located is "Zhang San's math score is 90 points", and the page label can be obtained as P3. At this time, the horizontal and vertical coordinates of "Zhang San's math score is 90 points" are P3 (2,5), (2,8), (5,5), and (5,8). This coordinate domain is output as the coordinate domain of the matching information, and the text of the content is read as the area information through the device tool, that is, the text of "Zhang San's math score is 90 points" is output as the area information of the matching information.
[0043] Furthermore, obtaining the target information and matching the target information with the original PDF file in the coordinate system based on the anchor point algorithm will also generate a match failure message. The generation of the match failure message means that there is no content in the original PDF file that matches the target information. At this time, a match failure reminder will be pushed to the user. The reminder can be in the form of text displayed to a terminal connected to the controller. The reminder content is: no relevant information was matched. For target information that does not generate matching information, it can be basically determined that the target information does not exist in the original PDF file.
[0044] Preferably, when the matching information includes at least two identical area information, the method further includes: obtaining verification information, and filtering the matching information through the verification information to generate updated matching information.
[0045] Specifically, when the user inputs the target information, there may be multiple matching information obtained, that is, the matching information contains at least two identical area information. At this time, the user can enter verification information to verify the matching information obtained. Adding multiple information verification can enhance the matching accuracy and save the workload of manual review. The input verification information will also be used as an anchor point to filter the matching information obtained to generate updated matching information; for example, when the user enters "Zhang San", there are multiple matching information. The user can enter "Beijinger" as the verification information, filter the multiple matching information to generate updated matching information, and the updated matching information contains the content corresponding to "Zhang San" and "Beijinger" at the same time.
[0046] S130 , cutting the original PDF file according to the matching information to generate a cutting target.
[0047] Cutting refers to the operation of taking a screenshot of the original PDF file. After obtaining the matching information, the controller can cut the part of the original PDF file containing the matching information according to the matching information to generate a cutting target, wherein the cutting target includes area information.
[0048] Preferably, the cutting position is determined according to the coordinate domain; and the page aggregator cuts the region information of the original PDF file according to the cutting position to generate a cutting target.
[0049] Specifically, the controller can determine the cutting position based on the coordinate domain. For example, the coordinate domain is P3 (2,5), (2,8), (5,5), (5,8), and the cutting position is the range of the horizontal coordinate 2-5 and the vertical coordinate 5-8 of the third page in the original PDF file. After determining the cutting position, the page aggregator is used to cut the area information of the original PDF file according to the cutting position to generate a cutting target. The page aggregator can hide irrelevant information and display useful data, so that the page size can be cut to generate a cutting target, and the cutting target includes the area information.
[0050] Preferably, cutting the original PDF file to generate cutting targets according to the matching information further includes: cutting the original PDF file to generate cutting targets according to the updated matching information.
[0051] Specifically, if there are multiple matching information and the user inputs verification information for filtering, the original PDF file is cut according to the updated matching information to generate a cutting target, that is, the cutting position is determined according to the updated coordinate domain, and the cutting target at this time contains the updated area information.
[0052] S140: Generate a target PDF file according to the cutting target.
[0053] Specifically, after generating the cutting target, the controller will save the cutting target as a target PDF file, and the user can view the content matching the input target information by clicking the target PDF file.
[0054] The technical solution of the embodiment of the present invention realizes accurate positioning of target information by matching the anchor point algorithm in the coordinate system of the original PDF file, cuts the original PDF file to generate a cutting target by matching the information, and then generates a target PDF file based on the cutting target, which can enable the user to grasp the target information more intuitively, while reducing the user's workload and improving the user's work efficiency.
[0055] Embodiment 2
[0056] Figure 2 This is a flowchart of a method for accurately cutting PDF provided in the second embodiment of the present invention. The technical solution of this embodiment specifically describes the generation of the target PDF file according to the cutting target. The specific contents of steps S210 and S230 are roughly the same as those of steps S110 and S130 in the first embodiment, so they will not be described in detail in this embodiment. Figure 2 As shown, the method includes:
[0057] S210: Obtain an original PDF file, and establish a coordinate system for the original PDF file.
[0058] S220 , acquiring target information, and matching the target information with the original PDF file in a coordinate system based on an anchor point algorithm to generate matching information.
[0059] S230: Cut the original PDF file according to the matching information to generate a cutting target.
[0060] S240. Create a new blank PDF file.
[0061] Specifically, after generating a cutting target, the controller will automatically create a new blank PDF file. When there is only one cutting target, the controller will create a new blank PDF file. When there are multiple cutting targets, the controller will create blank PDF files according to the number of cutting targets. For example, if three cutting targets are generated, the controller will create three blank PDF files.
[0062] S250, adding the cutting target to the blank PDF file to generate a target PDF file.
[0063] Specifically, the controller will add the cutting target to the newly created blank PDF file according to the coordinate domain of the cutting target in the original PDF file. For example, the coordinate domain of the cutting target in the original PDF file is P3(2,5), (2,8), (5,5), (5,8). The controller will add the cutting target to the first page of the newly created blank PDF file according to the coordinate domain, that is, the coordinate domain of the cutting target in the newly created blank PDF file is P1(2,5), (2,8), (5,5), (5,8), and the target PDF file can be named according to the naming rules set by the user. At this time, it is completely guaranteed that the format of the intercepted cutting target and the original PDF file area information are consistent. When there are multiple cutting targets, for example, 3 cutting targets are generated, the controller will create 3 blank PDF files. The controller will add the 3 cutting targets to the first pages of the 3 newly created blank PDF files according to the coordinate domain of each cutting target in the original PDF file to generate 3 target PDF files, and the controller will also summarize the 3 target PDF files for user viewing and subsequent operations.
[0064] Specific application scenarios: 1. Student information printing: Use this technical solution to automatically download a PDF file list from a university website and connect it to the internal verification information system. When there is student data that needs to be verified, the PDF file is automatically queried, verified, and intercepted based on the student name, major, and student number. Finally, the result of the verification success or failure, as well as the intercepted result, is returned to the verification information system, thus automating the entire student information data verification process.
[0065] 2. Bank receipt printing: To use this technical solution, go to a bank website to download the bank receipt PDF file, enter the pre-set interception area parameters of this bank, intercept each page of this PDF file according to the parameters, rename and save it locally, and finally transmit this part of the data to the server for easy use and printing by business teachers in various regions.
[0066] The technical solution of the embodiment of the present invention realizes accurate positioning of target information by matching the anchor point algorithm in the coordinate system of the original PDF file, cuts the original PDF file by matching information to generate a cutting target, and then adds the cutting target to the blank PDF file by creating a new blank PDF file to generate a target PDF file, thereby realizing precise cutting of target information, allowing users to grasp the target information more intuitively, while reducing the user's workload and improving the user's work efficiency.
[0067] Embodiment 3
[0068] Figure 3 This is a schematic diagram of the structure of a device for accurately cutting PDF provided by Embodiment 3 of the present invention. Figure 3 As shown, the device includes: a PDF coordinate system establishment module 310, which is used to obtain the original PDF file and establish a coordinate system for the original PDF file; a target information matching module 320, which is used to obtain target information, and match the target information with the original PDF file in the coordinate system based on the anchor point algorithm to generate matching information, wherein the matching information includes a coordinate domain and area information; a cutting target generation module 330, which is used to cut the original PDF file according to the matching information to generate a cutting target, wherein the cutting target includes area information; and a target file generation module, which is used to generate a target PDF file according to the cutting target.
[0069] Preferably, the PDF coordinate system establishing module 310 includes: a PDF file acquiring unit, used to acquire an original PDF file, and to obtain PDF pages by paging the original PDF file through a pager; and a coordinate establishing unit, used to establish a coordinate system for each PDF page.
[0070] Preferably, the PDF coordinate system establishing module 310 further includes: a processing tool establishing unit, which is used to establish a processing tool matching the PDF file after acquiring the original PDF file, wherein the processing tool includes a file interpreter tool, a page aggregator tool and a device tool.
[0071] Preferably, the target information matching module 320 is specifically used to obtain target information and establish anchor points based on the target information; obtain the coordinate system, page layout and page label of each PDF page in the original PDF file through a file interpreter tool; calculate the intersection and union ratio with the content in each PDF page through the anchor point; use the coordinates corresponding to the content with an intersection and union ratio greater than a preset threshold as a coordinate domain; read the text of the content as area information through a device tool; and use the coordinate domain and area information as matching information.
[0072] Preferably, the device also includes a matching information verification module, which is specifically used to: when the matching information contains at least two identical area information, obtain verification information, and filter the matching information through the verification information to generate updated matching information; cut the original PDF file according to the matching information to generate a cutting target, including: cutting the original PDF file according to the updated matching information to generate a cutting target.
[0073] Preferably, the cutting target generating module 330 is specifically used to: determine the cutting position according to the coordinate domain; and generate the cutting target by cutting the region information of the original PDF file according to the cutting position through the page aggregator.
[0074] Preferably, the target file generating module 340 is specifically used to: create a new blank PDF file; and add the cutting target to the blank PDF file to generate a target PDF file.
[0075] The technical solution of the embodiment of the present invention realizes accurate positioning of target information by matching the anchor point algorithm in the coordinate system of the original PDF file, cuts the original PDF file to generate a cutting target by matching the information, and then generates a target PDF file based on the cutting target, which can enable the user to grasp the target information more intuitively, while reducing the user's workload and improving the user's work efficiency.
[0076] The device for accurately cutting PDF provided by the embodiment of the present invention can execute the method for accurately cutting PDF provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0077] Embodiment 4
[0078] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0079] like Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0080] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0081] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a method for accurately cutting a PDF.
[0082] In some embodiments, the method for accurately cutting PDF may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for accurately cutting PDF described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the method for accurately cutting PDF in any other appropriate manner (e.g., by means of firmware).
[0083] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0084] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0085] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0086] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0087] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0088] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0089] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0090] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for accurately cutting PDF, characterized in that: include: Obtaining an original PDF file, and establishing a coordinate system for the original PDF file; Acquire target information, and match the target information with the original PDF file in the coordinate system based on an anchor point algorithm to generate matching information, wherein the matching information includes a coordinate domain and region information; Cutting the original PDF file according to the matching information to generate a cutting target, wherein the cutting target includes the region information; Generate a target PDF file according to the cutting target; The obtaining of the original PDF file and establishing a coordinate system for the original PDF file includes: obtaining the original PDF file, paging the original PDF file through a pager to obtain PDF pages; and establishing a coordinate system for each of the PDF pages; After obtaining the original PDF file, the method further includes: establishing a processing tool matching the original PDF file, wherein the processing tool includes a file interpreter tool, a page aggregator tool and a device tool; Among them, obtaining target information, matching the target information with the original PDF file in the coordinate system based on the anchor algorithm to generate matching information, includes: obtaining target information, and establishing an anchor according to the target information; obtaining the coordinate system, page layout and page label of each PDF page in the original PDF file through the file interpreter tool; calculating the intersection and union ratio with the content in each PDF page through the anchor; taking the coordinates corresponding to the content with the intersection and union ratio greater than a preset threshold as the coordinate domain; reading the text of the content as the area information through the device tool; taking the coordinate domain and the area information as the matching information.
2. The method according to claim 1, characterized in that When the matching information includes at least two identical area information, it further includes: Acquire verification information, and filter the matching information by using the verification information to generate updated matching information; The step of cutting the original PDF file according to the matching information to generate a cutting target includes: The original PDF file is cut according to the updated matching information to generate the cutting target.
3. The method according to claim 2, characterized in that The step of cutting the original PDF file according to the matching information to generate a cutting target includes: Determine a cutting position according to the coordinate domain; The page aggregator cuts the region information of the original PDF file according to the cutting position to generate a cutting target.
4. The method according to claim 3, characterized in that The step of generating a target PDF file according to the cutting target includes: Create a new blank PDF file; The cutting target is added to the blank PDF file to generate the target PDF file.
5. A device for accurately cutting PDF, characterized in that: include: A PDF coordinate system establishment module, used for acquiring an original PDF file and establishing a coordinate system for the original PDF file; A target information matching module, used for acquiring target information, matching the target information with the original PDF file in the coordinate system based on an anchor point algorithm to generate matching information, wherein the matching information includes a coordinate domain and area information; A cutting target generating module, used for cutting the original PDF file according to the matching information to generate a cutting target, wherein the cutting target includes the region information; A target file generation module, used for generating a target PDF file according to the cutting target; The PDF coordinate system establishment module includes: a PDF file acquisition unit, which is used to: acquire an original PDF file, and paginate the original PDF file to obtain PDF pages through a pager; and establish a coordinate system for each PDF page; The PDF coordinate system establishment module further includes: a processing tool establishment unit, which is used to: establish a processing tool matching the original PDF file, wherein the processing tool includes a file interpreter tool, a page aggregator tool and a device tool; Among them, the target information matching module is specifically used to: obtain target information and establish an anchor point according to the target information; obtain the coordinate system, page layout and page label of each PDF page in the original PDF file through the file interpreter tool; calculate the intersection and union ratio with the content in each PDF page through the anchor point; use the coordinates corresponding to the content whose intersection and union ratio is greater than a preset threshold as the coordinate domain; read the text of the content as area information through the device tool; and use the coordinate domain and the area information as the matching information.
6. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 4.
7. A computer storage medium, characterized in that: The computer storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method according to any one of claims 1 to 4 when executed.
Citation Information
Patent Citations
PDF file analysis method, device and equipment and computer readable storage medium
CN109726388A
Picture cutting and extracting method and device, computer equipment and storage medium
CN110598623A