1

I can run Poppler to convert a PDF file to JPG with Node JS running on Windows 10 OS without any problems. The basic code is like this:

const { Poppler } = require('node-poppler');
app.get('/poppler', (req, res) => {
  const file = __dirname + '/res/8025.pdf';
  const poppler = new Poppler();
  const options = {
    firstPageToConvert: 1,
    lastPageToConvert: 1,
    jpegFile: true,
  };
  const outputFile = __dirname + '/res/8025';
  const result = poppler.pdfToCairo(options, file, outputFile).then((res) => {
    console.log(result);
  });
});

But the same code running on Google Cloud Functions produce an error poppler : Error: linux is NOT supported I guess it is because the Google Cloud Functions are running on an Ubuntu OS.

node-poppler NPM say :

Linux support:

Windows and OSX/Darwin binaries are provided with this repository. For Linux users, you will need to download the poppler-data and poppler-utils binaries separately.

An example of downloading the binaries on a Debian system:

sudo apt-get install poppler-data
sudo apt-get install poppler-utils

Once they have been installed, you will need to pass the poppler-utils installation directory in as parameters to an instance of the Poppler class:

const { Poppler } = require('node-poppler');
const poppler = new Poppler('./usr/bin');

I can use Windows WSL to run the Linux , I wonder how to deploy my function to Firebase with the required Linux files ? Any help will be appreciated.

I like Poppler and would like to use it with Google cloud Functions.

Pierre
  • 21
  • 3
  • you cannot write to file system in serverless products like Cloud Functions and that's why this package won't work as it needs some files written to the system. You can either use GCP compute engine for this in which you have access to the whole system or try other methods like the one described here https://stackoverflow.com/questions/43242998/cloud-functions-for-firebase-converting-pdf-to-image – Methkal Khalawi Oct 29 '20 at 10:55

0 Answers0