Add a Barcode to PDFs Using Microsoft Flow and Muhimbi’s PDF Converter

Barcoding PDFs can make using them more efficient, not to mention easier to keep track of.  The Barcode can act as an identifier for the PDF and can make life easy for users, especially if they are working with an Inventory Management system or similar.

When talking with customers in the manufacturing industry, we got to know that they preferred to use machine-readable identifiers, like barcodes, so they could use scanning devices to automatically look up the record information the barcode referred to.

In this blog we will create a product Barcode (based on a SharePoint Choice column) and add that value as a Barcode to a PDF using Microsoft Flow and then e-mail the PDF to the address of our choice. This works equally well for files coming from different sources such as DropBox, OneDrive, or any other data source supported by Microsoft Flow (now known as Power Automate).

Before we begin, please make sure the following prerequisites are in place:

Now that we have all the prerequisites in place, lets get started with Part A: 

In the real world the barcode data can come from anywhere, in this example it comes from a ‘choice’ column which can be created as follows:

  • Navigate to the library you want to create a column in.
  • Select ‘+ Add column’ or ‘+’ to the right of the last column name at the top of the list or library.
  • In the dropdown menu, choose the type of column as “Choice”.
  • In the “Create a column panel”, type a title or column heading into the Name field, adding choices (while making sure the values are valid Code39 barcodes) and setting “Require that column contains information” to YES.

Part B: Create a Flow to Convert a document to PDF, add a Barcode on the First Page and send it as an email to the address of your choice.

From a high-level, our Flow will look like the following:

When a file is created or modified (properties only) 
+ Add 
If yes 
Term inate 
ACC • r 
null X 
If no 
Get file content 
Convert document 
Add Linear Barcode watermark 
Send email 

Step 1B: Open the MS Flow designer, create a flow and find the “When a file is created or modified (properties only)” trigger. Using this trigger will allow you to start the flow when adding or modifying a property of a file into a folder.

  • In the action, specify the path to the SharePoint Online Library to monitor for new items.

Step 2B:  As we don’t want the barcode to be added when the column is empty, add a condition block to the Flow Canvas and configure it with reference to the details below:

  • Choose Value: “Product Value” (value of the choice column) the output from the “When a file is created or modified (properties only)” action.
  • Condition: “is equal to “.
  • Value: null

Step 3B: If the condition evaluates to True (if yes) .

  • Add the “Terminate” action inside the “if yes” condition block and set the status to “Cancelled“.

Step 4B: If condition evaluates to false (if no).

Step 4.1B: Add the SharePoint “Get file content” action to the Flow Canvas and configure it with reference to the details below:

  • Site Address: Specify the path to the SharePoint Online site-collection which holds the file.
  • File Identifies: “Identifier” the output from the “When a file is created or modified (properties only)” action.

Step 4.2B: Add the Muhimbi “Convert document” action to the Flow Canvas and configure it with reference to the details below. If your source documents are already in PDF format then this step is naturally not needed.

  • Source File name: “File name with extension” the output from the “When a file is created or modified (properties only)” action.
  • Source file content: “File Content” the output of the “Get file content” action.
  • Output Format: PDF

Step 4.3B: This is where the real Magic happens. Add the Muhimbi “Add Linear Barcode Watermark” action to the Flow Canvas.

You can find more details about Muhimbi’s “Add Linear Barcode Watermark” action here.

Lets configure the action with reference to our requirements:

  • Source file content: “Processed File Content” the output of the “Convert document” action.
  • Barcode content: “Product Value” (value of the choice column)the output from the “When a file is created or modified (properties only)” action.
  • Barcode type: “Code39” for details on types of barcodes and choosing the correct barcode see this.
  • Position: Bottom Center.
  • Width: 200.
  • Height: 200.
  • Watermark start page: 1
  • Watermark end page: 1

All the other parameters are optional.

Step 4.4B: Use the “Send an email” Outlook action to send an email with attachment to the address of your choice. Naturally you can do whatever you want with the generated file, write it back to SharePoint, DropBox, Google Drive, etc.

  • To: Email address of your choice.
  • Subject: Subject of the email.
  • Body: Body for the email.
  • Attachment: “Base file name“.pdf  (output variable of the “Convert document” action.
  • Attachment Content: “Processed file content” (output variable of the “Add Linear Barcode Watermark ” action).
l!eua ue puos

That is it. Publish your Flow and upload a file (e.g. an MS-Word document) to the folder that is monitored by the configured SharePoint trigger. After a short wait, you can find the PDF document – including barcode – in the inbox of the email address specified in the Send email action.

Here is the final Watermarked PDF :

For more details about the various watermarking facilities in the Muhimbi PDF Converter, see this Knowledge base article.

In the next blog post we will add a Barcode the moment a document is opened in SharePoint Online using the Muhimbi real-time Watermark OnOpen facility.

Subscribe to this blog for the latest updates about SharePoint Online, Microsoft Flow, Power Apps and document conversion and manipulation.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s