PDF optimization translation method and system based on intelligent text detection
By employing intelligent text detection and transparent rendering technologies, the problems of content misalignment and occlusion in PDF translation have been solved, achieving precise alignment between the translated text and the original text, as well as complete display of image information, thereby improving the accuracy and readability of the translation.
Patent Information
- Application Number
- CN202510965077.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-14
- Publication Date
- 2025-11-04
AI Technical Summary
Existing PDF translation technologies suffer from problems such as content misalignment, opaque background of translated text, and text truncation when processing documents with fixed layouts. These issues affect the accuracy and readability of the translation, especially in documents with complex layouts. As a result, the translated text fails to align accurately with the original text, obscures key information, and lacks intelligent content detection and repair mechanisms.
This paper adopts a PDF translation method based on intelligent text detection. By accurately detecting text regions, extracting text, and applying a window translation strategy, it performs machine translation in combination with context. It also uses transparent rendering technology to avoid occluding image content and dynamically optimizes the text layout to ensure the accuracy and readability of the translation results.
It achieves precise alignment between the translation and the original text, avoiding content misalignment and image occlusion, improving the accuracy and readability of the translation, and maintaining the logical coherence between sentences and the integrity of the document.
Smart Images

Figure CN120893451A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of document processing, in particular to a PDF optimization translation method and system based on intelligent text detection. BACKGROUND
[0002] With the acceleration of globalization, the demand for cross-language communication is increasing, especially in the fields of technology, business and law. As an important electronic document format, PDF documents are widely used in various occasions. However, the existing PDF translation technology still faces many challenges when facing fixed layout format documents, resulting in unsatisfactory translation effect, which seriously affects the accuracy and readability of translation.
[0003] Currently, the mainstream PDF translation software mainly relies on machine translation technology, but when processing PDF documents, problems such as content misplacement, opaque translation text background and text segment truncation often occur, affecting the accuracy and readability of translation. Specifically, the content misplacement problem causes the translation text to fail to align accurately with the original text, especially in complex layout documents, text position offset may cause semantic confusion or context break, thereby affecting user understanding and the professionalism of the document. The opaque translation text background problem usually occurs when the translation text covers the original text, especially when processing documents containing pictures or illustrations, the translation text may block key illustrations, annotations or explanation information, thereby destroying the integrity of the document and the information transmission effect. In addition, text segment truncation problems also occur, especially when translating long or complex sentences, the software fails to correctly handle line breaks and page breaks, resulting in sentence fragmentation, loss of context coherence, and reduced translation fluency and accuracy.
[0004] The root cause of these problems is that existing translation software fails to fully consider the complexity of fixed layout format when processing PDF documents, and lacks intelligent content detection and repair mechanisms, resulting in limited translation effect. Although machine translation systems such as Google Translate, Bing Translate perform well in general text translation, these technologies fail to effectively solve the problems of fixed layout, image obstruction and text misplacement in PDF document translation, making it difficult to meet the actual application requirements.
[0005] Therefore, a new technical solution is needed to optimize the PDF translation process based on intelligent text detection, ensure accurate alignment of translation text with the original text, do not affect the display of image information, and maintain the logical coherence between sentences, thereby improving the accuracy, fluency and professionalism of PDF translation. SUMMARY
[0006] To solve the problems of content dislocation, sentence truncation and picture occlusion in PDF translation, the application provides a PDF translation optimization method based on intelligent text detection. The method accurately detects the text area, extracts the text and applies the window translation strategy, and finally backfills and renders according to the previously detected text area to ensure the accuracy of the translation result.
[0007] To solve the above technical problems, the application adopts the following technical solutions: A PDF optimization translation method based on intelligent text detection, comprising the following steps: Step 1: Analyzing the PDF document, identifying the text area and image area in the PDF document respectively, extracting the native text block and its structured position information in the text area of the PDF document, Step 2: Optical recognition of image text blocks in the image area, merging the recognition results with the native text blocks into a unified structured data set; Step 3: Sorting the native text blocks and image text blocks by coordinates, using a window translation strategy combined with context for machine translation, and extracting the target translation; dynamically associating adjacent text blocks during translation, and defining the target text range through boundary markers; Step 4: Dynamically optimizing the text layout according to the length of the target translation, and backfilling the translation result to the original position; wherein the image text blocks are rendered with transparency to avoid occluding image content.
[0008] Further, the structured position information in step 1 includes: text block bounding box coordinates, font size, font name and page number; image area detection uses computer vision algorithm to locate the image text block area in the image.
[0009] Further, the step 2 of merging the recognition results with the native text blocks into a unified structured data set includes: converting the local coordinates of the image text blocks to the global coordinate system of the PDF page through a mapping function, and the mapping relationship satisfies:
[0010] wherein, is the bounding box coordinate of the native text block, is the boundary coordinate of the image area on the PDF page, is the text box coordinate of the optically recognized image text block.
[0011] Further, the step 3 of using a window translation strategy combined with context for machine translation includes: Step 3.1, sorting the native text blocks and image text blocks by spatial position, establishing cross-page text association, and accurately obtaining the context text blocks of the target text block and , constructing a context window for translation; Step 3.2, special markers are inserted before and after the content of the target text block <t>With< / t> , forming the following translation input structure: ; Step 3.3, based on the neural machine translation model, the translation between special markers in the translation model output is extracted as the target translation. <t>With< / t>
[0012] Further, in step 3.1, the horizontally adjacent text blocks are grouped by the coordinate clustering algorithm, and the text order is determined by the vertical coordinates.
[0013] Further, the dynamic optimization of text layout in step 4 includes: (a) estimating the translation width based on the number of characters and font size; (b) triggering line splitting or font scaling when exceeding the limit; (c) scaling using an iterative reduction strategy until the text box is fitted.
[0014] Further, the transparent rendering in step 4 includes: (e) eliminating the image text blocks in the original image area; (f) creating a transparent overlay layer with the same size as the image text block in the original image area, and drawing the translation on the transparent image overlay to form a transparent text layer; (g) combining the transparent text layer with the image text block area.
[0015] Further, the step 1 uses a PDF parsing library to extract the native text block, and the step 2 uses an OCR engine to recognize the image text block.
[0016] Further, the step 4 directly replaces the text layer for the native text block, and backfills through the transparent text layer for the image text block.
[0017] In another aspect, the present application provides a PDF optimization translation system based on intelligent text detection, characterized in that it comprises the following steps: PDF document parsing module: parsing the PDF document, identifying the text area and image area in the PDF document respectively, extracting the native text block and its structured position information in the text area of the PDF document, image area optical recognition module: used for optical recognition of the image text block in the image area, and merging the recognition result with the native text block into a unified structured data set; Target translation extraction module: used for sorting the original text block and image text block by coordinates, adopting window translation strategy combined with context for machine translation, and extracting target translation; dynamically associating adjacent text blocks during translation, and defining the target text range through boundary markers; Text layout optimization module: used for dynamically optimizing text layout according to the length of target translation, and backfilling the translation result to the original position; wherein transparent rendering is adopted for the image text block to avoid shielding the image content.
[0018] Compared with the prior art, the present application has the following beneficial effects: 1. Improve the typesetting accuracy and semantic coherence of translation: Based on the accurate extraction of the structured position information of the text block in the PDF document, the present application realizes the accurate alignment of the translation and the original text in space, avoiding the common problems of content misplacement and chaotic typesetting in traditional translation process. At the same time, by adopting the window translation strategy, the target text block is dynamically associated with its adjacent text blocks before and after it, and a translation input containing rich context information is constructed, effectively enhancing the semantic coherence and translation accuracy of long sentences and complex sentences, greatly reducing phenomena such as sentence truncation and semantic fragmentation that affect the reading experience.
[0019] 2. Avoid shielding the image content by translation: For the text content in the image area, the present application adopts transparent rendering strategy for backfilling, specifically by creating a transparent overlay layer and drawing the translation on this layer, so that the translation can be clearly displayed without shielding or interfering with the image content, ensuring the complete transmission of visual information and significantly improving the readability and integrity of the document with images and text.
[0020] 3. Dynamic typesetting optimization: The present application introduces a dynamic layout adjustment mechanism, dynamically estimates the required text box width and height based on the number of characters and font size of the translation, and realizes scientific prediction of the space demand of the translation. When the length of the translation exceeds the range of the original text box, the system automatically triggers line splitting processing or font scaling operation, and adopts an iterative reduction strategy to ensure that the translation maintains good readability while perfectly adapting to the original typesetting structure, avoiding problems such as text overflow, shielding or chaotic typesetting, and ensuring the beauty and standardization of the overall document. BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the present application or prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.
[0022] Figure 1 is a flowchart of an embodiment of the present application.
[0023] Figure 2 is a specific process flow of an embodiment of the present application.
[0024] Figure 3 is a process of mapping image text local coordinates to global coordinates for use in an embodiment of the present application.
[0025] Figure 4 is a transparent background covering method for use in an embodiment of the present application. DETAILED DESCRIPTION
[0026] To make the above objectives, features and advantages of the present application more apparent, specific embodiments of the present application are described in detail below with reference to the accompanying drawings. In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be practiced in a variety of ways other than those described herein without departing from the spirit of the present application, and skilled persons in the art can make similar improvements without departing from the scope of the present application, so the present application is not limited to the specific embodiments disclosed below. Embodiment 1 The embodiments of the present application employ the following open source software and technical tools: the PyMuPDF software package for parsing and extracting PDF text ( https: / / github.com / pymupdf / PyMuPDF ), the OpenCV library for computer vision technology processing images ( https: / / opencv.org / ), and the application of optical character recognition (OCR) technology using the Tesseract OCR engine ( https: / / github.com / tesseract-ocr / tesseract ).
[0027] During translation, the present application uses neural machine translation (NMT) technology, and builds a custom neural translation model based on OpenNMT ( http: / / opennmt.net / ). The specific corpus used in fine-tuning training includes multilingual parallel datasets such as WMT ( http: / / www.statmt.org / wmt19 / ) and OpenSubtitles ( https: / / www.opensubtitles.org / ), which contain a large number of translation examples in Chinese and English and other languages.
[0028] As shown in the specific embodiments of Figure 1 and Figure 2 , the present application includes the following steps: Step 1: parsing a PDF document, identifying text regions and image regions in the PDF document respectively, and extracting text blocks and their structured position information in the text regions of the PDF document, The core goal of Step 1 is to accurately identify the text and image regions in the PDF file, ensuring that the original layout structure of the document is preserved during subsequent translation processing, avoiding misalignment. To achieve this goal, first, PyMuPDF is used to parse the entire PDF document, and the native text blocks in each page and their corresponding position information and font attributes are extracted. Specifically, each text block is represented by four key coordinates , accompanied by the font size, font name, and page number of the text block. In this way, the position information of the text box not only includes coordinates, but also font size, name, and page number, ensuring accurate positioning and consistent font style when processing cross-page text.
[0029] Step 2: Optical recognition of text blocks in image regions, merging the recognition results with text blocks in text regions into a unified structured data set; For pictures embedded in PDF, the invention uses computer vision algorithms for detection, ensuring that all text in the document (whether native PDF text or text embedded in images) can be accurately identified. Specifically, the detection of image regions uses OpenCV's contour detection method, based on color changes and boundary features of the image to locate potential text blocks. Since the text box coordinates extracted by OpenCV are in the local coordinate system of the image (with the top-left corner of the image as the origin, y-axis pointing down), and the image position coordinates provided by PyMuPDF are in the global coordinate system of the PDF page (y-axis pointing up), coordinate mapping conversion is required.
[0030] The specific embodiment can be abstracted as shown in Figure 3 , let the boundary coordinates of the image on the PDF page be , and the picture text box coordinates detected by OpenCV be The mapping formula is as follows:
[0031] Through the above method, all text information in the PDF can be uniformly extracted and represented in a structured format of "coordinates + font style + page number", ensuring accurate restoration of text position and font style during subsequent translation and content backfilling, and maximizing the preservation of the original document's layout integrity.
[0032] First, the invention uses the text region detection results obtained in Step 1 to obtain the global bounding box coordinates of all text blocks, which are represented by four coordinates The text region is defined, including its corresponding page number information. For each text region, a partial image of that region is extracted from the corresponding PDF page image based on its bounding box coordinates. Here, the cropping operation is implemented using the image cropping function in the OpenCV library to ensure accurate acquisition of the image content corresponding to the text region. Subsequently, the OCR recognition engine Tesseract is used to perform text recognition on the cropped partial image. Tesseract converts the character information in the image into a text string, completing the extraction of the text region's content.
[0033] Ultimately, this invention saves each identified text segment in a one-to-one correspondence with its corresponding global bounding box coordinates and page number information, forming a structured data format of "text content + coordinates + font style + page number". This structure ensures the precise correspondence between the text information and its location on the PDF page, providing accurate positioning data for subsequent translation and backfilling processes, and ensuring that the translation results strictly reproduce the original layout of the document.
[0034] Step 3: Sort the text blocks in the text and image regions by coordinates, use a window translation strategy combined with context for machine translation, and extract the target translation; dynamically associate adjacent text blocks during translation, and define the target text range by boundary markers; The core task of this step is to perform high-quality, context-aware machine translation based on the extracted text content, bounding box coordinates, and page number information after text recognition. This invention uses a neural machine translation (NMT) model based on neural networks as the translation engine, and fine-tunes it using multilingual corpora and domain-specific terminology datasets to adapt to the complex language expressions and terminology translation needs that may be involved in various PDF documents.
[0035] To ensure semantic coherence and syntactic integrity in the translation results, this invention designs a context window translation strategy to consider the contextual relationships between preceding and following text when translating a single text block. The basic idea of this strategy is to translate a target text block... At that time, the previous text block and the next text block As input into the translation model along with the context, the model's ability to perceive contextual semantics is enhanced, avoiding semantic breaks and information loss caused by block-by-block translation.
[0036] Before the translation task begins, this invention arranges the text boxes according to the page order. For each page's text boxes, it first... x and y The coordinates are approximated. This is because of text boxes in the same column. x The coordinates may have slight differences. This invention sets a threshold for...x The coordinates are approximated to group text boxes that are close to each other into the same column. Next, based on the approximated coordinates... The coordinates are used to sort the text boxes to determine their horizontal order. For text boxes within the same column, their... x Because the coordinates are close together, this invention uses the K-Means algorithm to group them together, ensuring that the text boxes in each column are related to each other. Then, based on... y The coordinates are further sorted to ensure the text boxes are in the correct vertical order. Typically, y The text box with smaller coordinates is located at the top of the page, while y Text boxes with larger coordinates are located at the bottom of the page.
[0037] Furthermore, for text spanning multiple pages, processing is based on the page number information of the text boxes. For example, if a text box is the first text box on the current page, its preceding text box will be the last text box on the previous page; if a text box is the last text box on the current page, its following text box will be the first text box on the next page. This processing method ensures the contextual coherence of cross-page text during translation and avoids translation interruptions caused by pagination.
[0038] Through the above methods, the present invention can accurately obtain target text blocks. Text blocks before and after and , construct a context window for translation.
[0039] To further ensure the accurate extraction of target text blocks from the translation results during window translation. Regarding the translated content, this invention employs an explicit control tag embedding strategy when constructing the translation input sequence. When forming the window translation input, this invention will embed the target text block... Insert special markers before and after the content. <t>With< / t> This results in the following translation input structure: In this way, the markers act as semantic boundaries, enabling the model to identify the precise range of the translation target.
[0040] This invention uses a neural machine translation (NMT) model as the core translation engine, targeting control tokens. <t>And< / t> To meet the special processing requirements of the standard NMT model pre-trained vocabulary, additional control tokens are added. <t>And< / t> These tokens are included in the vocabulary as independent lexical units and designated as reserved lexical units. Setting them as reserved lexical units ensures that these tokens are treated as structural symbols during model encoding and decoding, neither participating in the semantic transformation of language content nor affecting the translation quality of the context, while guaranteeing complete preservation in the translation output.<t>And< / t> The mark, thereby providing strong guarantee for subsequent accurate extraction of target translation.
[0041] After the translation is completed, the translation result returned by the model is structured and analyzed by the present application. The translation is usually a continuous text containing the translation of three contents and a mark. The present application uses string search to locate the first occurrence of <t>With its counterpart< / t> , and extracts the content between them as the translation result of the current target text block .
[0042] After the translation content extraction is completed, the present application corresponds the translation to the boundary box coordinate information and the page number saved in step 2 one by one, and reorganizes it into a structured format of “translated text + coordinate + font style + page number”, providing accurate input for the next text backfill module. This design ensures that even if context auxiliary information is used in the window translation process, the translation content output each time is still limited to the part of the current target text block, strictly maintaining structural consistency and positioning accuracy.
[0043] Step 4: dynamically optimize the text layout according to the length of the target translation, and backfill the translation result to the original position; wherein the text block in the image area is rendered in a transparent manner to avoid blocking the image content.
[0044] This step aims to ensure that the translated text can be accurately backfilled to the original position, while solving the problem of opaque translation background possibly blocking the picture content, to maintain the integrity of the image and the readability of the text.
[0045] The present application proposes a text layout optimization method, aiming to solve the typesetting disorder problem caused by the length change of the translated text, and ensure that the translation content is reasonably filled in the original text area while maintaining consistent typesetting.
[0046] In the specific implementation process, first, the width and height of the text box are calculated according to the original coordinates, wherein the width is obtained by subtracting the left upper corner horizontal coordinate from the right lower corner horizontal coordinate, and the height is obtained by subtracting the upper boundary vertical coordinate from the lower boundary vertical coordinate. Subsequently, the horizontal display width of the translated text under the current font is estimated according to the total number of characters of the translated text and the original font size. In this step, a linear approximation method is used to estimate the character width, that is, an empirical character width coefficient (about 0.5 times the font size per character) is selected, multiplied by the total number of characters and multiplied by the font size, to obtain the estimated horizontal width of the translated text under the original font style.
[0047] If the estimated width does not exceed the original textbox width, it is considered that the translation can be fully accommodated without adjustment. In this case, the translated text is rendered in the original font style directly in the original area, and the original coordinates are kept unchanged. If the estimated width exceeds the original textbox, line breaking processing is needed for the translated text. The line breaking method uses the character number equal division method: according to the original textbox width and font size, the maximum number of characters that can be accommodated per line is estimated, and according to this number, the corresponding number of characters is extracted from the beginning of the translated text content as the text content of each line. Then, according to the vertical height of the original textbox and the number of lines, the actual line spacing of each line is calculated. The calculation of line spacing is based on the height of the textbox, which is evenly divided into the corresponding number of lines, so that each line is evenly distributed in the vertical direction. The vertical start and end coordinates of each line are thus derived, and the horizontal coordinates remain consistent with the original textbox.
[0048] If the multiple lines of text after line breaking cannot be fully accommodated in the original textbox, i.e. the average line spacing is less than the set minimum readable threshold (set to 0.5 times the font size in this invention), the font scaling strategy is started. This strategy keeps the original font name unchanged, multiplies the font size by a fixed scaling step (set to 5% in this invention), and re-executes the character width estimation and line breaking process. This process continues until the translated text can be fully accommodated in the original textbox under the scaled font. Please refer to Figure 4 The present invention proposes a transparent background covering method to avoid the translation text blocking the picture content and ensure the consistency of the overall picture layout, the specific process is as follows: The present invention first removes the original text using the image inpainting method of OpenCV. This process first creates a mask layer with the same size as the original image, filling white in the text area recognized by OCR, and keeping black in other areas. Then, use the method provided by cv2 to repair these areas, which can smoothly fill the missing content and make it naturally blend with the surrounding background, thus generating a clean image that has removed the original text.
[0049] After removing the original text, the present invention creates a transparent layer with the same size as the original image based on the textbox coordinate information recognized by OCR, and uses PIL (Pillow) to generate a transparent background. On this transparent layer, use ImageDraw to draw text and set appropriate font and size through ImageFont to match the original text layout style as much as possible. During the drawing process, ensure that only the text color is filled, without adding any background filling, to maintain the transparency effect, so that the translated text can be clearly visible and not block the underlying image content.
[0050] Then, the present application synthesizes the transparent text layer with the image after removing the original text. Using the overlay method provided by PIL, the translated text is accurately overlaid on the original text location without affecting other contents of the original image. Due to the use of transparent background, all details in the image are preserved, ensuring the readability of the translated text and the integrity of the page.
[0051] Finally, the processed image is saved in PNG format to preserve the transparent background effect, and the modified image is embedded into the PDF page using PyMuPDF, ensuring that the entire document remains consistent with the original version in terms of visual and layout, thus realizing a complete transparent background translation text overlay solution.
[0052] This method can accurately and seamlessly backfill the translated text to the corresponding position of the original image, while ensuring that the content of the original image is not obscured, avoiding visual confusion or information loss caused by text overlay. Through transparent background processing, the translated text can naturally blend into the original image, making the final presented page not only meet the layout requirements, but also have high readability and aesthetics.
[0053] Embodiment 2 The present embodiment provides a PDF optimization translation system based on intelligent text detection, comprising the following steps: PDF document parsing module: parsing the PDF document, respectively identifying the text area and image area in the PDF document, extracting the native text block and its structured position information in the text area of the PDF document, Image area optical recognition module: for optical recognition of image text blocks in the image area, merging the recognition results with the native text block into a unified structured data set; Target translation extraction module: for sorting the native text block and image text block by coordinates, using window translation strategy combined with context for machine translation, and extracting the target translation; dynamically associating adjacent text blocks during translation, and defining the target text range through boundary markers; Text layout optimization module: for dynamically optimizing the text layout according to the length of the target translation, and backfilling the translation result to the original position; wherein the image text block is rendered with transparency to avoid obscuring the image content.
[0054] The above is only the preferred specific implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical range disclosed in the present application, which should be covered within the protection scope of the present application.
[0055] It should be understood that parts not elaborated in the specification are all prior art.
[0056] It should be understood that the above description is merely a detailed explanation of the preferred embodiments and is not intended to limit the patent protection scope of the present application. Any modification or alternation made by those skilled in the art without departing from the scope of the present application shall fall within the patent protection scope of the present application. The patent protection scope of the present application shall be subject to the appended claims.
Claims
1. A PDF optimization translation method based on intelligent text detection, characterized in that, Includes the following steps: Step 1: Parse the PDF document, identify the text regions and image regions in the PDF document respectively, and extract the original text blocks and their structured location information of the text regions in the PDF document; Step 2: Perform optical recognition on the image text blocks in the image region, and merge the recognition results with the original text blocks into a unified structured dataset; Step 3: Sort the original text blocks and image text blocks by coordinates, use a window translation strategy combined with context to perform machine translation, and extract the target translation; during translation, dynamically associate adjacent text blocks and define the target text range by boundary markers; Step 4: Dynamically optimize the text layout based on the target translation length and fill the original position with the translation results; transparent rendering is used for image text blocks to avoid obscuring the image content.
2. The PDF optimization translation method based on intelligent text detection according to claim 1, characterized in that, The structured location information in step 1 includes: text block bounding box coordinates, font size, font name, and page number; image region detection uses computer vision algorithms to locate image text block regions in the image.
3. The PDF optimization translation method based on intelligent text detection according to claim 1, characterized in that, Step 2, which merges the recognition results with the original text blocks into a unified structured dataset, includes: converting the local coordinates of the image text blocks into the global coordinate system of the PDF page using a mapping function, with the mapping relationship satisfying: in, These are the coordinates of the native text block bounding box. The boundary coordinates of the image region on the PDF page. The coordinates of the text box for the text block in the image for optical recognition.
4. The PDF optimization translation method based on intelligent text detection according to claim 1, characterized in that, Step 3, which employs a window translation strategy combined with contextual information for machine translation, includes: Step 3.1: Sort the original text blocks and image text blocks according to their spatial location, establish cross-page text associations, and accurately obtain the target text blocks. Text blocks before and after and , construct a context window for translation; Step 3.2, in the target text block Insert special markers before and after the content. <t> and< / t> This results in the following translation input structure: ; Step 3.3: Extract special markers from the translation model output based on the neural machine translation model. <t> and< / t> The translation between the markers is used as the target translation.
5. The PDF optimization translation method based on intelligent text detection according to claim 4, characterized in that, In step 3.1, horizontally adjacent text blocks are grouped using a coordinate clustering algorithm, and the text order is determined by vertical coordinates.
6. The PDF optimization translation method based on intelligent text detection according to claim 1, characterized in that, Step 4, which involves dynamically optimizing the text layout, includes: (a) Estimating the width of the translation based on the number of characters and font size; (b) Trigger line break processing or font scaling when limits are exceeded; (c) Scaling employs an iterative shrinking strategy until it fits the text box.
7. The PDF optimization translation method based on intelligent text detection according to claim 1, characterized in that, The transparent rendering in step 4 includes: (e) Remove image text blocks from the original image region; (f) Create a transparent overlay layer with the same size as the image text block of the original image region, and draw the translation on the transparent overlay to form a transparent text layer; (g) Composite the transparent text layer with the image text block region.
8. The PDF optimization translation method based on intelligent text detection according to claim 1, characterized in that, Step 1 uses a PDF parsing library to extract raw text blocks, and step 2 uses an OCR engine to recognize image text blocks.
9. The PDF optimization translation method based on intelligent text detection according to claim 7, characterized in that, Step 4 directly replaces the text layer for the original text block and backfills the image text block with a transparent text layer.
10. A PDF optimization translation system based on intelligent text detection, characterized in that, Includes the following steps: PDF document parsing module: Parses PDF documents, identifies text and image regions within the PDF document, and extracts the original text blocks and their structured location information from the text regions. Image region optical recognition module: It is used to perform optical recognition on image text blocks in image regions and merge the recognition results with the original text blocks into a unified structured dataset; The target translation extraction module is used to sort the original text blocks and image text blocks by coordinates, perform machine translation using a window translation strategy combined with context, and extract the target translation; during translation, it dynamically associates adjacent text blocks and defines the target text range by boundary markers; Text layout optimization module: It is used to dynamically optimize the text layout according to the length of the target translation and fill the translation result back into the original position; the text blocks in the image are rendered transparently to avoid occluding the image content; The PDF optimization translation system based on intelligent text detection is used to perform the steps in the PDF optimization translation method based on intelligent text detection as described in any one of claims 1-9.
Citation Information
Cited By
Multi-language menu translation method based on AI large model
CN121562640A
An AI large model-based multilingual menu translation method
CN121562640B