collective / collective.documentviewer

https://pypi.org/project/collective.documentviewer
21 stars 22 forks source link

Converting documents fails #85

Open opeeters opened 3 years ago

opeeters commented 3 years ago

I'm getting the following error message when converting e.g. PDF's (on CentOS 7):

2021-02-01 17:16:20,597 WARNING [waitress.queue:115][MainThread] Task queue depth is 1
2021-02-01 17:16:52,310 INFO    [collective.documentviewer:101][waitress] Running command /usr/bin/md5sum /home/plone/some_website/var/blobstorage/0x00/0x00/0x00/0x00/0x00/0x00/0xba/0x5c/0x03dda2a7b2352000.blob
2021-02-01 17:16:52,354 INFO    [collective.documentviewer:120][waitress] Finished Running Command /usr/bin/md5sum /home/plone/some_website/var/blobstorage/0x00/0x00/0x00/0x00/0x00/0x00/0xba/0x5c/0x03dda2a7b2352000.blob
2021-02-01 17:16:52,376 ERROR   [collective.documentviewer:798][waitress] Error converting PDF:

Traceback (most recent call last):
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 266, in dump_images
    qpdf.strip_page(filepath, output_folder)
AttributeError: 'NoneType' object has no attribute 'strip_page'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 770, in __call__
    pages = self.run_conversion()
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 591, in run_conversion
    return sc.convert(self.storage_dir, **args)
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 493, in convert
    gm.dump_images(path, output_dir, sizes, format, language)
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 268, in dump_images
    raise Exception
Exception
Traceback (most recent call last):
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 266, in dump_images
    qpdf.strip_page(filepath, output_folder)
AttributeError: 'NoneType' object has no attribute 'strip_page'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 770, in __call__
    pages = self.run_conversion()
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 591, in run_conversion
    return sc.convert(self.storage_dir, **args)
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 493, in convert
    gm.dump_images(path, output_dir, sizes, format, language)
  File "/home/plone/.buildout/eggs/collective.documentviewer-6.0.0-py3.6.egg/collective/documentviewer/convert.py", line 268, in dump_images
    raise Exception
Exception
mauritsvanrees commented 3 years ago

This happens when calling qpdf.strip_page on this line. There qpdf is None, which is likely because qpdf is not installed. Or maybe it is installed, but something goes wrong when trying to open it in a subprocess, and this is misinterpreted. Can you try qpdf on the command line?

I am not sure if that can be installed with yum or with ruby/gem. There are CentOS instructions in this repo, but that is a document from 2012 and does not mention qpdf.

opeeters commented 3 years ago

qpdf was available via the cli.

Diving into my documentation I had installed qpdf like this:

curl -L -O https://github.com/qpdf/qpdf/releases/download/release-qpdf-10.0.1/qpdf-10.0.1.tar.gz
tar -xvf qpdf-10.0.1.tar.gz
cd qpdf-10.0.1
./configure --disable-crypto-openssl # solving compilation issue with --disable-crypto-openssl
make
make install

I also tried the yum-version of qpdf, but than you get version 5.0.1

Upgrading to qpdf 10.1.0 fixed it:

curl -L -O https://github.com/qpdf/qpdf/releases/download/release-qpdf-10.1.0/qpdf-10.1.0.tar.gz
tar -xvf qpdf-10.1.0.tar.gz
cd qpdf-10.1.0
./configure
make
make install

qpdf --version

Run buildout as your plone user after upgrading qpdf and restart the plone instance.