A file processing method, apparatus, device, medium, and product
By automatically evaluating and replacing pages in different PDF formats generated from configuration diagram documents, the problem of degraded exported PDF files is solved, achieving efficient and accurate file repair, suitable for safety-grade scenarios such as nuclear power plants.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA TECHENERGY
- Filing Date
- 2026-06-01
- Publication Date
- 2026-07-24
AI Technical Summary
Existing technologies often result in a decline in file quality when exporting algorithm configuration diagrams as PDF files due to layout mismatches. In particular, portrait and landscape PDF files may exhibit large blank spaces or logical breaks when presenting different logics, affecting file readability and security. Furthermore, manual repair is time-consuming, labor-intensive, and prone to errors.
By obtaining PDF files of different layouts generated from the same document, the quality information is used to judge the quality of page content, and the pages are automatically replaced to optimize the layout, ensuring that the quality of the replaced file is higher than that of the original file. A machine learning model is used to evaluate the page quality and replace the page according to the white space ratio and strategy information.
It improves the quality of PDF files, avoids the inefficiency and errors of manual repair, meets the needs of safety-level scenarios such as nuclear power plants, and ensures the accuracy and traceability of documents.
Smart Images

Figure CN122452500A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of industrial control technology, and in particular to a document processing method, apparatus, equipment, medium, and product. Background Technology
[0002] For projects in certain scenarios (such as nuclear power plants, thermal power plants, chemical plants, and rail transit), the project involves processes such as design, commissioning, operation and maintenance, and the Distributed Control System (DCS) of nuclear power plants. Furthermore, configuration software is a crucial tool for implementing control logic design, commissioning, and operation and maintenance. The safety-level and non-safety-level control logic of the unit is presented in the form of algorithm configuration diagrams, which are ultimately exported in Portable Document Format (PDF) to facilitate compliant archiving, multi-party review, and offline printed delivery. Summary of the Invention
[0003] This application provides a document processing method, apparatus, device, medium, and product to automatically repair PDF files and improve their quality.
[0004] To achieve the above objectives, the technical solutions provided in this application are as follows: This application provides a file processing method, the method comprising: obtaining a first file and a second file, wherein the first file and the second file are generated based on the same document, the layout of the first file is different from the layout of the second file, and the content of a first page in the first file is the same as the content of a second page in the second file; obtaining quality information of the first page and quality information of the second page, wherein the quality information indicates the quality of the page content; and, in response to the quality information satisfying a preset condition, replacing the first page in the first file with the second page, wherein the preset condition indicates that the page content quality of the second page is higher than the page content quality of the first page.
[0005] In one scenario, the target page is either the first page or the second page; the process of determining the quality information of the target page includes: converting the target page into a first image; performing binarization processing on the first image to obtain a second image; determining boundary information from the second image, the boundary information indicating the area occupied by the content presented in the target page; determining the blank ratio of the target page based on the boundary information; and determining the quality information of the target page based on the blank ratio.
[0006] In one scenario, the blank space ratio is also determined based on strategy information, which is determined based on the layout corresponding to the target page, and the strategy information indicates the calculation process of the blank space ratio.
[0007] In one scenario, the quality information includes the blank space ratio; the preset conditions include: the blank space ratio of the first page is greater than a first threshold, the blank space ratio of the second page is not greater than the first threshold, and the difference between the blank space ratio of the first page and the blank space ratio of the second page exceeds a second threshold.
[0008] In one scenario, after replacing the first page in the first file with the second page, the method further includes: detecting at least a portion of the pages in the first file to obtain detection results; generating abnormal information based on the third page in response to the detection results indicating an anomaly in the third page of the first file; displaying the abnormal information; and updating the first file in response to at least one operation.
[0009] In one scenario, obtaining the quality information of the first page and the quality information of the second page includes: determining the quality information of the first page and the quality information of the second page based on first configuration information, wherein the first configuration information indicates the calculation process of the quality information; updating the first file includes: updating the first configuration information based on the at least one operation, and continuing to execute the step of determining the quality information of the first page and the quality information of the second page based on the first configuration information.
[0010] This application provides a document processing apparatus, comprising: a first unit for obtaining a first document and a second document, wherein the first document and the second document are generated from the same document, the layout of the first document is different from the layout of the second document, and the content of a first page in the first document is the same as the content of a second page in the second document; a second unit for obtaining quality information of the first page and quality information of the second page, wherein the quality information indicates the quality of the page content; and a third unit for replacing the first page in the first document with the second page in response to the quality information satisfying a preset condition, wherein the preset condition indicates that the page content quality of the second page is higher than the page content quality of the first page.
[0011] This application provides an electronic device, which includes a processor and a memory; the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device performs the file processing method provided in this application.
[0012] This application provides a computer-readable medium storing instructions or computer programs that, when executed on a device, cause the device to perform the file processing method provided in this application.
[0013] This application provides a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the file processing method provided in this application.
[0014] Based on the above, the technical solution provided by this application includes: obtaining a first file (such as a landscape PDF file) and a second file (such as a portrait PDF file), wherein the first file and the second file are generated based on the same document (such as an algorithm configuration diagram page document for a project), the layout of the first file is different from the layout of the second file, and the content of the first page in the first file is the same as the content of the second page in the second file; obtaining quality information of the first page and quality information of the second page, wherein the quality information indicates the quality of the page content; in response to the quality information satisfying a preset condition (such as the preset condition indicating that the page content quality of the second page is higher than the page content quality of the first page), replacing the first page in the first file with the second page, so as to ensure that the quality of the first file after replacement is higher than the quality of the first file before replacement, thereby improving the quality of the PDF file. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 A flowchart of a document processing method provided in this application; Figure 2 A schematic diagram illustrating a mapping relationship between different files provided in this application; Figure 3 A schematic diagram illustrating a page replacement process provided in this application; Figure 4 A schematic diagram illustrating another page replacement process provided in this application; Figure 5 A schematic diagram illustrating the calculation process for the blank percentage provided in this application; Figure 6A schematic diagram of a file processing system applicable to a file processing method provided in this application; Figure 7 A schematic diagram of an interactive interface provided for this application; Figure 8 A schematic diagram illustrating an automatic page replacement process provided in this application; Figure 9 A schematic diagram of a two-level verification process provided in this application; Figure 10 A schematic diagram of the structure of a document processing device provided in this application; Figure 11 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation
[0017] Research revealed that for the aforementioned project, the large number of control stations and the numerous pages of algorithm configuration files for each station resulted in a substantial amount of data in the algorithm configuration diagram files (also known as source files), leading to significant document processing challenges. These algorithm configuration diagram files are editable source project files, belonging to a proprietary industrial control system (DCS) configuration format. This means that each page in the algorithm configuration diagram file contains vector engineering data, including controller locations, addresses, algorithm source code, download instructions, and version information. Consequently, the algorithm configuration diagram file can only be opened in the corresponding DCS configuration software. Furthermore, after opening the algorithm configuration diagram file, some configuration logic editing operations can be performed, such as dragging and dropping logic blocks, modifying parameters, adding or deleting interlocks, and adjusting the layout.
[0018] The research also revealed that, due to the unique nature of industrial control logic, the algorithm configuration diagrams in the aforementioned project documents do not present standardized geometric shapes. Furthermore, because the page layout of the algorithm configuration diagrams strictly depends on the logical flow of control signals, the document layout exhibits at least the following characteristics: ① When the algorithm configuration diagram describes simple logic, the signal paths are short and the logic nodes are few, naturally presenting a vertical, elongated structure suitable for vertical layout; ② When the algorithm configuration diagram describes complex logic, involving multiple parallel signals, complex feedback loops, or cross-references, the logic diagram extends significantly horizontally, naturally presenting a wide, horizontal structure, requiring horizontal layout to ensure logical coherence; ③ When the algorithm configuration diagram presents an irregular distribution, some special algorithm pages exhibit asymmetrical content distribution, resulting in highly irregular positions of the effective content areas within the page.
[0019] Research also revealed that when batch exporting or printing the aforementioned algorithm configuration diagram documents (such as documents containing irregular algorithm configuration diagrams) as PDF files, a "globally fixed template" approach can be used to ensure that each page in the final PDF file uses the same layout (e.g., landscape or portrait), thus forcibly unifying different pages within the algorithm configuration diagram document to the same layout. This PDF file (also known as the final draft file) refers to the rendered page image and text data obtained by exporting the algorithm configuration diagram document. It is a derived file from the same source as the original algorithm configuration diagram document, ensuring that the PDF file only retains the visual appearance and loses the underlying compilable control instructions. Furthermore, this PDF file is a static, fixed layout file and uses a universal read-only format. Additionally, after opening the PDF file, users can only view, print, and annotate, but cannot perform configuration logic editing operations, ensuring that users cannot modify the internal control algorithm through the PDF file.
[0020] The study also revealed that for the aforementioned algorithm configuration diagram document, if it is exported as a landscape PDF file, the algorithm configuration diagrams adapted for portrait orientation (such as those describing simple logic) will have large, invalid blank spaces on both sides of the corresponding pages in the PDF file. This results in content compression, reduced readability, and an impact on file quality. However, if the document is exported as a portrait PDF file, the algorithm configuration diagrams adapted for portrait orientation (such as those describing complex logic) will be forcibly paginated or excessively compressed, causing font size reduction and severely compressing the logical integrity. This significantly reduces file quality, may even lead to misreading risks, and pose security hazards in the corresponding scenarios. Therefore, PDF files exported from this algorithm configuration diagram document may suffer from file quality issues due to unexpected formatting anomalies.
[0021] The study also found that in order to solve the above problems, the quality of PDF files can be improved by manually identifying and repairing each page. However, this is not only time-consuming and labor-intensive, but also prone to human error, which can lead to disordered file order, lost or duplicated content. This cannot meet the needs of some scenarios (especially nuclear power safety-level scenarios), such as the requirements for file accuracy, efficiency and traceability.
[0022] Based on the above research, in order to solve the above problems, this application provides a file processing method, which includes: obtaining a first file (such as a landscape PDF file) and a second file (such as a portrait PDF file), wherein the first file and the second file are generated based on the same document (such as an algorithm configuration diagram page document for a project), the layout of the first file is different from the layout of the second file, and the content of the first page in the first file is the same as the content of the second page in the second file; obtaining quality information of the first page and the quality information of the second page, wherein the quality information indicates the quality of the page content; in response to the quality information satisfying a preset condition (such as the preset condition indicating that the page content quality of the second page is higher than the page content quality of the first page), replacing the first page in the first file with the second page, so as to ensure that the quality of the first file after replacement is higher than the quality of the first file before replacement, thereby improving the quality of the PDF file.
[0023] Furthermore, this application does not limit the executing entity of the file processing method. For example, the method can be applied to a terminal device or a server. Alternatively, the method can be implemented through data interaction between the terminal device and the server. The terminal device can be a smartphone, computer, personal digital assistant (PDA), tablet computer, etc. The server can be a standalone server, a cluster server, or a cloud server.
[0024] To enable those skilled in the art to better understand the technical solutions provided in this specification, the technical solutions will be clearly and completely described below with reference to the accompanying drawings of the embodiments involved. Obviously, the described embodiments are only some embodiments, not all embodiments. Based on these embodiments, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions.
[0025] To better understand the technical solution, the document processing method will be explained below with reference to some accompanying figures. For example... Figure 1 As shown, the file processing method includes steps 101 to 103 as described below. Among them, the... Figure 1 A flowchart of a document processing method provided in this application.
[0026] Step 101: Obtain a first file and a second file. The first file and the second file are generated based on the same document. The layout of the first file is different from that of the second file. The content of the first page in the first file is the same as the content of the second page in the second file.
[0027] The first file is a PDF file obtained by exporting the aforementioned algorithm configuration diagram document in a first format (such as landscape), so that each page in the first file is presented according to this first format. Therefore, each algorithm configuration diagram in the algorithm configuration diagram document is presented in this first file according to this first format.
[0028] Furthermore, the first file is not limited; for example, when the above algorithm configuration diagram document is... Figure 2 When displaying the algorithm configuration diagram page document, if the first format is... Figure 2 If the format shown is landscape, then the first document can be used. Figure 2 The implementation uses a landscape PDF file as shown, so that there is a gap between the pages in the first file and the pages in the algorithm configuration diagram document. Figure 2 The mapping relationship shown enables the first file to present the visual effect of the content in the configuration page document by the algorithm in a landscape layout.
[0029] Furthermore, the layout corresponding to the first document refers to the typesetting method used by most pages (e.g., all pages) in the first document when presenting valid content. Additionally, the layout corresponding to the first document is not limited; for example, it can be implemented using a landscape layout. Therefore, in one scenario, the layout corresponding to the first document can be obtained through statistical analysis of the layouts corresponding to each page in the first document, so that the layout corresponding to the first document can represent the typesetting method used by most pages (e.g., all pages) in the first document. Here, the layout corresponding to a single page refers to the typesetting method used by that page when presenting valid content.
[0030] It should be noted that the aforementioned valid content refers to the content displayed on the pages of the PDF file, such as visual renderings of some logical units. Therefore, in one scenario, the valid content presented on each page of the PDF file (such as the first file and the second file) is an image (such as an image rendered from an algorithm configuration diagram page), rather than text.
[0031] The second file is a PDF file obtained by exporting the aforementioned algorithm configuration diagram document in a second format (such as portrait orientation), so that all pages in the second file are presented in this second format. Therefore, each algorithm configuration diagram in the original document is presented in this second file according to the second format.
[0032] Furthermore, there is no limitation to a second file; for example, when the above algorithm configuration diagram document is... Figure 2 When showing the algorithm configuration diagram page document, if the second format is... Figure 2 The second document can be formatted in portrait mode as shown. Figure 2The illustrated portrait PDF file is implemented to ensure that there is a gap between the pages in the second file and the pages in the algorithm configuration diagram document. Figure 2 The mapping relationship shown enables the second file to present the visual effect of the content in the configuration page document by the algorithm in a vertical layout.
[0033] Furthermore, the layout corresponding to the second document refers to the typesetting method used by most pages (such as all pages) in the second document when presenting valid content. Additionally, the layout of the second document is not limited; for example, it can be implemented using a portrait layout. Therefore, in one scenario, the layout corresponding to the second document can be obtained through statistical analysis of the layouts of each page in the second document, so that the layout of the second document can represent the typesetting method used by most pages (such as all pages) in the second document.
[0034] Furthermore, there is a certain mapping relationship between the first file and the second file mentioned above (e.g. Figure 2 The mapping relationship shown indicates the content correspondence between different files, so that a page in one file can be replaced with a corresponding page in another file (e.g., ...). Figure 3 or Figure 4 During the repair process shown, the layout can be changed while keeping the content unchanged.
[0035] It is evident that, in one scenario, when the content corresponding to the first page in the aforementioned first document (such as the algorithm configuration diagram document) is the same as the content corresponding to the second page in the aforementioned second document, the first page (such as...) Figure 3 The valid content presented on the landscape page shown is consistent with that on the second page (such as...). Figure 3 The vertical pages shown present the same effective content, but the layout of the first page is different from that of the second page, so that subsequent decisions can be made based on these two pages to determine which layout is more suitable for the effective content.
[0036] For the aforementioned first page, it refers to any page in the first document. Furthermore, this application does not limit the implementation of the first page; for example, in one scenario, if the first document is a landscape PDF file, then the first page can be... Figure 3 The example shown is a landscape page. For instance, in one scenario, if the first file is a portrait-oriented PDF file, then the first page can be... Figure 4 The page shown is in portrait orientation.
[0037] Regarding the aforementioned second page, it refers to the page existing in the second file that is used to display the valid content presented by the aforementioned first page. Furthermore, this application does not limit the implementation of the second page; for example, in one scenario, if the second file is a portrait-oriented PDF file, then when the first page is... Figure 3 When the page is in landscape mode as shown, the second page can be... Figure 3 The image shows a portrait-oriented page. For example, in one scenario, if the second file is a landscape PDF file, then when the first page is... Figure 4 When the page is in portrait orientation, the second page can be... Figure 4 The page shown is in landscape mode.
[0038] Furthermore, the implementation of step 101 is not limited. For example, it can be implemented using any method that can generate PDF files based on the algorithm-configured page document according to different layout methods.
[0039] As can be seen, in one scenario, for an algorithm configuration diagram document of a certain project, if an export operation triggered for the document is detected, the document is exported according to different layout methods (such as landscape, portrait, etc.) to obtain PDF files corresponding to different layout methods (such as first file, second file), and a mapping relationship (such as one-to-one mapping relationship) is established between page numbers in different PDF files. The aim is to use this mapping relationship to represent the correspondence in content (such as images obtained from rendering the algorithm configuration diagram) of different PDF files, so that page number errors and page correspondence errors can be avoided during page replacement.
[0040] It should be noted that the process described above is not limited. For example, the process can at least satisfy the following constraints: ① When generating a landscape PDF file, all pages in the algorithm configuration diagram document are exported in landscape format to obtain a landscape PDF file, so that the page size of each page in the landscape PDF file completely matches the pre-set printing paper size, in order to fully present the graphic elements, parameters, bookmark information, etc. involved in each page of the algorithm configuration diagram document through the landscape PDF file; ② When generating a portrait PDF file, all pages in the algorithm configuration diagram document are exported in portrait format to obtain a portrait PDF file, so that the portrait PDF file... The page size, page number order, total number of pages, bookmark information, etc. of the portrait PDF file are consistent with those of the landscape PDF file (if they are the same), to ensure that the graphic elements presented on each page of the portrait PDF file are consistent with the graphic elements presented on the corresponding pages of the landscape PDF file, with only the layout method being different; ③ When establishing the mapping relationship between the landscape PDF file and the portrait PDF file, the page numbers in the landscape PDF file are matched one-to-one with the page numbers in the portrait PDF file, in order to achieve the same page number corresponding to the same algorithm configuration diagram page in both landscape and portrait layouts, so that the mapping relationship can be recorded through document metadata in the future, and to ensure that more accurate page replacement can be achieved based on the mapping relationship in the future.
[0041] Step 102: Obtain the quality information of the first page and the quality information of the second page, which indicates the quality of the page content.
[0042] The quality information of the first page indicates the quality of its content, enabling it to indicate whether the visual effects of the content (such as images) presented on the first page are defective, such as blurry images due to excessive compression or incomplete images due to forcibly splitting an image into multiple images. Therefore, in one scenario, the quality information is configured to indicate the state of the content presented on the first page in at least one dimension (such as image clarity or image integrity), aiming to indicate whether the visual effects of the content are defective.
[0043] The quality information of the second page can indicate the quality of the page content, enabling it to indicate whether there are visual defects in the effective content (such as images) presented on the second page, such as image blurring due to excessive compression or image incompleteness due to forcibly splitting an image into multiple images. Therefore, in one scenario, the quality information is configured to indicate the state of the effective content presented on the second page in at least one dimension (such as image sharpness, image integrity, etc.), in order to indicate whether there are visual defects in the effective content.
[0044] Furthermore, the implementation method of the aforementioned quality information is not limited; for example, it can be implemented using any metric that can measure the page quality in a PDF file.
[0045] Furthermore, the process for obtaining the aforementioned quality information is not limited. For example, it can employ any method capable of evaluating the quality of a page based on a page in a PDF file, such as by using a pre-built machine learning model with this evaluation function.
[0046] Research has found that in some scenarios, for images rendered from configuration diagrams based on any algorithm, if the image (such as...) Figure 3 The logical unit image presented in the landscape page or Figure 4 If the logical unit image presented on the vertical page is displayed in an incorrect layout, it will result in some defects in the visual effect of the image (such as unclear clarity, incompleteness, etc.).
[0047] The study also found that for images rendered from page configuration diagrams based on any algorithm, if the image is displayed in an incorrect layout, large areas of blank space will appear due to the mismatch between the image and the layout. Therefore, in order to identify this error, the proportion of blank space can be used to determine whether the image presented on a page matches the layout used on the page, so that the visual effect of the image can be determined based on the judgment result.
[0048] Based on the two studies above, it can be seen that in one scenario, when the target page is the first page or the second page, the process of determining the quality information of the target page may include: taking the target page (e.g., the first page or the second page) as the target page. Figure 5 The original page shown is converted into a first image; the first image is then binarized to obtain a second image (such as...). Figure 5 The binarization result shown); determine boundary information from the second image (such as...). Figure 5 (The boundary information shown indicates the content presented on the target page, such as...) Figure 5 The area occupied by the logical unit image and other valid content shown in the target page; based on the boundary information, the blank ratio of the target page is determined; based on the blank ratio, the quality information of the target page is determined so that the quality information includes the blank ratio, so as to ensure the accuracy of quality detection.
[0049] Regarding the aforementioned first image, it can present the valid content (such as an image) recorded on the target page in an image-like manner. Furthermore, the implementation method of the first image is not limited; for example, the first image can be implemented using any high-resolution image (such as a grayscale image). Thus, in one scenario, the first image can be a grayscale image with a resolution of not less than 300 dots per inch (DPI) to eliminate the precision loss during the vector-to-bitmap conversion process and ensure clear distinction between algorithm primitives and blank areas. Moreover, the method of obtaining the first image is not limited; for example, it can be implemented using any method capable of converting a single page from a PDF file into this grayscale image.
[0050] The second image described above can present the valid content (such as an image) recorded on the target page in a binarized manner. Furthermore, the implementation of the second image is not limited; for example, it can be implemented using any type of binary image. Additionally, the implementation of the second image is not limited; for example, it can be implemented using any method capable of converting a grayscale image to a binary image. As can be seen, in one scenario, the process of acquiring the second image may include: after converting the target page into the first image, performing a binarization transformation on the first image based on the Gaussian adaptive threshold binarization algorithm to obtain the second image. The aim is to use this binarization transformation to set the effective content presented in the first image (such as algorithm primitives, functional blocks, signal connections, parameter annotations, and other logical units) as the foreground color (such as pure black with a pixel value of 0), and to set the blank areas in the first image that do not record any content as the background color (such as pure white with a pixel value of 255). This makes the second image a binary image composed of pure black and pure white values, which can effectively eliminate the interference of brightness and contrast differences and background noise between different images on the detection results.
[0051] It should be noted that the aforementioned logical unit refers to objects existing in the algorithm configuration diagram that need to be presented in the PDF file using image rendering, such as algorithm primitives, function blocks, signal connections, parameter annotations, etc. Furthermore, this application does not limit the implementation method of this logical unit.
[0052] Regarding the aforementioned boundary information, this boundary information can indicate the valid content presented on the target page (such as...). Figure 5The image shown (of logical units) occupies the area on the target page, with the aim of using this boundary information to indicate the positional distribution of the valid content on the target page. Furthermore, the boundary information is not limited; for example, it can be implemented using the smallest rectangle that can enclose the valid content. Moreover, the method of obtaining the boundary information is not limited; for example, it can be implemented using any method that can identify the boundaries of valid content within a single page of a PDF file. Therefore, in one scenario, the process of obtaining the boundary information may include: first, determining the edge position of the valid content on the target page based on the second image, such as... Figure 5 The leftmost, rightmost, topmost, and bottommost boundary positions of the logical unit shown are identified; then, based on these edge positions, a minimum rectangle that can enclose the valid content is constructed (e.g., ...). Figure 5 (as shown by the green border); then, the boundary information is determined based on the minimum rectangle so that the boundary information can indicate the edge position of the minimum rectangle, thereby indicating the maximum boundary of the valid content.
[0053] Regarding the white space ratio of the target page, this white space ratio indicates the size of the blank areas without recorded content on the target page relative to the size of the displayed content. Therefore, this white space ratio can, to some extent, indicate whether the layout of the target page is compatible with the effective content presented on the target page. Furthermore, the method of obtaining this white space ratio is not limited; for example, it can be implemented using any method capable of calculating the white space ratio for a single page in a PDF file.
[0054] Research has revealed that the importance of blank areas in the same location varies across different layouts. Specifically: in a landscape layout, the horizontal blank area corresponding to the content better reflects the compatibility of the content with the landscape layout, making the horizontal blank area more important than the vertical blank area of the content; conversely, in a portrait layout, the vertical blank area corresponding to the content better reflects the compatibility of the content with the portrait layout, making the vertical blank area more important than the horizontal blank area of the content.
[0055] Based on the above research, in one scenario, the process of determining the white space ratio of the target page can include: first, determining the corresponding strategy information based on the layout of the target page, so that the strategy information can indicate the importance of white space areas in different locations, thereby indicating the calculation process of the white space ratio; then, determining the white space ratio of the target page based on the strategy information and the aforementioned boundary information, so that the white space ratio can more accurately measure the compatibility between the effective content presented on the target page and the layout method adopted by the target page, thereby making the quality information determined based on the white space ratio more accurate. It is evident that, in one scenario, the white space ratio of the target page is not only obtained based on the boundary information but also determined based on the strategy information, which is based on the layout of the target page and indicates the calculation process of the white space ratio.
[0056] Regarding the layout of the target page mentioned above, the layout refers to the typesetting method adopted by the target page. Furthermore, the method for determining the layout of the target page is not limited. For example, the layout of the target page can be implemented using the layout of the PDF file to which the target page belongs. As another example, in one scenario, the layout of the target page can be implemented using any method capable of recognizing the typesetting of individual pages in a PDF file, such as a pre-built machine learning model with this recognition function.
[0057] Regarding the strategy information corresponding to the aforementioned target page, this strategy information indicates the importance of blank areas in different locations on the target page, aiming to guide the calculation process of the blank area ratio of the target page. Furthermore, this strategy information is not limited. For ease of understanding, two examples are provided below.
[0058] Example 1: When the target page is laid out in landscape mode, the white space ratio of the target page can be determined based on the horizontal white space area corresponding to the effective content on the target page. Specifically, it can be done as follows: First, based on the left and right edges of the maximum boundary of the effective content (such as the maximum boundary described by the boundary information above), identify the white space areas located on the left and right sides of the maximum boundary of the target page; then, divide the target page into multiple columns equally along the width to obtain the total number of columns of the target page (e.g., ...). Figure 5 The results of the equal division shown are used to count the number of columns covered by the blank area to obtain the number of blank columns. Then, the number of blank columns is divided by the total number of columns on the page to obtain the blank percentage of the target page, so that the blank percentage can be in the range of 0-1 or 0%-100%. The number of columns is not limited. For example, the number of columns can be N columns, where N is a positive integer and N≥10 (e.g., N is 20).
[0059] Example 2: When the target page is in portrait orientation, the white space ratio of the target page can be determined based on the vertical white space corresponding to the effective content. Specifically, it can be done as follows: First, based on the top and bottom edges of the maximum boundary of the effective content (such as the maximum boundary described above), identify the white space located on the top and bottom sides of the maximum boundary of the target page; then, divide the target page into multiple rows along the vertical direction of height to obtain the total number of rows of the target page, and count the number of rows covered by the white space to obtain the number of blank rows; finally, divide the number of blank rows by the total number of rows of the page to obtain the white space ratio of the target page, so that the value of the white space ratio is in the range of 0-1 or 0%-100%. The number of rows is not limited; for example, the number of rows can be M rows, where M is a positive integer, M≥10 (e.g., M=20).
[0060] Based on the aforementioned quality information, for any single page in a PDF file (such as the first or second page), the page is first converted into a grayscale image with a resolution of at least 300 DPI (as in the first image mentioned above). This eliminates the precision loss during the vector-to-bitmap conversion process, ensuring clear distinction between algorithm primitives and blank areas, thus laying the foundation for subsequent binarization processing. Then, based on the Gaussian adaptive threshold binarization algorithm, the grayscale image is converted into a pure black and pure white binary image (as in the second image mentioned above). This binarization aims to convert the algorithm primitives, functional blocks, signal connections, parameter annotations, and other logical units presented in the grayscale image into the foreground color of the binary image, and to convert the blank areas in the grayscale image into the binary image. The background color in the image is used to eliminate the interference of brightness and contrast differences and background noise from different drawings on the detection results. Then, based on the binary image, the edge positions (such as extreme touch positions) of the effective content in the single page are identified, such as the leftmost, rightmost, topmost, and bottommost edge positions of the effective content, to form the smallest rectangle that completely encloses the effective content, and the edge of the rectangle is taken as the maximum boundary of the effective content (as mentioned above, boundary information). Finally, based on the maximum boundary and the strategy information that matches the layout of the single page, the blank ratio of the single page is calculated to obtain the quality information of the single page, so that the quality information can indicate whether the effective content presented on the single page is compatible with the layout method used on the single page.
[0061] Step 103: In response to the quality information meeting the preset conditions, replace the first page in the first file with the second page. The preset conditions indicate that the page content quality of the second page is higher than that of the first page.
[0062] The preset conditions are configured as the recognition logic for indicating the best layout for the same content.
[0063] Furthermore, the identification logic for the optimal layout is not limited to the above. For example, when the quality information includes the white space ratio, the identification logic can be as follows: For a single page in a PDF file, the higher the white space ratio value of the single page, the larger the invalid white space area outside the boundaries of the valid content on the single page. This indicates that the layout method used on the single page is less reasonable. Therefore, the white space ratios of single pages corresponding to the same valid content under different layouts can be compared. The single page with a larger white space ratio value is judged to have an unreasonable layout method, while the single page with a smaller white space ratio value is judged to have an optimal layout method that is suitable for the valid content. To facilitate understanding, an example is provided below.
[0064] As an example, for any page pair constructed based on landscape and portrait PDF files, the page pair can indicate the single PDF page corresponding to the same valid content in different layouts. Based on this assumption, the page pair includes landscape and portrait pages, where the landscape page refers to the single page in the landscape PDF file that presents the valid content, and the portrait page refers to the single page in the portrait PDF file that presents the valid content.
[0065] Based on the above assumption, in one scenario, the logic for identifying the optimal layout could include the following: First, obtain the pre-set anomaly threshold T1 and difference threshold T2, so that the anomaly threshold T1 is used to initially screen suspected abnormal pages, and the difference threshold T2 is used to determine the rationality of the layout method; Based on the abnormal threshold T1, traverse the page pairs. If the blank ratio of the horizontal page in the page pair does not exceed the abnormal threshold T1 and the blank ratio of the vertical page in the page pair also does not exceed the abnormal threshold T1, then it can be determined that the horizontal PDF file and the vertical PDF file generated by the configuration page document based on the same algorithm are both normally formatted and do not need to be repaired. Either of these two PDF files can be kept for archiving. If the blank space ratio of the horizontal version of the page exceeds the abnormal threshold T1 and the blank space ratio of the vertical version of the page also exceeds the abnormal threshold T1, it can be determined that both the horizontal and vertical PDF files exhibit layout abnormalities under the indicated valid content on the page (e.g., the algorithm configuration diagram page rendering the valid content is in an ultra-wide or ultra-height format, and neither the horizontal nor vertical layout can be fully adapted). Automatic repair cannot be achieved through page replacement, so it is marked as a manual verification item. The purpose of this mark is to indicate that the abnormality should be resolved through manual verification rather than through automatic page replacement, so as to ensure that there is no need to perform the automatic page replacement process for this page. If only one page in the page pair has a blank space ratio exceeding the abnormal threshold T1 (e.g., the blank space ratio of the horizontal page exceeds the abnormal threshold T1, or the blank space ratio of the vertical page in the page pair also exceeds the abnormal threshold T1), it can be determined that the quality of the valid content indicated by the page pair varies significantly under different layouts. Therefore, a judgment is made based on the difference threshold T2 and the difference between the blank space ratio of the horizontal page and the blank space ratio of the vertical page. If the difference obtained by subtracting the blank space ratio of the vertical page from the blank space ratio of the horizontal page is greater than the difference threshold T2, it can be determined that the layout method used by the horizontal page is not suitable for displaying the valid content, but the layout method used by the vertical page is not suitable for displaying the valid content. If the vertical layout is suitable for displaying the valid content, then the vertical page can be kept for archiving. If the difference between the blank area of the vertical page and the blank area of the horizontal page is greater than the difference threshold T2, then the layout of the vertical page is not suitable for displaying the valid content, but the layout of the horizontal page is suitable for displaying the valid content, so the horizontal page can be kept for archiving. If the absolute value of the difference between the blank area of the horizontal page and the blank area of the vertical page does not exceed the difference threshold T2, then the valid content has no significant difference under different layouts and is a reasonable version, requiring no repair. Either the horizontal page or the vertical page can be kept for archiving.
[0066] Based on the above example, if a landscape PDF file is pre-set as the base file and a portrait PDF file as the reference file, then any single page in the landscape PDF file identified as having an unreasonable layout will be replaced with a corresponding single page in the portrait PDF file (e.g., a single page with the same formatting), thus achieving layout error correction through automatic page replacement. Furthermore, this application does not limit the method for determining the base file and reference file. For example, in some scenarios, the base file and reference file can be determined based on default configurations. Also, in some scenarios, it can be determined based on user interaction (e.g., by...). Figure 6 The human-computer interaction is implemented in the interaction layer or by utilizing Figure 7 The interface shown demonstrates human-computer interaction. This method adjusts the base file and reference file to flexibly adapt to various scenarios, such as algorithm configuration diagrams primarily using landscape layouts or those primarily using portrait layouts. Furthermore, the replacement process fully preserves the page order, page number identifiers, and bookmark information of the original file (such as the base file), eliminating the risk of content loss or page number misalignment. Finally, after completing all automatic replacement steps for the base file, a PDF file corrected through automatic page replacement is obtained.
[0067] Based on the above six paragraphs, it can be seen that in one scenario, when the aforementioned quality information includes the white space ratio, the aforementioned preset conditions may include: the white space ratio of the first page is greater than a first threshold (such as the aforementioned abnormal threshold T1), the white space ratio of the second page is not greater than the first threshold, and the difference between the white space ratio of the first page and the white space ratio of the second page exceeds a second threshold (such as the aforementioned difference threshold T2), in order to better identify the optimal layout method corresponding to the same valid content by means of these preset conditions, thereby improving accuracy.
[0068] Based on the relevant content of steps 101 to 103 above, the document processing method provided in this application includes: obtaining a first file (such as a landscape PDF file) and a second file (such as a portrait PDF file), wherein the first file and the second file are generated based on the same document (such as an algorithm configuration diagram page document for a certain project), the layout of the first file is different from the layout of the second file, and the content of the first page in the first file is the same as the content of the second page in the second file; obtaining the quality information of the first page and the quality information of the second page, wherein the quality information indicates the quality of the page content; in response to the quality information satisfying a preset condition (such as the preset condition indicating that the page content quality of the second page is higher than the page content quality of the first page), replacing the first page in the first file with the second page, so as to ensure that the quality of the first file after replacement is higher than the quality of the first file before replacement, thereby improving the quality of the PDF file.
[0069] In addition, to further improve the repair effect, the above-mentioned file processing method may include not only steps 101 to 103, but also the following steps: detecting at least some pages (such as the replaced single page) in the first file to obtain detection results, so that the detection results can indicate whether there are pages in the first file that are abnormal (such as incompatibility between valid content and layout); in response to the detection results indicating that a third page in the first file is abnormal (such as the valid content presented in the replaced single page still not matching the layout used by the single page), generating abnormal information based on the third page, so that the abnormal information can indicate the relevant content of the abnormality in the first file (such as page numbers marked with manual verification items, blank ratio before and after replacement, page preview comparison before and after replacement, abnormality type, etc.); displaying the abnormal information; and in response to at least one operation, updating the first file so that the updated first file has fewer abnormalities than the first file before the update, thereby improving the file repair effect.
[0070] The above detection results are obtained through automatic verification of PDF files (such as the first file after page replacement, the first file without any layout abnormalities, the first file marked with manual verification items, etc.), aiming to indicate whether there are layout abnormalities on each page of the PDF file. The automatic verification method is not limited; for example, it can employ any method capable of identifying layout abnormalities in PDF files, such as... Figure 8 or Figure 9 The first-level automatic verification is implemented as shown. This first-level automatic verification is configured to perform at least the following steps: For all pages in the PDF file that have undergone automatic page replacement, the white space ratio calculation process is re-executed. If the recalculated white space ratio does not exceed the aforementioned anomaly threshold T1, it can be determined that the layout anomaly has been successfully overcome through automatic page replacement, and the replaced page is considered to be in normal layout. If the recalculated white space ratio still exceeds the anomaly threshold T1, it can be determined that the layout anomaly cannot be resolved through automatic page replacement. Therefore, the replaced page is marked as a manual verification item, with the aim of indicating that the anomaly should be resolved through manual verification.
[0071] For the aforementioned third page, it refers to a single page in the first document that exhibits layout abnormalities, so that the third page can, to a certain extent, indicate layout abnormalities that cannot be overcome by automatic page replacement. Furthermore, the method for determining the third page is not limited; for example, it may specifically include: first calculating the white space ratio of each page in the first document; and based on the white space ratio and the aforementioned abnormality threshold T1, determining the third page to ensure that the white space ratio of the third page exceeds the abnormality threshold T1.
[0072] For the aforementioned anomaly information, this anomaly information refers to the result of automatic verification of PDF files (such as the first file after page replacement, the first file without any layout anomalies, the first file marked with manual verification items, etc.), so that the anomaly information can indicate the relevant abnormal content in the PDF file. Furthermore, the anomaly information is not limited; for example, it can be implemented using an anomaly page verification checklist. This checklist should at least include the page number of the manually verified item, the percentage of blank space before and after replacement, a comparison of page previews before and after replacement, and the anomaly type.
[0073] For the above-mentioned at least one operation, the at least one operation refers to the operation performed by the user when manually verifying the above-mentioned abnormal information, with the aim of resolving part or all of the abnormality indicated by the abnormal information through the at least one operation. In addition, the implementation method of the at least one operation is not limited. For example, the at least one operation may refer to some operations directly performed on the first file, with the aim of realizing manual review, manual replacement, and page orientation adjustment operations on the abnormal page through the at least one operation.
[0074] Research has found that in some scenarios, adjusting certain parameters used when calculating the percentage of blank space (such as...) can help. Figure 7 The blank detection parameters (such as DPI and fraction of equal parts) shown are used to perform manual verification.
[0075] Based on the above research, it can be seen that, in one scenario, the above file processing method may include at least the following steps: based on first configuration information (such as...) Figure 7 The blank detection parameters (such as DPI and fraction of equal parts) are used to determine the quality information of the first page and the quality information of the second page. The first configuration information indicates the calculation process of the quality information. In response to the quality information meeting the preset conditions, the first page in the first file is replaced with the second page. At least some pages in the first file are detected to obtain the detection results. In response to the detection results indicating that the third page in the first file has an anomaly, anomaly information is generated based on the third page. The anomaly information is displayed. In response to at least one operation, the first configuration information is updated based on the at least one operation, and the aforementioned step of "determining the quality information of the first page and the quality information of the second page based on the first configuration information" and its subsequent steps are continued to achieve file repair by manually adjusting the first configuration information, so as to better improve the repair effect.
[0076] Regarding the aforementioned first configuration information, this first configuration information refers to the parameters used when analyzing the quality of a single PDF page (such as the percentage of blank space), with the aim of adjusting the characteristics of the quality calculation process through this first configuration information. Furthermore, this first configuration information is not limited; for example, it may include at least... Figure 7 The diagram shows the blanking detection DPI and the number of divisions. The blanking detection DPI refers to the sampling sharpness used when converting a single PDF page into an image. A higher DPI results in more accurate blanking boundary detection and a lower error in calculating the blanking percentage. The number of divisions refers to the number of divisions used when dividing the image. A higher DPI results in more accurate blanking boundary detection and a lower error in calculating the blanking percentage.
[0077] Research has found that in some scenarios, adjusting certain parameters used when identifying the optimal layout (such as...) can help. Figure 7The abnormal threshold T1 and difference threshold T2, etc., shown in the figure, are used to perform manual verification.
[0078] Based on the above research, it can be seen that, in one scenario, the above file processing method may include at least the following steps: based on a second configuration parameter (such as...) Figure 7 The system uses parameters such as the anomaly threshold T1 and the difference threshold T2 to determine preset conditions. In response to the quality information of the first page and the second page satisfying the preset conditions, it replaces the first page in the first file with the second page. It then performs detection on at least some pages in the first file to obtain detection results. In response to the detection results indicating an anomaly on the third page of the first file, it generates anomaly information based on the third page. It displays the anomaly information. In response to at least one operation, it updates the second configuration information based on the at least one operation, and continues to execute the aforementioned step of "determining preset conditions based on the second configuration parameters" and its subsequent steps. This allows for file repair through manual adjustment of the second configuration information, thereby improving the repair effect.
[0079] Regarding the aforementioned second configuration information, this second configuration information refers to the parameters used when constructing the triggering conditions (such as the aforementioned preset conditions) of the automatic page replacement process, with the aim of adjusting the triggering conditions of the automatic page replacement process through this second configuration information. Furthermore, this second configuration information is not limited; for example, it may include at least... Figure 7 The parameters shown are the abnormal threshold T1 and the difference threshold T2.
[0080] Based on the above-mentioned manual verification content, it can be seen that for PDF files (such as those processed by...), Figure 8 or Figure 9 For a PDF file after Level 1 automatic verification, after displaying the corresponding error information to the user, the user can directly perform some operations on the PDF file based on the error information. This allows for manual review, manual replacement, and page orientation adjustment of the abnormal pages. Furthermore, the user can also adjust the parameters involved in some processes (such as the blank ratio calculation process and the process of determining whether the page replacement process has been triggered) based on the error information, so as to re-execute the process based on the adjusted parameters. This allows for manual adjustment of some parameters and one-click re-execution of the corresponding process based on the adjusted parameters.
[0081] In another scenario, for PDF files after page replacement, a two-level closed-loop verification process of "automatic verification + manual verification" can be performed, while simultaneously retaining a complete end-to-end operation log to ensure zero-error verification results. This aligns with the high reliability and traceability compliance requirements of scenarios such as nuclear power plants. "Retaining a complete end-to-end operation log" refers to real-time recording of the entire operation log (e.g., timestamps, operation content, anomaly information, processing results), allowing users to export the log file with a single click. This enables full-process log recording and export, better facilitating compliance traceability and meeting compliance archiving requirements in certain scenarios. Furthermore, in another scenario, after completing the verification process, a verification processing report is simultaneously output. This report records all abnormal pages, processing methods, verification results, and time statistics, meeting the compliance archiving requirements of these scenarios.
[0082] In addition, in one scenario, this application also provides a visual desktop interface (such as...). Figure 7 The interface shown allows users to complete the entire process parameter configuration and execution without modifying the code. Specifically, the exception page detection configuration module deployed in this interface is configured to support visual setting of blank area thresholds and blank detection DPI, simultaneously performing parameter range validation to avoid invalid parameter input. The file selection module in this interface is configured to support visual selection of horizontal base files and vertical replacement of source files, achieving automatic file path filling, etc. The execution and progress module in this interface is configured to support one-click start of the repair process and real-time progress bar display to avoid program freezes, etc. The log display module in this interface is configured to display execution logs in real time and support one-click log export.
[0083] Furthermore, this application does not limit the execution scenario of the document processing method; for example, it can be implemented in a document printing scenario. Therefore, for a first document that has undergone some process processing (such as automatic page replacement and two-level validation), directly printing the first document ensures that the resulting paper document can present the valid content in a high-quality manner.
[0084] Based on the aforementioned document processing methods, it is clear that the document processing method provided in this application is based on the layout characteristics of the algorithm configuration diagram page, giving the document processing method the following characteristics: ① This application provides a blank ratio quantification detection method based on the maximum boundary recognition of logical units (such as valid content), which can complete the determination of page layout rationality without relying on any text content, solving the pain point of recognition failure in discrete primitive type documents in existing technologies; ② This application establishes a directional quantification judgment rule that matches the layout characteristics of the algorithm configuration diagram page, and designs horizontal and vertical blank ratio calculation methods for horizontal and vertical pages respectively. Through direct comparison of the blank ratio of the same source dual versions, accurate determination of layout abnormalities is achieved. This avoids subjective errors caused by manual visual judgment and ensures consistency of processing results across different batches; ③ This application constructs a complete automated processing flow of "generating dual-version source files, detecting layout anomalies, intelligent page replacement, two-level verification, and full-process traceability," coupled with a fallback mechanism for manual verification in boundary scenarios where both versions are abnormal. This achieves unmanned operation throughout the entire process of algorithm configuration PDF layout correction, ensuring the reliability and compliance of the processing results; ④ The detection parameters, basic document selection, and screenshot output configuration in this application all support visual custom adjustment, which can adapt to the processing needs of different types and sizes of algorithm configuration diagrams in nuclear power plants, and can also be smoothly extended to configuration document processing scenarios in other industrial control fields.
[0085] As can be seen, the document processing method provided in this application has the following advantages: This document processing method is proposed for the scenario of printing and archiving industrial configuration documents, solving the layout correction problem of irregular horizontal and vertical mixed-layout algorithm configuration diagrams. It directly adapts to the actual needs of compliant document archiving in some scenarios (such as nuclear power plants), filling the technical gap in this specific scenario; This document processing method can adapt to discrete primitive documents without continuous text, solving the problem of human error risk in existing manual recognition technology in algorithm configuration PDF scenarios; This document processing method achieves fully automated processing, significantly improving processing efficiency. It aims to construct a fully automated processing system from document generation to report output through this document processing method, thereby reducing the processing time of a single 500-page document from 4 hours of manual processing. The processing time has been reduced from 0.5 hours to less than 5 minutes, improving efficiency by over 95% and significantly reducing the risk of human error. This document processing method features a robust reliability assurance mechanism, employing a two-tiered closed-loop verification system of "automatic verification + manual verification." A manual review process is included as a fallback for boundary scenarios where neither version can be adapted, and complete retention of all operation records ensures traceability and high reliability in certain scenarios. Furthermore, this method provides a standardized quantitative system for determining layout rationality. By establishing targeted quantitative calculation and comparison rules for white space ratios, it standardizes the determination of layout anomalies, avoiding subjective errors in manual judgment and ensuring consistency in processing results across different batches and by different operators.
[0086] Based on the aforementioned document processing method, this application also provides a document processing apparatus, which is described below in conjunction with... Figure 10 This section explains and clarifies the relevant content of the document processing device. Among other things, Figure 10 This is a schematic diagram of a document processing apparatus provided in this application. It should be noted that for technical details of the document processing apparatus provided in this application, please refer to the relevant content of the document processing method above.
[0087] like Figure 10 As shown, the document processing apparatus 1000 provided in this application includes: The first unit 1001 is used to obtain a first file and a second file. The first file and the second file are generated based on the same document. The layout of the first file is different from the layout of the second file. The content of the first page in the first file is the same as the content of the second page in the second file. The second unit 1002 is used to obtain the quality information of the first page and the quality information of the second page, wherein the quality information indicates the quality of the page content. The third unit 1003 is used to replace the first page in the first file with the second page in response to the quality information meeting a preset condition, wherein the preset condition indicates that the page content quality of the second page is higher than that of the first page.
[0088] In one scenario, the target page is either the first page or the second page; the process of determining the quality information of the target page includes: converting the target page into a first image; performing binarization processing on the first image to obtain a second image; determining boundary information from the second image, the boundary information indicating the area occupied by the content presented in the target page; determining the blank ratio of the target page based on the boundary information; and determining the quality information of the target page based on the blank ratio.
[0089] In one scenario, the blank space ratio is also determined based on strategy information, which is determined based on the layout corresponding to the target page, and the strategy information indicates the calculation process of the blank space ratio.
[0090] In one scenario, the quality information includes the blank space ratio; the preset conditions include: the blank space ratio of the first page is greater than a first threshold, the blank space ratio of the second page is not greater than the first threshold, and the difference between the blank space ratio of the first page and the blank space ratio of the second page exceeds a second threshold.
[0091] In one scenario, the file processing apparatus 1000 further includes: a fourth unit, configured to detect at least a portion of the pages in the first file and obtain a detection result; in response to the detection result indicating an anomaly in a third page of the first file, generate anomaly information based on the third page; display the anomaly information; and update the first file in response to at least one operation.
[0092] In one scenario, the second unit 1002 is specifically used to: determine the quality information of the first page and the quality information of the second page based on the first configuration information, wherein the first configuration information indicates the calculation process of the quality information; The fourth unit is specifically used for: updating the first configuration information based on the at least one operation, and continuing to execute the step of determining the quality information of the first page and the quality information of the second page based on the first configuration information.
[0093] Based on the aforementioned content regarding the document processing device 1000, its working principle includes: obtaining a first file (e.g., a landscape PDF file) and a second file (e.g., a portrait PDF file), wherein the first file and the second file are generated from the same document (e.g., an algorithm configuration diagram document for a project), the layout of the first file is different from that of the second file, and the content of the first page in the first file is the same as the content of the second page in the second file; obtaining quality information of the first page and the second page, wherein the quality information indicates the quality of the page content; and in response to the quality information satisfying a preset condition (e.g., the preset condition indicating that the page content quality of the second page is higher than that of the first page), replacing the first page in the first file with the second page to ensure that the quality of the first file after replacement is higher than that of the first file before replacement, thereby improving the quality of the PDF file.
[0094] In addition, this application also provides an electronic device, the device including a processor and a memory: the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device performs any implementation of the file processing method provided in this application.
[0095] See Figure 11 The diagram illustrates a structural schematic of an electronic device 1100 suitable for implementing embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablets, portable media players (PMPs), and in-vehicle terminals (such as in-vehicle navigation terminals), as well as fixed terminals such as television (TV), desktop computers, etc. Figure 11 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0096] like Figure 11As shown, electronic device 1100 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 1101, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1102 or a program loaded from storage device 1108 into random access memory (RAM) 1103. The RAM 1103 also stores various programs and data required for the operation of electronic device 1100. The processing unit 1101, ROM 1102, and RAM 1103 are interconnected via bus 1104. An input / output (I / O) interface 1105 is also connected to bus 1104.
[0097] Typically, the following devices can be connected to I / O interface 1105: input devices 1106 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 1107 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1108 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1109. Communication device 1109 allows electronic device 1100 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 11 An electronic device 1100 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0098] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing any embodiment of the file processing method provided in this application. In such embodiments, the computer program can be downloaded and installed from a network via communication device 1109, or installed from storage device 1108, or installed from ROM 1102. When the computer program is executed by processing device 1101, it performs the functions defined above in the methods of embodiments of this disclosure.
[0099] The electronic device provided in this embodiment and the file processing method provided in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0100] This application also provides a computer-readable medium storing instructions or a computer program that, when executed on a device, causes the device to perform any implementation of the file processing method provided in this application.
[0101] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can 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 a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, RAM, ROM, an erasable programmable read-only memory (EPROM), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, radio frequency (RF), or any suitable combination thereof.
[0102] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol, such as Hypertext Transfer Protocol (HTTP), and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include Local Area Networks (LANs), Wide Area Networks (WANs), the Internet (such as the Internet), and peer-to-peer networks, as well as any currently known or future-developed networks.
[0103] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0104] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, enable the electronic device to perform the aforementioned methods.
[0105] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LANs or WANs—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0106] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0107] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units / modules do not necessarily limit the specific unit itself.
[0108] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Product (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), etc.
[0109] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems or apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to the method section.
[0110] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0111] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0112] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in RAM, memory, ROM, electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0113] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A file processing method, characterized in that, The method includes: Obtain a first file and a second file, which are generated from the same document. The layout of the first file is different from that of the second file. The content of the first page in the first file is the same as the content of the second page in the second file. Obtain quality information of the first page and quality information of the second page, wherein the quality information indicates the quality of the page content; In response to the quality information meeting a preset condition, the first page in the first file is replaced with the second page, whereby the preset condition indicates that the page content quality of the second page is higher than that of the first page.
2. The method according to claim 1, characterized in that, The target page is either the first page or the second page; The process of determining the quality information of the target page includes: Convert the target page into a first image; The first image is binarized to obtain the second image; Boundary information is determined from the second image, the boundary information indicating the area occupied by the content presented in the target page within the target page; Based on the boundary information, the blank space ratio of the target page is determined; Based on the stated blank space ratio, the quality information of the target page is determined.
3. The method according to claim 2, characterized in that, The blank space ratio is also determined based on strategy information, which is determined based on the layout corresponding to the target page, and the strategy information indicates the calculation process of the blank space ratio.
4. The method according to claim 1, characterized in that, The quality information includes the percentage of blank areas; The preset conditions include: the blank space ratio of the first page is greater than a first threshold, the blank space ratio of the second page is not greater than the first threshold, and the difference between the blank space ratio of the first page and the blank space ratio of the second page exceeds a second threshold.
5. The method according to any one of claims 1-4, characterized in that, After replacing the first page in the first file with the second page, the method further includes: At least a portion of the pages in the first file are inspected to obtain the inspection results; In response to the detection result indicating an anomaly on the third page of the first file, anomaly information is generated based on the third page; Display the aforementioned abnormal information; In response to at least one operation, update the first file.
6. The method according to claim 5, characterized in that, Obtaining the quality information of the first page and the quality information of the second page includes: The quality information of the first page and the quality information of the second page are determined based on the first configuration information, wherein the first configuration information indicates the calculation process of the quality information; The update of the first file includes: The first configuration information is updated based on the at least one operation, and the steps of determining the quality information of the first page and the quality information of the second page based on the first configuration information are continued.
7. A document processing device, characterized in that, include: The first unit is used to obtain a first file and a second file, which are generated based on the same document. The layout of the first file is different from that of the second file. The content of the first page in the first file is the same as the content of the second page in the second file. The second unit is used to obtain the quality information of the first page and the quality information of the second page, wherein the quality information indicates the quality of the page content. The third unit is used to replace the first page in the first file with the second page in response to the quality information meeting a preset condition, wherein the preset condition indicates that the page content quality of the second page is higher than that of the first page.
8. An electronic device, characterized in that, The device includes: a processor and a memory; The memory is used to store instructions or computer programs; The processor is configured to execute the instructions or computer program in the memory to cause the electronic device to perform the method according to any one of claims 1-6.
9. A computer-readable medium, characterized in that, The computer-readable medium stores instructions or computer programs that, when executed on the device, cause the device to perform the method according to any one of claims 1-6.
10. A computer program product, characterized in that, It includes a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the method of any one of claims 1-6.