METHOD, DEVICE, COMPUTER EQUIPMENT AND STORAGE MEDIUM FOR PROCESSING PDF FILES

There is provided a method for processing tables in a PDF file, including: parsing the PDF file to obtain coordinates of start points and end points of all transverse line sections and longitudinal line sections; obtaining coordinates of crosspoints of all line sections and recording coordinates of line sections that form the crosspoints; calculating all unit grids according to the coordinates of the crosspoints and the coordinates of the line sections; and filling every character respectively into a corresponding unit grid according to character coordinates obtained in parsing the PDF file.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims the priority benefit of Chinese Patent Application Serial Number 202211634325.6, filed on Dec. 19, 2022, the full disclosure of which is incorporated herein by reference.

FIELD OF THE DISCLOSURE

This disclosure generally relates to the file processing and, more particularly, to a method, a device, a computer equipment and a storage medium for transforming tables in a portable document format to a target document.

BACKGROUND OF THE DISCLOSURE

The portable document format (PDF) file and the Office Software are both generally used electronic files. Although a PDF file can be read almost on any operating system, contents of the PDF file do not include table objects and it is difficult to edit the PDF file. During editing a PDF file, the PDF file is generally transformed to a file having another format. However, although tables are also generally used electronic files, current techniques are not able to directly transform the tables in a PDF file to a format of an Office Software or other table-form document.

Accordingly, the present disclosure further provides a method, a device, a computer equipment and a storage medium that can recognize and divide tables in a PDF file and transform the tables to other file formats.

SUMMARY

The present disclosure provides a method, a device, a computer equipment and a storage medium for processing tables in a PDF file that firstly parse start/end coordinates of all line sections according to path objects parsed from the PDF file, and then calculate all unit grids and divide different tables according to crosspoints of all line sections.

The present disclosure provides a method for transforming tables in a PDF file into a target document, including the steps of: parsing the PDF file to obtain coordinates of start points and end points of all transverse line sections and longitudinal line sections; obtaining coordinates of crosspoints of all line sections and recording coordinates of line sections that form the crosspoints; calculating all unit grids according to the coordinates of the crosspoints and the coordinates of the line sections; filling every character respectively into a corresponding unit grid according to character coordinates obtained in parsing the PDF file; and generating the target document.

The present disclosure further provides a device for processing tables in a PDF file. The device includes a non-volatile storage medium, a memory and a processor. The non-volatile storage medium is configured to record a computer program. The memory is configured to provide environment for operations of the computer program in the non-volatile storage medium. The processor is configured to run the computer program to parse the PDF file, record coordinates of start points and end points of all transverse line sections and longitudinal line sections as well as character coordinates into the memory, calculate coordinates of crosspoints of all line sections and coordinates of line sections that form the crosspoints to be stored in the memory, calculate all grid units according to the coordinates of the crosspoints and the coordinates of the line sections, and fill every character respectively into a corresponding unit grid according to the character coordinates.

The present disclosure further provides a computer equipment including a storage device and a processor. The storage device is used to record a computer program. The processor is used to run the computer program in the storage device to execute the embodiment of a method for processing tables in a PDF file.

The present disclosure further provides a content accessible memory recorded with a computer program. The computer processor is run by a processor to implement the embodiment of a method for processing tables in a PDF file.

DETAILED DESCRIPTION OF THE DISCLOSURE

One objective of the present disclosure is to provide a method for processing tables (including recognizing, dividing or the like) in a portable document format (PDF) file, and a device, a computer equipment and a content accessible memory using the same. The present disclosure further transforms the tables in the PDF file to a target document for being edited by a user.

Please refer toFIG.1, it is a schematic block diagram of a computer equipment100according to one embodiment of the present disclosure. The computer equipment100is equipment capable of reading and/or transforming PDF files such as a desktop computer, a tablet computer or a notebook computer without particular limitations.

The computer equipment100includes a processor11and a storage device connected via a bus14. The storage device includes a non-volatile storage medium12and a memory13. The non-volatile storage medium12records an operating system (OS)121and a computer program122. The computer program122includes programs for running a method of processing tables in a PDF file according to the embodiments of the present disclosure. The method is described by an example hereinafter.

The processor11includes, for example, a central processing unit (CPU) and/or a micro processing unit (MCU) that provides calculation and control capability to support operations of the computer equipment100. Methods that the processor11runs the operating system121and the computer program122and accesses the memory13via the bus14are known to the art, and thus details thereof are not described herein.

The memory13provides an environment of operations of the computer program122in the non-volatile storage medium12, e.g., recording contents of path objects (e.g., including coordinates of start/end points , colors, line widths of line sections, but not limited to), text objects (e.g., including fonts, coordinates, colors, sizes of characters, but not limited to), and image objects obtained in parsing the PDF file, and is for being accessed by the processor11according to the computer program122.

Please refer toFIG.2, it is a flow chart of a method for processing tables in a PDF file by the computer equipment100according to one embodiment of the present disclosure. The method includes the steps of: parsing a PDF file to obtain coordinates of start points and end points of all transverse line sections and longitudinal line sections (Step S21); combining the transverse line sections and the longitudinal line sections (Step S22); obtaining coordinates of crosspoints of all line sections and recording coordinates of line sections that form the crosspoints (Step S23); calculating all unit grids according to the coordinates of the crosspoints and the line sections (Step S24); dividing table regions according to connectivity of all unit grids (Step S25); filling every character respectively into a corresponding unit grid according to character coordinates obtained in parsing the PDF file (Step S26); and generating a target document (Step S27). The method for processing tables in a PDF file of the present disclosure is described hereinafter by an example.

Step S21: The processor11runs the computer program122to parse a PDF file. The PDF file is, for example, a file designated by a user, and the parsed contents are recorded in the memory13.

The parsing PDF file of the present disclosure is, for example, to record, using a user defined source language, contents of the PDF file, e.g., including path objects, text objects or the like, into the memory13for being accessed by the computer program122for the following calculations, e.g., including calculating coordinates of crosspoints, calculating unit grids, dividing table regions and filling characters as described below.

For example,FIG.3Ashows all transverse line sections, and terminal coordinates (shown by dots) at two terminals (i.e. start points and end points) of each transverse line section obtained by the processor11;FIG.3Bshows all longitudinal line sections, and terminal coordinates (shown by dots) at two terminals (i.e. start points and end points) of each longitudinal line section obtained by the processor11; and FIG.3C is a schematic diagram of putting all transverse line sections and longitudinal line sections on the same two-dimensional space (e.g., created in the memory). The two-dimensional space is preferable corresponding to an area of a displayed image on a screen of the computer equipment. In the present disclosure, coordinates are, for example, values or positions corresponding to a transverse axis and a longitudinal axis inFIGS.3A to3C. For example, both a point A and a point A′ have coordinates (600,75).

It should be mentioned that the computer equipment100does not need to showFIGS.3A to3Con a user interface (e.g., the screen), andFIGS.3A and3Care shown herein only for illustration purposes. The computer equipment100records, e.g., using a user defined data structure, every line section (including the transverse line sections and the longitudinal line sections) and coordinates of start/end points thereof in the memory13. Furthermore, dots shown inFIGS.3A to3Care only intended to illustrate, and computer equipment100does not need to form the dots at two terminals of a line section.

Step S22: When the processor11recognizes (using the computer program122being executed) that two line sections are too close to each other (e.g., a distance therebetween being smaller than or equal to predetermined number of pixels, e.g., 3 pixels, which is determined according to the resolution), the two line sections are combined to one line section.

Please refer toFIG.4, it shows a first transverse line section LS11and a second transverse line section LS22after parsing the PDF file. When identifying that a transverse distance between the first transverse line section LS11and the second transverse line section LS22Is smaller than or equal to a predetermined pixel numbers, the processor11combines, using expansion procedure, the first transverse line section LS11and the second transverse line section LS22into one transverse line section LS1, i.e. changing two line sections in the memory13to one line section, e.g., changing 4 terminals to 2 terminals. The method for processing longitudinal line sections is similar, and thus details thereof are not repeated herein.

The Step S22is an optional step.

Step S23: Please refer toFIG.5, the processor11then calculates coordinates of crosspoints (e.g., also shown as dots) of all line sections (including transverse line sections and longitudinal line sections) and coordinates of line sections that form the crosspoints (i.e. line sections connecting to the same crosspoints) to be stored in the memory13. The coordinates are values or positions corresponding to a transverse axis and a longitudinal axis inFIG.5. It is seen fromFIGS.5and3thatFIG.5further includes multiple coordinates of crosspoints (i.e. the dots), which are stored in the memory13using the user defined data structure.

Step S24: Referring toFIG.5again, the processor11calculates all unit grids according to the coordinates of the crosspoints and the line sections obtained in Step S23. In one aspect, each unit grid is consisted of coordinates of four crosspoints. In another aspect, each grid unit is consisted of four sides. In a further aspect, each grid unit is consisted of coordinates of four crosspoints and four sides. That is, each unit grid and the associated coordinates of four crosspoints and/or four sides (i.e. a line section between two crosspoints) are recorded by the user defined data structure in the memory13.

Step S25: This step is used to divide multiple table regions in the PDF file. For example, referring toFIG.6A, it shows three unit grids A, B and C. One side of the unit grid A is connected to one side of the unit grid B, and one side of the unit grid B is connected to one side of the unit grid C. For example, when identifying that crosspoints of two crosspoints of the unit grid A and the unit grid B are overlapped (or smaller than or equal to a predetermined pixel distance) and/or one side of the unit grid A and the unit grid B is overlapped (or smaller than or equal to a predetermined pixel distance), it means that the two unit grids are connected to each other (i.e. with connectivity). For example, referring toFIG.6B, it shows that the unit grid B and the unit grid C are not connected to each other (i.e. no connectivity). The processor11identifies that the unit grids A, B and the unit grid C inFIG.6Bare two table regions. The processor11sequentially identifies the connectivity of every unit grid recorded in the memory13with adjacent unit grids thereof. In this way, it is able to identify two table regions as shown inFIG.5, e.g., a left table and a right table.

After this step, the memory13records data associated with different tables according to the user defined data structure. For example, the memory13records the left table as a Table I (or Module I), and a position of the Table I, as well as all unit grids in the Table I and coordinates of four crosspoints and/or four sides associated with each unit grid in the Table I. The memory13also records the right table as a Table II (or

Module II), and a position of the Table II, as well as all unit grids in the Table II and coordinates of four crosspoints and/or four sides associated with each unit grid in the Table II.

However, if it is known that there is only one table in a PDF file, the Step S25is not performed by the computer program.

Step S26: As mentioned above, after parsing the PDF file by the processor11, text objects are also recorded in the memory13, e.g., including coordinates of characters. The processor11then fills all characters sequentially into corresponding unit grids (coordinate range of each unit grid being known after the Step S24) according to the coordinate of every character so as to finish the recognition procedure of tables of the present disclosure.

In the present disclosure, the path objects and the text objects can be obtained in the same or different stages. For example in one aspect, the path objects are acquired in the Step S21but the text objects are acquired in the Step S26. In another aspect, the path objects and the text objects are both acquired in the Step S21to be recorded in the memory13.

Step S27. Finally, after all unit grids are calculated and filled with the corresponding characters, a target document is generated according to a format of the target document.

In the present disclosure, the target document is, for example, Office Software including Word, Excel, Access, Outlook, PowerPoint, but not limited to.

The target document may be other document formats, e.g., xls format or Numbers format, but not limited to.

The format and writing of the target document are known to the art, i.e. using the conventional method to generate the target document, and thus details thereof are not described herein. The main objective of the present disclosure is to provide a method for processing tables in the PDF file.

The present disclosure further provides a computer equipment including a storage device and a processor11. The storage device is used to record a computer program122. The processor11is used to run the computer program122in the storage device to perform the method of processing tables in the PDF file as shown inFIG.2.

The present disclosure further provides a content accessible memory12which records a computer program122. The computer program122is run by the processor11to implement the method of processing tables in the PDF file as shown inFIG.2.

As mentioned above, because contents of a PDF file do not include table objects, the prior art is not able to transform tables in the PDF file directly into formats of Office Software or other table-form documents. Accordingly, the present disclosure further provides a method (e.g., referring toFIG.2), a device, a computer equipment and a storage medium (e.g., referring toFIG.1) that recognize tables in a PDF file and transform the recognized tables into other document formats. Therefore, users can transform the tables in the PDF file according to a format of a target document to facilitate the editing the tables.