1
2Use this to convert all pages of a PDF to JPG:
3
4
5
6<?php
7
8$imagick = new Imagick();
9
10$imagick->readImage('myfile.pdf');
11
12$imagick->writeImages('converted.jpg', false);
13
14?>
15
16
17
18If you need better quality, try adding $imagick->setResolution(150, 150); before reading the file!
19
20
21
22If you experience transparency problems when converting PDF to JPEG (black background), try flattening your file:
23
24
25
26<?php
27
28$imagick = new Imagick();
29
30$imagick->readImage('myfile.pdf[0]');
31
32$imagick = $imagick->flattenImages();
33
34$imagick->writeFile('pageone.jpg');
35
36?>
37
38
39
40In order to read pages from a PDF-file use [PAGENUMBER] after the filename (pages start from zero!).
41
42
43
44Example: Read page #1 from test.pdf
45
46
47
48<?php
49
50$imagick = new Imagick();
51
52$imagick->readImage('test.pdf[0]');
53
54$imagick->writeImage('page_one.jpg');
55
56?>
57
58