cancel
Showing results for 
Search instead for 
Did you mean: 
stpuceli

Split pages from a document

Often you will get a large document with several pages in it that are separated with a blank page, barcode or a change to the type of page that will distinguish a logical break in the document.  This is common when you want to save storage space or put like documents together in a packet (mortgage applications, bundles of invoices, HR onboarding packets, health information etc.).

 

The newly released Custom Classification Model in Microsoft Forms Recognizer allows you to train a model on your documents to recognize the various portions of the document.  This makes it easy for you to then break apart the document into logical smaller documents and then use Microsoft Syntex to classify and extract metadata.

Process Overview

Here is a high-level overview of how to process the document and split the pages into smaller documents for processing.

1-Overview.png

Structure of a document

To understand how to split pages from a document, you need to understand the structure of your document and what portions you need to train the Custom Classification Model with.

Throughout this post I’ll use a standard invoice as my example.  The structure of the document will be:

  • 2-page invoice (pages 1-2)
  • Separator sheet (page 3)
  • 1 page invoice (page 4)

As you train the Classification model, you will need at least 5 sample documents for each document section you want to split the pages on and create it’s own document.

The end result is going to be 3 individual documents, a 2 page invoice, a separator sheet and a 1 page invoice.  All of these will be created in a destination document library.

Forms Recognizer Custom Classification Model

When creating a Custom Classification Model using Forms Recognizer Studio, the wizard will guide you through creating the appropriate configuration in your Azure portal.  Once Forms Recognizer has finished setting up your project, you will see the components in Azure.  This is where you’ll get the endpoint and key needed when we create the Power Automate workflow.

2-CreateProject.png

Labeling and training documents

Now that you have a project created, create the appropriate Document Types (Bar Code Separator and Invoice in the example below) and then upload 5 documents for each Document Type created.

 

3-TrainModel.png

Select the documents and associate them to the correct Document Type.  Once you have all the documents labeled, you can train the model.

 

Once the model is trained, test it using a sample document with the page sections corresponding to the document types and you will see the results on the right.  Also notice the Result tab, this is the JSON output that we’ll be using in Power Automate to split the documents.

 

4-TestModel.png

Power Automate Integration

Now that we have a trained model against the page sections in your document, we can use that in Power Automate against documents received in SharePoint.  The complete solution can be downloaded from GitHub.  I’ll walk through the critical actions and the configuration.

 

5-PowerAutomate.png

The highlighted areas indicate:

  • This is the name of the model in Forms Recognizer Studio that was trained. 
  • The key from Azure can be found in the resource group that was created by Forms Recognizer.

 

6-PowerAutomate.png

  • The initial request to Forms Recognizer will return a JSON file that contains the URL needed to retrieve the results once the document has been processed.  This is in the header of the response named “Operation-Location”.

7-AnalyzeResults.png

  • The delay activity gives Forms Recognizer time to process the document and return the JSON response.  30 seconds usually does it.
  • Finally retrieve the JSON response containing the results we can use to split the document. 
    • The yellow highlighted docType attribute indicates the document type Forms Recognizer classified it as based on how you trained the model.
    • The pageNumber represents the page in the document for the respective document type.

8-JSON.png

 

Logic configured in the Power Automate activities will evaluate each docType.  When a docType changes from “Invoice” to “Bar Code Separator”, we know to create a document that will contain a 2-page invoice starting on page 1 and ending on page 2.  This process repeats until all docType attributes have been evaluated.

 

Creating the new document

Once the Power Automate logic has determined that a new document needs to be created with the pages identified in the JSON file, I used the Split PDF action provided from Adobe to split the original file that was uploaded. 

9-SplitDocument.png

The resulting file is then saved to the final SharePoint library where a Microsoft Syntex model has been configured to classify and extract metadata from the file.

 

10-CreateFile.png

 

 

 

 

 

Comments
About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/