A PDF document invoice page rapid identification and extraction method based on multi-strategy fusion

By employing a multi-strategy fusion method combining QR code semantic verification and black pixel detection, the problems of high computational overhead and low recall rate in invoice page recognition in PDF documents are solved, achieving efficient and fast invoice page recognition and extraction.

CN121392865BActive Publication Date: 2026-04-14HUA DATA TECH (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing technologies suffer from high computational overhead and latency when quickly separating invoice pages from non-invoice pages in multi-source merged PDF documents, and blurry or unreadable QR codes result in insufficient recall and stability.

Method used

A multi-strategy fusion method combining QR code semantic verification and black pixel structure detection is adopted. By inspecting PDF documents in parallel, QR code recognition is attempted first, and black pixel detection is performed if it fails, to ensure efficient recognition of invoice pages.

Benefits of technology

It significantly improves recognition speed and recall rate on large pages, avoids full-page OCR, is suitable for batch tasks with many pages, and balances accuracy and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121392865B_ABST
    Figure CN121392865B_ABST
Patent Text Reader

Abstract

The application provides a PDF document invoice page rapid identification and extraction method based on multi-strategy fusion, and relates to the technical field of document image identification and extraction. The PDF document invoice page rapid identification and extraction method based on multi-strategy fusion comprises the following steps: parallelizing checking each page in a PDF document, and extracting embedded image resources in the page; applying a two-dimensional code identification strategy, attempting to decode and determining an invoice in a semantic verification mode; as a supplementary determination strategy, using a black pixel detection strategy to determine whether a two-dimensional code exists in the upper left corner of the picture; and finally, combining and outputting the determination results. Through the two-strategy rapid fusion method of two-dimensional code semantic verification and black pixel structure detection, the application realizes efficient identification and extraction of the PDF document invoice page, guarantees the accuracy of determination and improves the processing speed in a batch task with a large number of pages.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of document image recognition and extraction technology, and in particular to a method for rapid recognition and extraction of invoice pages in PDF documents based on multi-strategy fusion. Background Technology

[0002] In scenarios such as automated financial processing, it is often necessary to quickly separate invoice pages from non-invoice pages in multi-source merged PDF documents. Existing methods that rely on OCR for text recognition of the entire page introduce high computational overhead and latency, especially when there are many pages, significantly impacting overall throughput. Furthermore, the resolution, compression, and lighting conditions of scanned documents can cause QR codes to be blurry or unreadable, making solutions relying solely on single QR code recognition insufficient in recall and stability. Therefore, there is an urgent need for a recognition method that remains efficient and fast even with large amounts of pages, while also ensuring accuracy and robustness. Summary of the Invention

[0003] To address the shortcomings of existing technologies, this invention proposes a rapid identification and extraction method for invoice pages in PDF documents based on multi-strategy fusion. This method achieves efficient identification and extraction of invoice pages from PDF documents through a two-strategy fusion approach: "QR code semantic verification + black pixel structure detection." QR code recognition and black pixel detection complement each other; QR code recognition provides high-precision semantic verification, while black pixel detection provides rapid structural hints when the QR code is missing or unreadable, thereby improving overall recall and throughput. This method avoids time-consuming steps such as full-page OCR, making it particularly suitable for batch tasks with a large number of pages, significantly improving processing speed while maintaining accuracy.

[0004] In a first aspect, the present invention provides a method for rapid identification and extraction of invoice pages from PDF documents based on multi-strategy fusion, comprising the following steps:

[0005] S1. Parallelize the inspection of each page in the PDF document, extract all embedded image resources on the page, and form an image queue for each page;

[0006] S2. For the image queue obtained in step S1, apply the QR code recognition strategy to identify the images in sequence, attempt to decode them and determine the invoice in a semantic verification manner; if the determination is successful, determine that the page is the invoice page, and stop the recognition of the image queue.

[0007] S3. For the image queue that failed to be identified in step S2, apply a black pixel detection strategy to detect the images in sequence; the specific steps include:

[0008] S31. Filter by size to exclude images that are unlikely to be QR codes;

[0009] S32. Extract the square candidate region image from the top left corner of the image;

[0010] S33. Convert the candidate region image into a grayscale image, then perform black-and-white binarization on each pixel, and count the proportion of black pixels. If the proportion is greater than the proportion threshold, the candidate region image is determined to be a QR code.

[0011] S34. When an image is identified as a QR code, the page corresponding to its image queue is marked as an invoice page, and the detection of that image queue is stopped.

[0012] S4. Based on the results of steps S2 and S3, extract and save the invoice pages and non-invoice pages respectively, and output the extraction result report.

[0013] As a further improvement of the present invention, the specific steps of step S1 include:

[0014] A parallel processing mechanism is used to analyze multiple pages simultaneously;

[0015] For each page, iterate through the page object, find and retrieve all image resources within it;

[0016] The image resources include the complete image of the invoice, as well as images that are components of the invoice.

[0017] As a further improvement of the present invention, the specific steps of step S2 include:

[0018] S21. For each image in the image queue, a QR code recognition strategy is applied for decoding;

[0019] S22. If the decoding is successful in step S21, determine whether the corresponding QR code is an invoice QR code according to the invoice coding rules.

[0020] S23. If the parsing result of step S22 is an invoice QR code, mark the current page as the invoice page, and do not check this page in subsequent steps.

[0021] As a further improvement of the present invention, the invoice coding rules include:

[0022] The invoice code is a comma-separated segmented string. The first field is 01, and the second field uses different codes to represent different invoice types. For example, 31 represents an electronic VAT special invoice, and 32 represents an ordinary invoice.

[0023] As a further improvement of the present invention, the screening method in step S31 is to exclude images with a width or height of less than 275 pixels.

[0024] As a further improvement of the present invention, in step S32, the method for determining the side length of the candidate region is to take the minimum value between 1 / 8 of the page width and the set upper limit value.

[0025] As a further improvement of the present invention, the upper limit value is 300 pixels.

[0026] As a further improvement of the present invention, the specific method of black-and-white binarization conversion in step S33 is as follows: in a grayscale image with a grayscale range of 0-255, pixels with a grayscale value less than 50 are marked as 1, which is considered as black pixels; pixels with a grayscale value greater than 50 are marked as 0, which is considered as white pixels.

[0027] As a further improvement of the present invention, in step S33, the percentage threshold is an empirical value: 0.1.

[0028] As a further improvement of the present invention, in step S4, when extracting and saving the invoice page, the page width is filtered: pages whose width exceeds 1.2 times the width of the document's first page are identified as verification pages and converted into non-invoice pages.

[0029] As a further improvement of the present invention, in step S4, the extraction result report includes the corresponding page number of the invoice page, as well as the invoice-related information extracted in step S2.

[0030] In a second aspect, the present invention provides a computer device including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the first aspect.

[0031] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect.

[0032] Fourthly, the present invention provides a computer program product that, when executed by a processor, implements the steps of the method described in the first aspect.

[0033] Compared with the prior art, the present invention has the following technical effects:

[0034] Speed: Avoid full-page OCR and complex layout understanding, prioritize lightweight visual operators and QR code semantic verification to achieve high throughput;

[0035] Robustness: Even when the QR code is missing, blurry, or unreadable, reliable prompts can still be provided through the black pixel structure features, improving the overall recall rate;

[0036] Scalability: Parameter thresholds (candidate region size, grayscale threshold, ratio threshold, etc.) can be adapted or configured according to different source documents, and are compatible with various scan qualities and layouts. Attached Figure Description

[0037] Figure 1 This is a flowchart of a method for rapid identification and extraction of invoice pages in PDF documents based on multi-strategy fusion, as disclosed in this invention.

[0038] Figures 2-5 The document page processed in Example 1 and the processing process images are shown.

[0039] Figures 6-11 The document page processed in Example 2 and the processing process images are shown.

[0040] Figures 2-11 The content involving QR codes, organization names, and identity information has been obscured or labeled. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Steps S1, S2… in the described embodiments of the present invention do not limit the scope of execution of the present invention; the various models, simulation environments, and software described in the present invention are not considered as the only limiting methods of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0042] In this invention, computer device / equipment / system refers to a related entity applied to a computer, such as hardware, a combination of hardware and software, software, or software in execution. More specifically, for example, software includes, but is not limited to, a process running on a processor, a processor, an object, executable software, an execution thread, a program, and / or a computer. Furthermore, an application program or script running on a server, and the server itself, can also be software. One or more software programs may be in an execution process and / or thread, and the software may be localized on one computer and / or distributed across two or more computers, and may be run on various computer-readable media.

[0043] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.

[0044] In a first aspect, the present invention provides an embodiment of a method for rapid identification and extraction of invoice pages from PDF documents based on multi-strategy fusion, such as... Figure 1 As shown, the specific process can be as follows:

[0045] S1. Parallelize the inspection of each page in the PDF document, extract the embedded image resources in the page, and form an image queue for each page.

[0046] Specifically:

[0047] For PDF documents, a parallel processing mechanism is used to analyze multiple pages simultaneously. For each page, the page objects are traversed to find and retrieve all image resources in the document.

[0048] This step can handle different types of PDF documents, and the different types of image resources obtained from them will be processed uniformly in subsequent steps. Specifically, for native invoice PDFs, the image resources extracted in this step will include images of QR codes, seals, and other elements that make up the invoice; for PDF files with embedded invoice images, this step will extract the entire invoice image.

[0049] This step obtains image resources by directly extracting embedded images from the page, avoiding the need to render the entire page as a bitmap before detection. This reduces data movement and rendering overhead, thereby improving overall recognition speed. Simultaneously, parallel processing significantly shortens the overall processing time for multi-page PDF documents.

[0050] S2. Apply a QR code recognition strategy to the extracted image queue, attempt to decode it, and determine the page as an invoice page using semantic verification. This includes the following steps:

[0051] S21. For the image queue extracted in step S1, a QR code recognition strategy is applied to decode each image in turn.

[0052] S22. If the decoding is successful in step S21, further analyze the decoded text content according to the invoice encoding rules, and check whether it contains information unique to invoices and associated with the electronic invoice QR code, thereby determining whether the corresponding QR code is an invoice QR code.

[0053] Specifically, the invoice QR code is decoded, and the resulting comma-separated segmented strings are parsed according to the segmented encoding rules of the invoice code:

[0054] (1) The first field is fixed as “01”;

[0055] (2) Different numbers in the second field (i.e. the type field) represent different types of invoices: for example, “31” represents an electronic VAT special invoice and “32” represents an ordinary invoice.

[0056] When a string meets the above rules, the corresponding QR code is an invoice QR code.

[0057] S23. If the parsing result of step S22 is an invoice QR code, mark the current page as "invoice page", stop recognizing the image queue, and do not detect the page again in subsequent steps.

[0058] S3. For pages that have been identified in step S2 but not marked as invoice pages, apply a black pixel detection strategy to the images on the pages and determine whether they are invoices by analyzing the color features of the images.

[0059] As a supplementary recognition method, a black pixel detection strategy is used to identify whether specific locations on an invoice contain a distribution of black pixels that match the characteristics of a QR code. Since QR codes are typically composed of black and white pixels, if the proportion of black pixels exceeds a certain threshold, there is a high probability that the image is a QR code. Without requiring OCR, this strategy effectively covers scanned copies of paper invoices where QR codes cannot be properly recognized.

[0060] The specific steps include:

[0061] S31. Filter images by size to exclude those that cannot be QR codes;

[0062] Specifically, after filtering out images with a width or height of less than 275 pixels, the following steps are performed on the remaining images.

[0063] Statistical verification during the development of this method showed that when the width or height of an image is less than 275 pixels, the image cannot contain sufficient information and therefore cannot be an invoice QR code. This step excludes these images to avoid misjudgment in subsequent black pixel detection.

[0064] S32. According to the set rules, extract the square candidate region in the upper left corner of the image.

[0065] Preferably, the method for determining the side length of the candidate region is to take the minimum value between 1 / 8 of the page width and a set upper limit value.

[0066] Preferably, the upper limit is set to 300 pixels.

[0067] S33. Convert the candidate region image to a grayscale image, then perform black-and-white binarization on each pixel, then count the number of black pixels, calculate the proportion of black pixels in the total number of pixels in the candidate region image, and compare it with a preset proportion threshold. When the proportion of black pixels is greater than the proportion threshold, the candidate region image is determined to be a QR code.

[0068] Preferably, the specific method for black-and-white binarization is as follows: In a grayscale image, the grayscale value of white is 255, and the grayscale value of black is 0. This method uses a threshold of 50 for inverse binarization, that is, pixels with a grayscale value less than 50 are marked as 1 (i.e., counted as black pixels), and pixels with a grayscale value greater than 50 are marked as 0 (i.e., counted as white pixels).

[0069] Note: The grayscale threshold of 50 set here is a tolerance scale to ensure that pixels with non-zero grayscale values ​​due to errors in image conversion or grayscale recognition are not missed during the process of judging and counting black pixels.

[0070] Preferably, the threshold for the proportion of black pixels is 0.1. This threshold is an empirical value obtained through multiple experiments, adjustments, and statistical analyses during the development of this method.

[0071] S34. In step S33, if the candidate region image is determined to be a QR code, mark the current page as "invoice page" and stop the detection of the image queue.

[0072] S4. Based on the dual-strategy recognition results of steps S2 and S3, comprehensively determine whether the current page is an invoice page, and summarize and extract all recognized invoice pages. Specifically:

[0073] S41. After completing the dual-strategy recognition steps S2 and S3 on all pages of the PDF, extract and save the invoice pages and non-invoice pages respectively.

[0074] Preferably, when saving the invoice page, width filtering is applied to the invoice verification page to further exclude non-invoice content. Specifically, pages whose width exceeds 1.2 times the width of the document's first page are identified as verification pages and converted to non-invoice pages.

[0075] S42. Summarize the corresponding page numbers of the invoice pages and the invoice-related information extracted through the QR code strategy, and output an extraction result report.

[0076] The report generated in this step lists all invoices and their key information contained in the PDF document, completing the task of quickly identifying and extracting information from the invoice pages.

[0077] In a second aspect, the present invention provides an embodiment of a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the first aspect.

[0078] Thirdly, the present invention provides an embodiment of a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect.

[0079] Fourthly, the present invention provides a computer program product embodiment, which, when executed by a processor, implements the steps of the method described in the first aspect.

[0080] Example 1: For example Figure 2 The page shown is for invoice recognition.

[0081] S1. Image Extraction. The invoice image on this page is a single, continuous image. Therefore, when extracting the image from this page, the result is as follows: Figure 3 The image shown is of the entire invoice.

[0082] S2, QR code recognition. (For...) Figure 3 QR code recognition failed, proceed to step S3.

[0083] S3, black pixel recognition.

[0084] S31. Exclude non-QR code images. Figure 3 The width and height are both greater than 275 pixels, so it was not excluded;

[0085] S32, to Figure 3 Cropping the top-left corner into a square candidate region with a side length of min(weight / 8, 300) yields... Figure 4 .

[0086] S33, will Figure 4 Convert to grayscale image, obtain Figure 5 .

[0087] right Figure 5 The proportion of black pixels (i.e., pixels with a grayscale value less than 50) was calculated, and the result was 0.1647, which is greater than the threshold of 0.1. Therefore, it was determined that... Figure 5 It is a QR code.

[0088] S34. Judgment Figure 5 Source Figure 3 The page in question, i.e. Figure 2 The page shown is the invoice page.

[0089] S4, will Figure 2 Save as an invoice page.

[0090] Example 2: For example Figure 6 The two pages shown are used for invoice recognition.

[0091] S1, Image Extraction. Figure 6 On the first page, the invoice is a raw PDF invoice. Therefore, when extracting images from this page, we get... Figure 7 , Figure 8 , Figure 9 Three pictures; from Figure 6 Extract from the second page Figure 10.

[0092] S2-S3, QR code recognition and black pixel detection.

[0093] (1) To Figure 7 , Figure 8 QR code recognition failed; switching to black pixel detection.

[0094] Before detecting black pixels, images that are not QR codes are first filtered by image size: Figure 7 , Figure 8 The dimensions of all images are 354x236 pixels. Because the height of 236 is less than the threshold of 275, they are judged to be non-QR code images, and therefore no black pixel detection is performed.

[0095] (2) To Figure 9 The QR code is recognized to obtain the string information:

[0096] ['01', '32', '', '25327000000437492235', '693.51', '20250507', '', 'FD77'];

[0097] Then, based on the invoice coding rules, the QR code is analyzed to determine that it is an invoice QR code.

[0098] (3) To Figure 10 QR code recognition failed, so the process switched to black pixel detection.

[0099] The image's width and height are both greater than 275 pixels, and it was not excluded by the size filter. Therefore, it proceeds to the detection step.

[0100] Cut Figure 10 The candidate region with a length of min(weight / 8, 300) in the upper left corner is converted into a grayscale image. Figure 11 Then, the pixels are binarized, and pixels with a gray level less than 50 are treated as black pixels. The proportion of black pixels is 0.0327, which is less than the threshold of 0.1. Therefore, the candidate region image is determined to be not a QR code, and the corresponding page is determined to be not an invoice page.

[0101] It should be noted that: Figure 11 It contains a large proportion of dark areas (derived from blue areas in the original image through grayscale conversion), and the grayscale value of these areas is not less than 50. Under the threshold condition of 50, they are not judged as black.

[0102] S4. Extract and save the invoice page, invoice information, and non-invoice pages separately.

[0103] During the process of saving the invoice pages, pages whose width exceeds 1.2 times the width of the document's first page are identified as verification pages and converted to non-invoice pages.

[0104] It should be noted that: Figure 10 This is the invoice verification page, and its width must be no less than 1.2 times the width of the invoice page, but... Figure 10 It has already been identified as a non-invoice page in the black pixel detection, so it does not need to go through the page width filtering here.

[0105] This invention proposes a method for rapid identification and extraction of invoice pages in PDF documents based on multi-strategy fusion. The time complexity of the method increases linearly with the number of pages and the number of images per page. Furthermore, since it avoids full-page OCR and complex layout analysis, it is suitable for rapid batch processing of large PDF documents with many pages.

Claims

1. A method for rapid identification and extraction of invoice pages from PDF documents based on multi-strategy fusion, characterized in that, Includes the following steps: S1. Parallelize the inspection of each page in the PDF document, extract all embedded image resources on the page, and form an image queue for each page; S2. For the image queue obtained in step S1, apply the QR code recognition strategy to identify the images in sequence, attempt to decode them and determine the invoice in a semantic verification manner; if the determination is successful, determine that the page is the invoice page, and stop the recognition of the image queue. S3. For the image queue that failed to be identified in step S2, apply the black pixel detection strategy to detect the images in sequence. The specific steps include: S31. Filter by size to exclude images that are unlikely to be QR codes; S32. Extract the square candidate region image from the top left corner of the image; S33. Convert the candidate region image into a grayscale image, then perform black-and-white binarization on each pixel, and count the proportion of black pixels. If the proportion is greater than the proportion threshold, the candidate region image is determined to be a QR code. S34. When an image is identified as a QR code, the page corresponding to its image queue is marked as an invoice page, and the detection of that image queue is stopped. S4. Based on the results of steps S2 and S3, extract and save the invoice pages and non-invoice pages respectively, and output the extraction result report.

2. The method according to claim 1, characterized in that, The specific steps of step S1 include: A parallel processing mechanism is used to analyze multiple pages simultaneously; For each page, image resources are found and obtained by traversing the page object; The image resources include the complete image of the invoice, as well as images that are components of the invoice.

3. The method according to claim 1, characterized in that, The specific steps of step S2 include: S21. For each image in the image queue, a QR code recognition strategy is applied for decoding; S22. If the decoding is successful in step S21, determine whether the corresponding QR code is an invoice QR code according to the invoice coding rules. S23. If the parsing result of step S22 is an invoice QR code, mark the current page as the invoice page, and no longer check this page in subsequent steps.

4. The method according to claim 3, characterized in that, The invoice coding rules include: The invoice code is a comma-separated segmented string. The first field is 01, and the second field uses different codes to represent different invoice types. For example, 31 represents an electronic VAT special invoice, and 32 represents a general invoice.

5. The method according to claim 1, characterized in that, The filtering method in step S31 is to exclude images with a width or height of less than 275 pixels.

6. The method according to claim 1, characterized in that, In step S32, the method for determining the side length of the candidate region is to take the minimum value between 1 / 8 of the page width and the set upper limit value.

7. The method according to claim 6, characterized in that, The upper limit is 300 pixels.

8. The method according to claim 1, characterized in that, In step S33, the specific method for black-and-white binarization conversion is as follows: in a grayscale image with a grayscale range of 0-255, pixels with a grayscale value less than 50 are marked as 1, which is considered as black pixels; pixels with a grayscale value greater than 50 are marked as 0, which is considered as white pixels.

9. The method according to claim 1, characterized in that, In step S33, the percentage threshold is an empirical value: 0.

1.

10. The method according to claim 1, characterized in that, In step S4, when extracting and saving the invoice page, the page width is filtered: pages whose width exceeds 1.2 times the width of the document's first page are identified as verification pages and converted to non-invoice pages.

11. The method according to claim 1, characterized in that, In step S4, the extraction result report includes the corresponding page number of the invoice page, as well as the invoice-related information extracted in step S2.

12. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-11.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the method described in any one of claims 1-11.

14. A computer program product, characterized in that, When executed by a processor, the computer program implements the steps of the method described in any one of claims 1-11.

Citation Information

Patent Citations

  • Method and system for achieving intelligent bus stop board

    CN103106410A

  • Method and a system for filling vehicle tires with pressurized air

    EP3944995A1