Code Monkey home page Code Monkey logo

Comments (10)

AuditeMarlow avatar AuditeMarlow commented on May 28, 2024 2

You loop through the PDF pages to save each page individually.

for ($i = 1; $i <= $pdf->getNumberOfPages(); $i++) {
    $pdf->setPage($i)->setOutputFormat('png')->saveImage('path/to/image.png');
}

You can in turn also decide yourself what page number you want to save.

$i = 1;
$pdf->setPage($i)->setOutputFormat('png')->saveImage('path/to/image.png');

from pdf-to-image.

BenjaminRehn avatar BenjaminRehn commented on May 28, 2024 1

Try this ;-)
#13

from pdf-to-image.

freekmurze avatar freekmurze commented on May 28, 2024

Probably something to do with transparency yes...

I'd accept a PR that fixes this.

from pdf-to-image.

AuditeMarlow avatar AuditeMarlow commented on May 28, 2024

Figured this happens when the PDF has multiple pages and you try to save it without looping through the pages.

from pdf-to-image.

adilsaeed31 avatar adilsaeed31 commented on May 28, 2024

HI,

Yes I'm facing the same issue i have multiple pages pdf file, when i convert it, it give me black background instead of white, any solution so far ?

Thanks
Adil

from pdf-to-image.

adilsaeed31 avatar adilsaeed31 commented on May 28, 2024

Thanks for this, that i have already did, but can't save single image with all pages images is there any way for this.

Thanks for your help so far.

from pdf-to-image.

BenjaminRehn avatar BenjaminRehn commented on May 28, 2024

i did a short look, and as i can see Imagick is used, try to use
flattenImages(); that should do the trick

from pdf-to-image.

BenjaminRehn avatar BenjaminRehn commented on May 28, 2024

flattenImages() was just removed as i can see, now it's
$image->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN);

from pdf-to-image.

piarson avatar piarson commented on May 28, 2024

Same issue persists (transparent background) when trying to save as PNG

was able to fix by forcing this:
Pdf.php:

public function getImageData($pathToImage) {
...
$imagick->transparentPaintImage('#FFFFFF',1,1, 'normal'); // added this
$imagick->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN);
...
}

fyi: http://phpimagick.com/Imagick/transparentPaintImage

from pdf-to-image.

freekmurze avatar freekmurze commented on May 28, 2024

Closing this for now, I accept PR's that make this package more stable.

from pdf-to-image.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.