Method for generating PDF (Portable Document Format) vertical text paragraphs

By identifying, eliminating duplicate text, dividing areas and identifying paragraphs, the problem of vertical text processing in PDF documents is solved, and efficient generation of vertical text paragraphs is achieved, saving time for manual adjustment.

CN119598972APending Publication Date: 2025-03-11赛博爱思(上海)软件科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411667176.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

The prior art is difficult to correctly process vertical text in PDF documents, resulting in a longer manual adjustment time.

Method used

By identifying and extracting the text in the PDF, removing duplicate and overlapping text, dividing text areas, identifying whether each area is vertical text, and paragraph identification of vertical text areas, and finally generating vertical text fields.

Benefits of technology

It realizes the correct generation of vertical text paragraphs in PDF documents, saving manual adjustment time and improving processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119598972A_ABST
    Figure CN119598972A_ABST
Patent Text Reader

Abstract

The invention discloses a method for generating paragraphs of a PDF (Portable Document Format) vertical text. The method comprises the following steps: identifying and extracting characters in the PDF; removing repeated and overlapped characters according to the extracted characters; dividing the rejected characters into a plurality of areas; identifying whether characters are vertically arranged in each area; performing paragraph recognition on the vertical character region; and obtaining the vertical character paragraphs after identification. According to the method, the vertical character paragraphs in the PDF document can be correctly generated, and the time for manual adjustment after manual copying or copying of characters in a wrong sequence is greatly saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of information technology, and in particular relates to a method for generating PDF vertical text paragraphs. Background Art

[0002] Vertical text, as an ancient typesetting method, has a long history in China. Since ancient times, Chinese characters have been written from top to bottom and from right to left. Vertical text not only reflects the aesthetic taste of the ancients, but is also an important carrier of cultural inheritance. With the development of science and technology, vertical text has not been eliminated, but has gradually returned to modern design. In the design of some advertisements, books, posters, etc., vertical text has become a fashion element. PDF is a common electronic document format with the characteristics of cross-platform, reliability, editability and security. It is widely used in document exchange, file archiving, e-books, forms and reports, as well as printing and publishing. When it is necessary to quote the text content in a PDF file, the common method is to manually copy the text and then put it into other word processing software for typesetting and editing. The text in most PDF documents is arranged horizontally. The existing technology mainly focuses on horizontal text, and often ignores vertical text to a certain extent or completely. In the existing technology, there is a certain method to divide the text into text lines, and then divide the text lines into text paragraphs, but it does not involve the processing of vertical text. The invention solves the defect that the vertical text in the PDF document cannot be correctly processed in the prior art, and provides a method for generating a PDF vertical text paragraph. Summary of the invention

[0003] To solve the above technical problems, the present invention proposes a method for generating vertical text paragraphs in PDF, which can correctly generate vertical text paragraphs in PDF documents and save a lot of time for manual transcription or manual adjustment after copying text in the wrong order.

[0004] To achieve the above object, the present invention provides a method for generating a PDF vertical text paragraph, comprising: Recognize and extract text from PDF; Eliminate repeated and overlapping texts based on the extracted texts; Divide the removed text into several areas; Identify whether each area has vertical text; Perform paragraph recognition on vertical text areas; After recognition, a vertical text paragraph is obtained.

[0005] Optionally, the text includes text content, font, font size, coordinates and direction.

[0006] Optionally, removing duplicate and overlapping text from the extracted text includes: According to the extracted text, text with the same content, the same font, the same font size, the same direction and close coordinates is defined as overlapping and repeated text, and the repeated and overlapping text is removed; the repeated and overlapping text is expressed in the PDF as bold text or text stroke.

[0007] Optionally, the removed text is divided into several areas including: Set a coefficient to define two characters whose distance is less than the average font size multiplied by the coefficient as close characters; Divide all words that are close to each other into the same area.

[0008] Optionally, identifying whether each area contains vertical text includes: Rotate the entire area to the positive direction of the text; Project the text onto the y-axis and calculate the ratio of the length of the interval with text to the total length of the interval, which is recorded as the x-axis coverage rate; Project the text onto the y-axis and calculate the ratio of the length of the interval with text to the total length of the interval, which is recorded as the y-axis coverage rate; If the y-axis coverage is greater than the x-axis coverage, the text is vertical, otherwise it is horizontal.

[0009] Optionally, paragraph recognition for the vertical text area includes: Divide the text in the vertical text area into several vertical lines; Divide the vertical lines into several groups according to the font size; Divide the text in each group according to the line spacing; Further divide the text divided according to line spacing according to the line indentation; Generate vertical text paragraphs based on the further divided text.

[0010] Optionally, the vertical text paragraph selection includes but is not limited to txt, rtf, xml or json file formats, and can also be placed in the system clipboard.

[0011] Technical effect of the invention: The invention discloses a method for generating vertical text paragraphs in a PDF document, which can correctly generate vertical text paragraphs in a PDF document, greatly saving the time for manual transcription or manual adjustment after copying text in the wrong order. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 A schematic diagram of a flow chart of a method for generating a PDF vertical text paragraph according to an embodiment of the present invention; Figure 2 A schematic diagram of a process for identifying whether each area has vertical text according to an embodiment of the present invention; Figure 3 The figure is a schematic diagram of a process of performing paragraph recognition on a vertical text area according to an embodiment of the present invention. DETAILED DESCRIPTION

[0013] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0014] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0015] like Figure 1 As shown, this embodiment provides a method for generating a PDF vertical text paragraph, including: Recognize and extract text from PDF; Eliminate repeated and overlapping texts based on the extracted texts; Divide the removed text into several areas; Identify whether each area has vertical text; Perform paragraph recognition on vertical text areas; After recognition, a vertical text paragraph is obtained.

[0016] Furthermore, the text includes text content, font, font size, coordinates and direction.

[0017] Furthermore, the repeated and overlapping words are removed according to the extracted words, including: Based on the extracted text, text with the same content, font, size, direction and close coordinates is defined as overlapping and repeated text, and the repeated and overlapping text is removed; the repeated and overlapping text is expressed in PDF as bold text or text stroke.

[0018] Furthermore, the removed text is divided into several areas including: Set a coefficient to define two characters whose distance is less than the average font size multiplied by the coefficient as close characters; Divide all words that are close to each other into the same area. Close distance is transitive, for example, if A and B are close to each other, and B and C are close to each other, then A and C are also close to each other.

[0019] Further, such as Figure 2 As shown, identifying whether each area has vertical text includes: Rotate the entire area to the positive direction of the text; Project the text onto the y-axis and calculate the ratio of the length of the interval with text to the total length of the interval, which is recorded as the x-axis coverage rate; Project the text onto the y-axis and calculate the ratio of the length of the interval with text to the total length of the interval, which is recorded as the y-axis coverage rate; If the y-axis coverage is greater than the x-axis coverage, the text is vertical, otherwise it is horizontal.

[0020] Further, such as Figure 3 As shown, paragraph recognition for a vertical text area includes: Divide the text in the vertical text area into several vertical lines; divide the text that overlaps in the horizontal direction into the same vertical line; Divide the vertical lines into several groups according to the font size; when the font sizes of two consecutive vertical lines are different, divide them into different groups; Divide the text in each group according to the line spacing; calculate the line spacing of adjacent vertical lines in a group, and when the line spacing of some of them is larger than the other line spacing, they are determined to be paragraph spacing. The two lines before and after the paragraph spacing are divided into different groups; The text divided according to the line spacing is further divided according to the line indentation; for several vertical lines in a group, if the starting positions of some of the vertical lines are lower than other lines, it is determined that they have line indentation, and the vertical lines with line indentation are divided into different groups from the adjacent previous vertical lines; Vertical text paragraphs are generated based on the further divided text; each group is identified as a paragraph, and the vertical text in it is spliced ​​into the text of the paragraph.

[0021] Furthermore, vertical text paragraph selection includes but is not limited to txt, rtf, xml or json file formats, and can also be placed in the system clipboard. The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for generating vertical text paragraphs in PDF, characterized in that: include: Recognize and extract text from PDF; Eliminate repeated and overlapping texts based on the extracted texts; Divide the removed text into several areas; Identify whether each area has vertical text; Perform paragraph recognition on vertical text areas; After recognition, a vertical text paragraph is obtained.

2. The method for generating a PDF vertical text paragraph according to claim 1, characterized in that: The text includes text content, font, font size, coordinates and direction.

3. The method for generating a PDF vertical text paragraph according to claim 1, characterized in that: Remove duplicate and overlapping text based on the extracted text, including: According to the extracted text, text with the same content, the same font, the same font size, the same direction and close coordinates is defined as overlapping and repeated text, and the repeated and overlapping text is removed; the repeated and overlapping text is expressed in the PDF as bold text or text stroke.

4. The method for generating a PDF vertical text paragraph according to claim 1, characterized in that: The removed text is divided into several areas including: Set a coefficient to define two characters whose distance is less than the average font size multiplied by the coefficient as close characters; Divide all words that are close to each other into the same area.

5. The method for generating a PDF vertical text paragraph according to claim 1, characterized in that: Identifying whether each area has vertical text includes: Rotate the entire area to the positive direction of the text; Project the text onto the y-axis and calculate the ratio of the length of the interval with text to the total length of the interval, which is recorded as the x-axis coverage rate; Project the text onto the y-axis and calculate the ratio of the length of the interval with text to the total length of the interval, which is recorded as the y-axis coverage rate; If the y-axis coverage is greater than the x-axis coverage, the text is vertical, otherwise it is horizontal.

6. The method for generating a PDF vertical text paragraph according to claim 1, characterized in that: Paragraph recognition for vertical text areas includes: Divide the text in the vertical text area into several vertical lines; Divide the vertical lines into several groups according to the font size; Divide the text in each group according to the line spacing; Further divide the text divided according to line spacing according to the line indentation; Generate vertical text paragraphs based on the further divided text.

7. The method for generating a PDF vertical text paragraph according to claim 1, characterized in that: The vertical text paragraph selection includes but is not limited to txt, rtf, xml or json file formats, and can also be placed in the system clipboard.