Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, June 30, 2017 4:06:47 PM(UTC)

Nick  
Nick

Groups: Registered, Tech Support, Administrators
Posts: 163

Was thanked: 9 time(s) in 9 post(s)

Sometimes, scanned documents are seperated into logical sections using patch pages. These patch pages are blank aside from a special type of barcode. The LEADTOOLS barcode SDK can recognize patch page codes and can subsequently be used to divide a PDF into multiple sections in memory. The code snippet below demonstrates this.

Code:

         BarcodeEngine engine = new BarcodeEngine();

         barcodeReader = engine.Reader;

         codecs.Options.Load.AllPages = true;
         RasterImage loadedImage = codecs.Load(@"Leadtools.pdf");
         List<RasterImage> docSections = new List<RasterImage>();

         // seed the initial documentSection with the first page of the document
         RasterImage img = loadedImage.Clone();

         // remove the first page since it's been seeded
         loadedImage.RemovePageAt(1);

         while (loadedImage.PageCount > 0)
         {
            BarcodeData[] data = barcodeReader.ReadBarcodes(rasterImage, Leadtools.Forms.LogicalRectangle.Empty, 0, new BarcodeSymbology[] { BarcodeSymbology.PatchCode });

	    bool isPatchPage = data.Length > 0;
	    
            // if we're on a patch page, finalize the current page range and begin a new one
            if (isPatchPage)
            {
               docSections.Add(img.CloneAll());

               loadedImage.RemovePageAt(1);
               img = loadedImage.Clone();

               loadedImage.RemovePageAt(1);
            }
            else // otherwise, add this page
            {
               img.AddPage(loadedImage);
            }
         }

         // add the lastly-created page
         docSections.Add(img);



This breaks the input document into a list of RasterImage objects, each RasterImage containing the page range between the patch pages. This can be modified to split documents by other parameters as well, such as different types of barcodes, detected characters via OCR, or anything else depending on development needs.

For more information, see our documentation on reading Barcodes.
https://www.leadtools.com/help/leadtools/v19m/dh/ba/barcodeengine.html
Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.035 seconds.