You can use the CLI action step in conjunction with the the Download step to perform advanced validations of PDF files such as number of lines and content.

Example code:

return pdf(fileBuffer).then((data) => {
  const {numpages, text} = data;
  // number of pages
  console.log("numpages", numpages);
  // PDF text
  console.log("text", text);
  if(numpages !== parseInt(expectedNumOfPages)) {
    return Promise.reject(new Error(`Invalid number of pages: ${numpages}`));
  }
  if(!text.includes(expectedText)) {
    return Promise.reject(new Error(`Invalid pdf text: ${text}`));
  }
});

Parameters - Packages and JavaScript used in this example:
  1. name: pdf, type: Package, value: pdf-parse@latest
  2. name: expectedNumOfPages, type: JavaScript, value: '2'
  3. name: expectedText, type: JavaScript, value: 'A Simple PDF File'

see screenshot:

Chrome browser requirements

This feature is supported in Chrome version 67 and above.
It requires a change to your Chrome browser settings:

  1. Open Chrome, go to Settings -> Advanced -> Privacy and security -> Content settings -> PDF documents  (you should also be able to copy this direct link and paste it to a Chrome window: chrome://settings/content/pdfDocuments)
  2. Enable the setting: 

Did this answer your question?