title: Convert png/jpeg to pdf 1.0 using ASCII85Encode and DCTEncode
body: <p>I have been asked to modify a php script (written ages ago and running on a server) that outputs complex pdf 1.0 files, so that png and jpeg images could be added to the layout.</p>
  <p>Since I don't have neither the time nor the budget to re-write that script with a pdf API, I thought I'd try to use Imagick to convert those images into pdf, and then insert the code in the pdf 1.0 files.
  The code is pretty straightforward :</p>
  <pre><code>$images = array('myfile.png');
  $pdf = new Imagick($images);
  $pdf-&gt;setImageFormat('pdf');
  $pdf-&gt;writeImages('myfile.pdf', true);
  </code></pre>
  <p>But the problem is that Imagick produces pdf 1.4 which makes it impossible to insert in the pdf 1.0.</p>
  <p>Ideally, the pdf 1.0 code for a jpeg should be as follows :</p>
  <pre><code>10 0 obj
  &lt;&lt;
  /Type /XObject
  /Subtype /Image
  /Name /I1 
  /Width 41 
  /Height 32 
  /BitsPerComponent 8 
  /ColorSpace /DeviceRGB
  /Length 11 0 R
  /Filter [ /ASCII85Decode /DCTDecode ]
  /DecodeParms [ null null ]
  &gt;&gt;
  stream
  s4IA&gt;!&quot;M;*Ddm8XA,lT0!!3,S!/(=^#mq&quot;I#n7=Q%MTB`&amp;/6#u'GM3&quot;-RKoP
  +!`0d0J+n0/M].F4Z&gt;5W3&amp;*K\5s[k-9he&gt;U6qpBM9he&gt;V9he=_%M''a&amp;JQQ-
  (+(jp/2T1X9gM'&gt;9he&gt;V9he&gt;V9he&gt;V9he&gt;V9he&gt;V9he&gt;V9he&gt;V9he&gt;V9he&gt;V
  9he&gt;V9he&gt;Vs1eUH#QPtI.0BS_!!3`5!tbS6_uZS4!!*6(!&lt;E3%!&lt;&lt;*&quot;z
  !rr?'&quot;9eu7#RLhG!&lt;&lt;-(!&lt;E3%!&lt;E0#z!!*'$!sAc3#7(VC$P3:=&quot;9AT+
  &quot;9J`2&quot;pbG9%:K8;!YGM;+VHL55uD&amp;(,&amp;r/h&quot;r*2nYsKZ\'iJKs1r43a6O+p#
  #ZK.?@rjLCiM,kJK-j!M&lt;+JG7U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UWO
  rrE)P~&gt;
  endstream
  endobj
  </code></pre>
  <p>So I thought I could encode straight the png/jpeg file using ASCII85Encode and DCTEncode to produce the code to encapsulate in pdf 1.0, but my php skills aren't good enough... So before I start some research, I'd like to know if it's the way to go. And I will appreciate any advice on that matter.</p>