Ian
Ian

Reputation: 755

Best way to convert pdf to greyscale with php?

If I want to convert a pdf to greyscale whats the best way to go about it. Im currently using tcpdf to convert html to pdf but I also need an option where I can convert it to greyscale. Whats the best way to go about doing this.

Upvotes: 0

Views: 3302

Answers (2)

Shikiryu
Shikiryu

Reputation: 10219

If you have Imagick (imagemagick) installed, you can take your generated PDF and save another gray-scaled one.

$image = new Imagick('generatedPDF.pdf');
$image->setColorspace(imagick::COLORSPACE_GRAY);
$image->writeImage('newPic.pdf');
$image->clear();
$image->destroy();

Upvotes: 4

TulieA
TulieA

Reputation: 71

I think the best way is to manipulate the HTML and images and make the HTML grayscale before converting to PDF.

You can run through all your images and pass them through GD to make them all gray http://php.about.com/od/gdlibrary/ss/grayscale_gd.htm

You will also need to probably create a separate css to use in case you have color applied to your page.

HTH

Upvotes: 0

Related Questions