A translation method, device and equipment of a PDF document and a storage medium

CN122965518APending Publication Date: 2026-10-23UC MOBILE CHINA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610874679.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-16
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

但是,现有技术中仍存在由于文件上传与服务端解析耗时较长造成的文档翻译速度慢、链路长的问题,以及由于服务端对文档内容分块不准确和模型翻译能力不足造成的对照翻译效果差的问题

Benefits of technology

[0016]根据本申请的实施例,通过将PDF文档分块逻辑由服务端下沉至端侧,并结合分块优化算法,避免了服务端分块效果不可控的问题,提高文档分块的准确性以及对照翻译的准确性,同时节省了文件上传与服务端解析的时间,使得翻译响应速度大幅提升。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122965518A_ABST
    Figure CN122965518A_ABST
Patent Text Reader

Abstract

The application provides a translation method, device and equipment of a PDF document and a storage medium, and relates to the technical field of document processing. The translation method of the PDF document comprises the following steps: in response to a translation instruction of a user, a current PDF document page is parsed to obtain a text block and / or an image block corresponding to the PDF document page; the text block and / or the image block are uploaded to a server respectively to obtain a text translation result and / or an image translation result; and the original text and the translated text are displayed in the PDF document page based on the text translation result and / or the image translation result. According to the embodiment of the application, the text is divided locally on the side of the terminal, the translation speed of the whole PDF document is improved, and the user experience of the contrast translation is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of document processing technology, and more specifically, to a method, apparatus, device, and storage medium for translating PDF documents. Background Technology

[0002] PDF containers, as one of the main formats for electronic document transmission and storage, support a large number of multilingual documents. When disseminating or sharing information through PDF documents, translation is often necessary.

[0003] In existing PDF document translation applications, the document typically needs to be uploaded to a server for parsing and translation. The translation result is then rendered by the front-end. The process can be summarized as: trigger translation → file upload and parsing → pagination of translation results → rendering the translated page. However, current technologies still suffer from slow translation speeds and long processing times due to lengthy file upload and server-side parsing processes, as well as poor translation quality due to inaccurate server-side document content segmentation and insufficient model translation capabilities. Summary of the Invention

[0004] According to one aspect of this application, a method for translating a PDF document is provided, comprising: in response to a user's translation instruction, parsing the current PDF document page to obtain text blocks and / or image blocks corresponding to the PDF document page; uploading the text blocks and / or image blocks to a server respectively to obtain text translation results and / or image translation results; and displaying a comparison between the original text and the translation on the PDF document page based on the text translation results and / or image translation results.

[0005] According to some embodiments, in response to a user's translation instruction, the current PDF document page is parsed to obtain text blocks and / or image blocks corresponding to the PDF document page, including: obtaining text objects and their position information in the PDF document page; clustering the text objects according to their position information to form multiple lines of the PDF document page; determining the type of the multiple lines; obtaining the geometric information corresponding to the multiple lines, and segmenting the multiple lines based on their type and geometric information to generate text blocks.

[0006] According to some embodiments, in response to a user's translation instruction, the current PDF document page is parsed to obtain text blocks and / or image blocks corresponding to the PDF document page, including: obtaining image objects and their location information in the PDF document page; and generating image blocks based on the image objects and their location information.

[0007] According to some embodiments, text objects are clustered based on their position information to form multiple rows of a PDF document page. This includes: determining whether the current text object is a subscript or superscript; isolating the current text object if it is a subscript or superscript; collecting the current text object into the row that matches the current text object in the multiple rows if it is not a subscript or superscript, based on the position information of the current text object; and after the multiple rows are collected, clustering the isolated text objects based on their position information to insert the isolated text objects back into the row that matches the isolated text objects in the multiple rows.

[0008] According to some embodiments, determining whether the current text object is a superscript or subscript symbol includes: scanning the current text object based on a preset symbol judgment rule; obtaining the midline height of the line that matches the current text object among multiple lines; and determining the relative position of the scanned current text object and the midline height to determine whether the current text object is a superscript or subscript symbol.

[0009] According to some embodiments, after multiple lines are collected, the isolated text objects are clustered based on their location information to insert them back into the lines that match the isolated text objects. This includes: determining a target line that matches the isolated text objects in the multiple lines based on their location information; determining the insertion position of the isolated text objects in the target line to insert them back into the target line; and updating the bounding box of the target line so that the target line covers the isolated text objects.

[0010] According to some embodiments, determining the type of the plurality of rows includes: scanning the plurality of rows one by one to identify the feature markers of each row in the plurality of rows; and performing a global continuity check based on the feature markers to determine the type of the plurality of rows.

[0011] According to some embodiments, text blocks and / or image blocks are uploaded to the server to obtain text translation results and / or image translation results, including: obtaining the original text in the text block and the position information of the text block in the PDF document page; obtaining the image information in the image block and the position information of the image block in the PDF document page; uploading the original text of the text block to the server and obtaining the text translation result corresponding to the original text from the server; uploading the image information of the image block to the server and obtaining the image translation result corresponding to the image information from the server.

[0012] According to some embodiments, based on text translation results and / or image translation results, a comparison display of the original text and the translated text is presented on a PDF document page, including: merging the text translation results and / or image translation results to obtain the final translation; and formatting the original text and the final translation on the PDF document page according to the position information of the text blocks and / or image blocks on the PDF document page, so as to display the original text and the final translation on the PDF document page in comparison.

[0013] According to one aspect of this application, a PDF document translation apparatus is provided, comprising: a semantic segmentation module, used to parse the current PDF document page in response to a user's translation instruction to obtain text blocks and / or image blocks corresponding to the PDF document page; an information transmission module, used to upload the text blocks and / or image blocks to a server respectively to obtain text translation results and / or image translation results; and a layout display module, used to display a comparison between the original text and the translation on the PDF document page based on the text translation results and / or image translation results.

[0014] According to one aspect of this application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs; and, when the one or more programs are executed by the one or more processors, causing the one or more processors to perform the method as described above.

[0015] According to one aspect of this application, a computer-readable storage medium is provided that stores a computer program or instructions thereon, which, when executed by a processor, implement the method described above.

[0016] According to the embodiments of this application, by moving the PDF document segmentation logic from the server to the client side and combining it with a segmentation optimization algorithm, the problem of uncontrollable segmentation effect on the server side is avoided, the accuracy of document segmentation and the accuracy of translation are improved, and the time for file upload and server parsing is saved, resulting in a significant improvement in translation response speed.

[0017] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application.

[0019] Figure 1 A flowchart illustrating a method for translating a PDF document according to an example embodiment of this application is shown.

[0020] Figure 2A schematic diagram of a PDF document translation apparatus according to an example embodiment of this application is shown.

[0021] Figure 3 A schematic diagram of an electronic device according to an example embodiment of this application is shown. Detailed Implementation

[0022] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.

[0023] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, they are provided so that this application will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted.

[0024] The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a full understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of these specific details, or other methods, components, materials, apparatus, or operations may be employed. In these cases, well-known structures, methods, apparatuses, implementations, materials, or operations will not be shown or described in detail.

[0025] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0026] The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. 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 apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.

[0027] This application provides a method, apparatus, device, and storage medium for translating PDF documents, which can perform text segmentation and extraction locally on the device side, solving the problem of slow document upload and parsing speed, and improving the accuracy of segmentation and comparative translation.

[0028] The following will describe in detail, with reference to the accompanying drawings, a method, apparatus, device, and storage medium for translating PDF documents according to embodiments of this application.

[0029] Figure 1 A flowchart illustrating a method for translating a PDF document according to an example embodiment of this application is shown.

[0030] like Figure 1 As shown, in step S100, in response to the user's translation instruction, the current PDF document page is parsed to obtain the text blocks and / or image blocks corresponding to the PDF document page.

[0031] After a user triggers document translation on the current PDF document page, the translation device responds to the user's instruction by parsing the current PDF document page and obtaining the text objects and their location information, as well as the image objects and their location information.

[0032] According to some embodiments, the translation device can parse and render PDF documents based on the PDFium engine.

[0033] Furthermore, the translation device traverses each text object in the PDF document page based on the position information of the text object, and scans the current text object based on the preset symbol judgment rules to determine whether the current text object is a superscript or subscript symbol.

[0034] According to some embodiments, the symbol determination rules are used to determine whether a text object is a superscript or subscript symbol. These rules include character count limits, height ratios, baseline offsets, vertical intersections, and horizontal distance limits. The character count limit can be set to 8 characters; text objects exceeding 8 characters are not considered superscripts or subscripts. The height ratio can be set between 20% and 60% of the height of a normal text object; text objects exceeding or falling below this range are not considered superscripts or subscripts. The baseline offset can be set to 1.0; when the offset between the baseline (vertical position) of a text object and the baseline of a normal text object in the same row is greater than 1.0, the text object is considered a superscript or subscript symbol. The vertical intersection ratio can be set to 30%, meaning that the vertical intersection ratio between the superscript / subscript symbol and an adjacent normal text object is no less than 30%. The horizontal distance limit can be set to 30 units, meaning that the horizontal distance between the superscript / subscript symbol and an adjacent normal text object does not exceed 30 units.

[0035] The translation device obtains the center line height of the line that matches the current text object among multiple lines on a PDF document page.

[0036] According to some embodiments, the translation device can determine the matching line among multiple lines on a PDF document page using the position information of the current text object, and determine the center line height of the normal text object in that line as the center line height of that line.

[0037] The translation device determines the relative position of the currently scanned text object with respect to the height of the center line in order to determine whether the current text object is a superscript or subscript.

[0038] According to some embodiments, if the current text object meets the symbol determination rules, the final symbol type of the current text object is determined by the height of the midline of the line it matches. If the bottom of the current text object is higher than the midline of the line, the translation device determines the current text object as a superscript. If the top of the current text object is lower than the midline of the line, the translation device determines the current text object as a subscript. If neither of the above conditions is met, the translation device determines the current text object as a normal text object.

[0039] For example, the "2" in the text object "H2O" in the body of a PDF document has 1 character count, a height of about 0.4 times that of H / O, a baseline that is about 2pt low, and a top that is below the height of the midline of the line containing H / O. Therefore, it is recognized as a subscript by the translation device.

[0040] According to some embodiments, if the preceding text object immediately adjacent to the current text object has been determined to be a superscript or subscript, and the two have the same baseline and intersect each other in the vertical direction by more than 60%, then the current text object directly inherits the same type and is recognized as a superscript or subscript by the translation device. This mechanism is specifically designed to handle scenarios with consecutive superscripts (or subscripts) such as "x²³", avoiding repeated geometric determinations.

[0041] When the current text object contains subscripts or superscripts, the translation device isolates the current text object and does not participate in the clustering process of normal text objects.

[0042] According to some embodiments, the isolated text object includes punctuation marks in addition to superscript and subscript symbols.

[0043] If the current text object is not a subscript or superscript, the translation device collects the current text object into the lines that match the current text object among multiple lines on the PDF document page, based on the position information of the current text object.

[0044] After collecting the normal text objects for each line, the translation device determines the target line in the PDF document page that matches the isolated text objects, based on the location information of the isolated text objects.

[0045] According to some embodiments, the translation device can find a matching target line for each isolated text object by measuring the vertical intersection ratio. If the target line belongs to a table, the text object and the target line must fall within the same cell of that table.

[0046] The translation device determines the insertion position of the isolated text object in the target line based on the horizontal coordinates, so as to insert the isolated text object back into the target line.

[0047] While inserting the isolated text object, the translation device updates the bounding box of the target line so that the target line covers the newly inserted isolated text object.

[0048] For example, in the original text of a PDF document page, “Area S1+S2= ...", “1” and “2” have been marked as subscripts by the translation device and do not participate in the clustering of normal text objects in the line containing “Area S +S =...". Finally, the translation device accurately inserts them back to the right of the corresponding “S” according to the horizontal coordinate.

[0049] The translation device scans each line of a PDF document page line by line to identify the feature markers of each line.

[0050] According to some embodiments, the translation device performs pattern matching on the beginning of each line during line-by-line scanning to determine whether it contains the feature markers of that line.

[0051] Taking list items as an example, the translation device performs pattern matching on the beginning of each line to determine whether it contains list symbols. The list symbols corresponding to different patterns include, but are not limited to, the following types.

[0052] Numeric types: “1.”, “2.”, “1)”, “(1)”, “[1]”, “1:”, etc.

[0053] Letter-based: “a.”, “(a)”, “[a]”, “A)”, etc.

[0054] Roman numerals: “I.”, “II.”, “(i)”, etc.

[0055] Purely numeric (common in reference lists): “1”, “2”, “3”, etc.

[0056] Bullet points: random symbols such as dots, squares, diamonds, and dashes.

[0057] Once a list symbol in a certain row is successfully matched, the translation device marks that row as the "starting row of the list item" and records information such as its symbol pattern, value, and horizontal position.

[0058] Furthermore, the translation device performs a global continuity check based on the feature tags of each line to determine the type of each line in the PDF document page.

[0059] Taking list items as an example, the translation device performs a global continuity check on candidate list items in the PDF document page, which includes: all items in the same list must have the same symbol pattern, the numbers or letters must be consecutively incremented by 1, 2, 3 or a, b, c, and the symbols of list items in the same list should be located at similar horizontal positions.

[0060] Lines that pass the global continuity check retain the "list item start line" feature tag, while lines that fail the global continuity check are reverted to plain text. Additionally, if a line is not marked with a feature tag but its preceding and following lines conform to continuity, the feature tag will be added back to that line. Conversely, if a line is marked with a feature tag but breaks the continuity between its preceding and following lines, the feature tag for that line will be removed.

[0061] The process involves parsing the current PDF document page, including segmenting the PDF document page into blocks to generate text blocks and / or image blocks.

[0062] The translation device acquires the geometric information corresponding to each line in the PDF document page, and segments each line in the PDF document page based on the type and geometric information of each line to generate text blocks.

[0063] According to some embodiments, the geometric information corresponding to each line in a PDF document page includes line spacing, font similarity, left and right boundary relationships, and center alignment, etc. The translation device can combine the type of each line (e.g., list item marker, directory item marker, etc.) and geometric information to segment the document.

[0064] For example, line spacing exceeding a preset threshold will force segmentation. Significant differences in font, font size, or other font similarity will also tend to lead to segmentation. If the entire page of text in a PDF document exhibits center-aligned characteristics (left boundary variance is much greater than center line variance), this will be used as an additional signal in segmentation determination.

[0065] For example, if the current line is the "list item start line", then the current line is the starting line of a new paragraph; if the line above the current line is the "list item start line" and the current line is horizontally indented after it, then the current line is considered a continuation line of that list item and is included in the same paragraph. If the line above the current line is a table of contents item, then the paragraph is broken and a new entry is started from the current line.

[0066] In the embodiments of this application, by standardizing line height and introducing horizontal alignment baselines, combined with text matching (e.g., judging list items), the accuracy of paragraph and list segmentation can be optimized.

[0067] According to some embodiments, segmenting each line in a PDF document page to generate text blocks also includes table segmentation. First, the translation device detects the horizontal and vertical lines that form the table frame on the PDF document page and combines them to obtain cell regions. Then, the translation device associates text objects in the PDF document page with the obtained cells. During table segmentation, the translation device determines whether two text objects (or two lines of text) belong to different table cells to ensure that the content in the table is correctly segmented.

[0068] While acquiring the text blocks corresponding to the PDF document page, the translation device generates image blocks based on the image objects and their location information in the PDF document page.

[0069] According to some embodiments, a local model link can be set up at the front end and connected to the document layout parsing model. The local model can perform more intelligent PDF segmentation processing, which can further improve the segmentation accuracy and better solve the problem of poor translation effect caused by inaccurate segmentation.

[0070] In step S200, the text block and / or image block are uploaded to the server respectively to obtain the text translation result and / or image translation result.

[0071] The translation device acquires the original text in the text block and the block coordinate information of the text block in the PDF document page, as well as the image information in the image block and the block coordinate information of the image block in the PDF document page.

[0072] The translation device uploads the original text of the text block to the server and retrieves the text translation result corresponding to the original text from the server.

[0073] According to some embodiments, the translation device can upload the original text of a text block to the server by calling the server-side text interface. Then, the server sends a text translation request to a preset translation model. After receiving the text translation request, the translation model translates the original text of the text block and sends the translated text as the text translation result to the front-end translation device through the server.

[0074] The translation device uploads the image information of the image blocks to the server and retrieves the image translation results corresponding to the image information from the server.

[0075] According to some embodiments, the translation device can upload images from image blocks to the server by calling the server-side image interface. The server then extracts the text content and its position information within the image using a preset OCR model, submits the text content recognized by the OCR model to the translation model for translation, and uses the resulting translation as the image translation result. The server returns the image translation result, along with the text content recognized by the OCR model and its position information within the image, to the front-end translation device. The translated text corresponding to the text content recognized by the OCR model has been segmented into image translation text blocks.

[0076] In step S300, based on the text translation results and / or image translation results, the original and translated texts are displayed side-by-side on the PDF document page.

[0077] The translation device merges the text translation results and / or image translation results to obtain the final translation.

[0078] Based on the position information of text blocks and / or image blocks in the PDF document page, the translation device typesets the original text and the final translation of the PDF document page to display the original text and the final translation of the PDF document page side by side.

[0079] According to some embodiments, the translation device performs comparative layout based on the position information of text blocks and / or image blocks in the PDF document page, and uses the remaining layout space to fill the corresponding area of ​​the PDF document page with the final translation based on the text content recognized by the OCR model and its position information in the image, so as to realize the comparative display of the original text and the final translation on the PDF document page.

[0080] According to some embodiments, the translation device retains the complete translation content while ensuring the original text layout accuracy, and retains the original text paragraph format (such as centering, rotation) and text style (such as color, bold, italics, underline, strikethrough, etc.), achieving a WYSIWYG high-fidelity translation effect.

[0081] Figure 2 A schematic diagram of a PDF document translation apparatus according to an example embodiment of this application is shown.

[0082] like Figure 2 As shown, the translation device 100 is configured at the front end, including a semantic segmentation module 110, an information transmission module 120, and a typesetting display module 130.

[0083] The semantic chunking module 110 responds to the user's instructions to parse the current PDF document page and obtain the text objects and their location information, as well as the image objects and their location information.

[0084] The semantic segmentation module 110 traverses each text object in the PDF document page based on the position information of the text object, and scans the current text object based on the preset symbol judgment rules to determine whether the current text object is a superscript or subscript symbol.

[0085] The semantic chunking module 110 obtains the center line height of the line that matches the current text object among multiple lines of the PDF document page.

[0086] The semantic segmentation module 110 determines the relative position of the scanned current text object with respect to the height of the center line, in order to determine whether the current text object is a superscript or subscript symbol.

[0087] When the current text object contains subscripts and superscripts, the semantic segmentation module 110 isolates the current text object and does not participate in the clustering process of normal text objects.

[0088] If the current text object is not a subscript or superscript symbol, the semantic segmentation module 110 collects the current text object into the lines that match the current text object in multiple lines of the PDF document page, based on the position information of the current text object.

[0089] After the normal text objects in each line are collected, the semantic segmentation module 110 determines the target line in the multiple lines of the PDF document page that matches the isolated text objects, based on the location information of the isolated text objects.

[0090] The semantic block module 110 determines the insertion position of the isolated text object in the target line based on the horizontal coordinates, so as to insert the isolated text object back into the target line.

[0091] While inserting the isolated text objects, the semantic chunking module 110 updates the bounding box of the target line so that the target line covers the newly inserted isolated text objects.

[0092] The semantic segmentation module 110 scans each of the multiple lines that have been formed in the PDF document page line by line to identify the feature markers of each line.

[0093] The semantic segmentation module 110 performs a global continuity check based on the feature tags of each line to determine the type of each line in the PDF document page.

[0094] The semantic segmentation module 110 obtains the geometric information corresponding to each line in the PDF document page, and performs segmentation judgment on each line in the PDF document page based on the type and geometric information of each line to generate text blocks.

[0095] While acquiring the text blocks corresponding to the PDF document page, the semantic segmentation module 110 generates image blocks based on the image objects and their location information in the PDF document page.

[0096] The information transmission module 120 acquires the original text in the text block and the block coordinate information of the text block in the PDF document page, as well as the image information in the image block and the block coordinate information of the image block in the PDF document page.

[0097] The information transmission module 120 uploads the original text of the text block to the server and obtains the text translation result corresponding to the original text from the server.

[0098] The information transmission module 120 uploads the image information of the image block to the server and obtains the image translation result corresponding to the image information from the server.

[0099] The layout and display module 130 merges the text translation results and / or image translation results to obtain the final translation.

[0100] Based on the position information of text blocks and / or image blocks in the PDF document page, the layout display module 130 typesets the original text and the final translation of the PDF document page to display the original text and the final translation of the PDF document page in comparison.

[0101] Figure 3 A schematic diagram of an electronic device according to an example embodiment of this application is shown.

[0102] like Figure 3 As shown, the electronic device 600 is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0103] like Figure 3 As shown, the electronic device 600 is manifested in the form of a general-purpose computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610), a display unit 640, etc. The storage unit stores program code, which can be executed by the processing unit 610, causing the processing unit 610 to perform the methods described in this specification according to the various exemplary embodiments of this application. For example, the processing unit 610 can perform, for example... Figure 1 The method shown.

[0104] Storage unit 620 may include readable media in the form of volatile storage units, such as random access memory (RAM) 6201 and / or cache memory 6202, and may further include read-only memory (ROM) 6203.

[0105] Storage unit 620 may also include a program / utility 6204 having a set (at least one) program module 6205, such program module 6205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0106] Bus 630 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0107] Electronic device 600 can also communicate with one or more external devices 700 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 650. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 660. Network adapter 660 can communicate with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0108] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. The technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this application.

[0109] Software products may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections with one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0110] Computer-readable storage media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable storage medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0111] Program code for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0112] The aforementioned computer-readable medium carries one or more programs, which, when executed by a device, cause the computer-readable medium to perform the aforementioned functions.

[0113] Those skilled in the art will understand that the above modules can be distributed in the device as described in the embodiments, or they can be modified accordingly and placed in one or more devices that are unique to this embodiment. The modules in the above embodiments can be combined into one module, or they can be further divided into multiple sub-modules.

[0114] The embodiments of this application have been described in detail above. These descriptions are solely for the purpose of helping to understand the method and core ideas of this application. Furthermore, any changes or modifications made by those skilled in the art based on the ideas of this application, its specific implementation methods, and its application scope, are all within the scope of protection of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for translating PDF documents, characterized in that, include: In response to the user's translation command, the current PDF document page is parsed to obtain the text blocks and / or image blocks corresponding to the PDF document page; Upload the text block and / or the image block to the server respectively to obtain the text translation result and / or the image translation result; Based on the text translation results and / or the image translation results, the original and translated texts are displayed side-by-side on the PDF document page.

2. The method according to claim 1, characterized in that, In response to a user's translation command, the current PDF document page is parsed to obtain the corresponding text blocks and / or image blocks, including: Obtain the text objects and their position information in the PDF document page; The text objects are clustered based on their location information to form multiple rows on the PDF document page; Determine the type of the multiple rows; Obtain the geometric information corresponding to the multiple lines, and segment the multiple lines based on the type and geometric information to generate the text block.

3. The method according to claim 1, characterized in that, In response to the user's translation command, the current PDF document page is parsed to obtain the corresponding text blocks and / or image blocks, including: Obtain the image objects and their location information from the PDF document page; The image block is generated based on the image object and its location information.

4. The method according to claim 2, characterized in that, The text objects are clustered based on their location information to form multiple rows on the PDF document page, including: Determine whether the current text object contains subscripts or superscripts; If the current text object is the subscript or superscript symbol, the current text object is isolated. If the current text object is not the subscript or superscript symbol, the current text object is collected into the line that matches the current text object in the plurality of lines according to the position information of the current text object; After the collection of the multiple lines is completed, the isolated text objects are clustered according to their location information, so as to insert the isolated text objects back into the multiple lines that match the isolated text objects.

5. The method according to claim 4, characterized in that, Determining whether the current text object is a subscript or superscript includes: The current text object is scanned based on preset symbol judgment rules; Obtain the centerline height of the line that matches the current text object among the plurality of lines; Determine the relative position of the scanned current text object with respect to the center line height to determine whether the current text object is the superscript or subscript symbol.

6. The method according to claim 4, characterized in that, After the collection of the multiple lines is completed, the isolated text objects are clustered based on their position information to insert them back into the lines that match them. This includes: Based on the location information of the isolated text object, determine the target line among the plurality of lines that matches the isolated text object; Determine the insertion position of the isolated text object in the target line, so as to insert the isolated text object back into the target line; Update the bounding box of the target line so that the target line covers the isolated text object.

7. The method according to claim 2, characterized in that, Determining the type of the plurality of rows includes: The plurality of rows are scanned line by line to identify the feature markers of each row. A global continuity check is performed based on the feature markers to determine the type of the multiple rows.

8. The method according to claim 1, characterized in that, The text block and / or the image block are uploaded to the server respectively to obtain text translation results and / or image translation results, including: Obtain the original text within the text block and the position information of the text block on the PDF document page; Obtain the image information in the image block and the position information of the image block in the PDF document page; The original text of the text block is uploaded to the server, and the text translation result corresponding to the original text is obtained from the server. The image information of the image block is uploaded to the server, and the image translation result corresponding to the image information is obtained from the server.

9. The method according to claim 8, characterized in that, Based on the text translation results and / or the image translation results, a comparison between the original text and the translation is displayed on the PDF document page, including: The text translation results and / or the image translation results are merged to obtain the final translation; Based on the position information of the text blocks and / or the image blocks in the PDF document page, the original text and the final translation of the PDF document page are formatted to display the original text and the final translation of the PDF document page in comparison.

10. A PDF document translation device, characterized in that, include: The semantic chunking module is used to parse the current PDF document page in response to the user's translation command to obtain the text blocks and / or image blocks corresponding to the PDF document page; The information transmission module is used to upload the text block and / or the image block to the server respectively to obtain the text translation result and / or image translation result; The layout and display module is used to display the original text and translation side-by-side on the PDF document page based on the text translation results and / or the image translation results.

11. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-9.

12. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the method as described in any one of claims 1-9.