Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot generate office document previews in Docker on a Mac #265

Open
dkobia opened this issue Aug 17, 2021 · 2 comments
Open

Cannot generate office document previews in Docker on a Mac #265

dkobia opened this issue Aug 17, 2021 · 2 comments
Labels

Comments

@dkobia
Copy link

dkobia commented Aug 17, 2021

Description and expectations

Office documents cannot generate inside Docker on a Mac.

Error:

Traceback (most recent call last):
  File "/usr/local/bin/preview", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/preview_generator/__main__.py", line 57, in main
    path_to_preview_image = manager.get_jpeg_preview(input_file)
  File "/usr/local/lib/python3.9/site-packages/preview_generator/manager.py", line 192, in get_jpeg_preview
    file_path = self.get_pdf_preview(file_path=file_path, file_ext=file_ext, force=force)
  File "/usr/local/lib/python3.9/site-packages/preview_generator/manager.py", line 237, in get_pdf_preview
    preview_context.builder.build_pdf_preview(
  File "/usr/local/lib/python3.9/site-packages/preview_generator/preview/builder/document_generic.py", line 104, in build_pdf_preview
    self._convert_to_pdf(
  File "/usr/local/lib/python3.9/site-packages/preview_generator/preview/builder/office__libreoffice.py", line 92, in _convert_to_pdf
    return self.convert_office_document_to_pdf(
  File "/usr/local/lib/python3.9/site-packages/preview_generator/preview/builder/office__libreoffice.py", line 208, in convert_office_document_to_pdf
    with open(output_filepath, "rb") as pdf_handle:
FileNotFoundError: [Errno 2] No such file or directory: './a9bca120677b36f7161818afd8d23b08.pdf'

Generated files:

# ls
a9bca120677b36f7161818afd8d23b08.lock  file-sample_100kB.doc  libreoffice.lock

How to reproduce

  • Create docker image e.g. with FROM python:3.9.6-slim-buster
  • Add all dependencies via apt-get and pip
  • Run and ssh into docker image:
    • $ wget https://file-examples-com.github.io/uploads/2017/02/file-sample_100kB.doc
    • $ preview *.doc

Version information

Version 0.23

@dkobia dkobia added the bug label Aug 17, 2021
@raphj
Copy link
Contributor

raphj commented Aug 20, 2021

Hello @dkobia and thank you for your report.

Does the same Dockerfile work on a Linux host? Can we have more details? (e.g. the Dockerfile used to build the container, the content of the preview command).

We also saw Mac users having not enough memory for libreoffice to successfully produce PDFs. For instance, see #234

@dkobia
Copy link
Author

dkobia commented Aug 20, 2021

@raphj -- I haven't tested on a linux host.

Dockerfile

FROM python:3.9.6-slim-buster

RUN apt update && apt install -y zlib1g-dev build-essential \
    openssl libssl-dev libcurl4-openssl-dev \
    libjpeg-dev python3-pythonmagick inkscape \
    xvfb poppler-utils libfile-mimeinfo-perl \
    qpdf libimage-exiftool-perl ffmpeg ghostscript \
    libsecret-1-0 libreoffice inkscape ufraw-batch \
    wget

COPY . /app
WORKDIR /app

RUN pip install -r requirements.txt

CMD python main.py

requirements.txt

boto3==1.18.22
preview-generator[all]==0.23

download sample doc file

$ wget https://file-examples-com.github.io/uploads/2017/02/file-sample_100kB.doc

run preview command

preview *.doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants