Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kalantari's avatar

iconv error on dompdf package using Vapor

Hi all! Our team has started using https://github.com/barryvdh/laravel-dompdf package for generating pdfs, and everything seems to work fine on our local environments, but on our server , which we are using Vapor for , we are getting the following error: iconv(): Wrong encoding, conversion from "UTF-8" to "UTF-8//IGNORE" is not allowed\n Based on this issue on dompdf repository it seems like there is a bug using dompdf via vapor: https://github.com/barryvdh/laravel-dompdf/issues/830

I was wondering if anyone has faced this issue before and has any workaround or solution for it, since we need to generate our pdfs from backend and our options are limited. Thank you in advance

0 likes
2 replies
JoeriTP's avatar
JoeriTP
Best Answer
Level 1

Hi, we faced the same issue (about a month ago) when switching to laravel vapor.

We're still on Laravel 7.x and PHP 7.4.x running in an Alpine Linux 3.14 container, so bear in mind that this might not fix your issue. Hopefully it's of some help though (and save you some headaches).

This is our dockerfile:

# This is based on Alpine Linux 3.14
FROM laravelphp/vapor:php74

# Fixes pdf rendering for alpine 3.14
# https://github.com/docker-library/php/issues/1121 -> answer litan1106 26 jul
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ gnu-libiconv=1.15-r3
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

# Make sure exif is installed and enabled for image processing
# https://github.com/docker-library/php/issues/362
RUN docker-php-ext-install exif

# Copied from base vapor Dockerfile
COPY . /var/task
1 like

Please or to participate in this conversation.