I need to read a pdf file on Travis with php-imagick extension.
I learned i need to adjust imagick policy.xml file to allow imagick to read pdf files. So i added a custom policy.xml.
env:
global:
- MAGICK_CONFIGURE_PATH=$HOME/.config/ImageMagick/
...
before_script:
# Allow imagemagick to read PDF files
- echo $MAGICK_CONFIGURE_PATH
- mkdir $MAGICK_CONFIGURE_PATH
- echo '<policymap>' > $MAGICK_CONFIGURE_PATH/policy.xml
- echo '<policy domain="coder" rights="read" pattern="PDF" />' >> $MAGICK_CONFIGURE_PATH/policy.xml
- echo '</policymap>' >> $MAGICK_CONFIGURE_PATH/policy.xml
- sudo rm /etc/ImageMagick-6/policy.xml
but still the build fails with [Failed to read the file]
The file is there, locally it works, i suspect that imagick still cant read PDFs. The new policy also seems to be applied:
$convert -list policy
Path: /home/travis/.config/ImageMagick/policy.xml
Policy: Coder
rights: Read
pattern: PDF
Policy: Coder
rights: Read
pattern: PDF
Path: [built-in]
Policy: Undefined
rights: None
How can i fix this?
Failed build is: https://travis-ci.org/ivoba/silverstripe-simple-pdf-preview/jobs/563919021
After a while i just answer my own question:
The problem was that imagemagick needs ghostscript for working with pdfs and ghostscript needs to be installed in Debian.
So additionally to editing the policy.xml file, adding the install command to .travis.yml did the trick.
sudo apt-get install -y ghostscript
Full working travis file is: https://github.com/ivoba/silverstripe-simple-pdf-preview/blob/master/.travis.yml