Skip to content
Advertisement

Convert PDF to PNG without transparent background

I use the following code to convert PDF to PNG. As you can see, I use code setImageAlphaChannel(Imagick::ALPHACHANNEL_REMOVE ) to remove the background transparency. But in practice it only works for the last page. Do you think there is a problem with the code? Do you have a better solution with a higher speed?

JavaScript

Advertisement

Answer

This looks like an iterator issue. You can try looping with something like this:

JavaScript

You could also get the iterating part down to a simple loop, if you like it more, since the Imagick class implements Iterator:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement