Split a PDF Document by Barcode or QR Code

August 23rd 2021
Back to all blogs

The Encodian connector provides several actions for you to be able to split PDF documents by barcode, QR code and text;

  • Split PDF – For splitting PDF documents based on page count, page arrays or bookmarks
  • Split PDF by Text – For splitting PDF documents based on text value or a regex expression
  • Split PDF by Barcode – For splitting PDF documents on barcode and QR code detection

In this post, we’ll explore an everyday use case for splitting combined scanned PDF documents using a contained ‘Page Break’ barcode using the Split PDF by Barcode action. The Encodian Split PDF by Barcode action can be used to split between any detected barcode or a specific barcode; for example, you could split up a collection of invoices into separate documents on detecting a QR code with a particular value.

Split PDF Document by Barcode – Scenario

We have a SharePoint library named ‘Incoming Documents‘, to which scanned and combined PDF documents are uploaded. We have another SharePoint library called ‘Processed Documents‘ where we need to add the separated PDF documents and, upon completion, delete the source document from the ‘Incoming Documents‘ library.

Split PDF Document by Barcode – Configuration

1. Create a new ‘Automated cloud flow‘ flow in Power Automate

1.a. Flow name: Provide a name for your flow

1.b. Trigger: Select the ‘When a file is created (properties only)‘ SharePoint trigger action

1.c. Click ‘Create

2. Configure the ‘When a file is created (properties only)‘ SharePoint trigger action as required

3. Add a condition action and configure to check whether the current document is a PDF document by evaluating the ‘Filename with Extension‘ property.

3.a. Input value: Select the ‘Filename with Extension‘ property provided by the ‘When a file is created (properties only)‘ SharePoint trigger action

3.b. Operator: Select the ‘ends with‘ operator

3.c Value: Enter ‘pdf

4. Within the ‘If No‘ branch, add a ‘Terminate‘ action

4.a. Status: Set to ‘Succeeded

Next

We will add logic to the flow to split the PDF document by the barcodes detected within the document and add each resulting file to the ‘Incoming Documents‘ SharePoint library.

5. Within the ‘If Yes‘ branch, add a SharePoint ‘Get File Content‘ action

5.a. Site Address: Set as per the trigger actions value

5.b: File Identifier: Select the ‘Identifier‘ property provided by the ‘When a file is created (properties only)‘ SharePoint trigger action

6. Add the Encodian Split PDF by Barcode action

6.a. Filename: Select the ‘File name with extension‘ property provided by the ‘When a file is created (properties only)‘ SharePoint trigger action

6.b. File Content: Select the ‘File Content‘ property provided by the ‘Get File Content’ SharePoint action

6.c. Barcode Value: Leave blank (Split on all detected barcode and QR codes)

6.d. Split Configuration: Select ‘All Instances

6.e. Split Action: Select ‘Remove‘ to remove the page containing the barcode from the resulting documents

7. Add the SharePoint ‘Create file‘ action

7.a. Site Address: Set as per the trigger actions value

7. b. Folder Path: Select the destination library, ‘Processed Documents‘ for this example

7.c. File Name: Select the ‘Documents Filename‘ property provided by the Encodian Split PDF by Barcode action

NOTE

Power Automate will automatically create an ‘Apply to each‘ loop and place the ‘Create file‘ action inside because the Encodian action returns an array of documents.

7.d. File Content: Select the ‘Documents File Content‘ property provided by the Encodian Split PDF by Barcode action

At this stage

The PDF document has been split and each resulting document added to the ‘Processed Documents‘ library; we now need to delete the original PDF document.

8. Underneath the ‘Apply to each‘ loop, add the SharePoint ‘Delete file‘ action

8.a. Site Address: Set as per the trigger actions value

8.b: File Identifier: Select the ‘Identifier‘ property provided by the ‘When a file is created (properties only)‘ SharePoint trigger action

The flow is now complete and should follow this construct:

You can now test your flow and validate that the document has been received, split by the Encodian action. The resulting files are added to SharePoint before deleting the accepted (source) document.

Processed documents added to SharePoint:

Final thoughts…

Hopefully, this post provides an excellent example of how you can utilise the Encodian Split PDF by Barcode action within Power Automate to automatically detect and split PDF documents by barcodes and QR codes.

We hope you’ve found this helpful guide; as ever, please share any feedback or comments; all are welcome!

Author
Jay Goodison

Managing Director

Back to all blogs

You might also be interested in...