Best way to convert pdf to greyscale with php?

♀尐吖头ヾ 提交于 2019-12-08 09:37:05

问题


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.


回答1:


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();



回答2:


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



来源:https://stackoverflow.com/questions/5090397/best-way-to-convert-pdf-to-greyscale-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!