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.
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 :
$images = array('myfile.png');
$pdf = new Imagick($images);
$pdf->setImageFormat('pdf');
$pdf->writeImages('myfile.pdf', true);
But the problem is that Imagick produces pdf 1.4 which makes it impossible to insert in the pdf 1.0.
Ideally, the pdf 1.0 code for a jpeg should be as follows :
10 0 obj
<<
/Type /XObject
/Subtype /Image
/Name /I1
/Width 41
/Height 32
/BitsPerComponent 8
/ColorSpace /DeviceRGB
/Length 11 0 R
/Filter [ /ASCII85Decode /DCTDecode ]
/DecodeParms [ null null ]
>>
stream
s4IA>!"M;*Ddm8XA,lT0!!3,S!/(=^#mq"I#n7=Q%MTB`&/6#u'GM3"-RKoP
+!`0d0J+n0/M].F4Z>5W3&*K\5s[k-9he>U6qpBM9he>V9he=_%M''a&JQQ-
(+(jp/2T1X9gM'>9he>V9he>V9he>V9he>V9he>V9he>V9he>V9he>V9he>V
9he>V9he>Vs1eUH#QPtI.0BS_!!3`5!tbS6_uZS4!!*6(!<E3%!<<*"z
!rr?'"9eu7#RLhG!<<-(!<E3%!<E0#z!!*'$!sAc3#7(VC$P3:="9AT+
"9J`2"pbG9%:K8;!YGM;+VHL55uD&(,&r/h"r*2nYsKZ\'iJKs1r43a6O+p#
#ZK.?@rjLCiM,kJK-j!M<+JG7UNAC1(t)FDAb*0\_p`bgo0t*lUkQ1@`73l?
V7":mjn2YdG(u<[[`6n\p,>KCB6T,tVmj^ukP$Aa86BPMLmY-NaOo_O#oP0P
8QfbQM4(?Rak>qS$5tBT8m5tUMOLQVb1c.W&HDk6!<NB,!sA`2#R1M<B)qu6
&Ha12&d1Kt@<!J)"YtXk'VVcu,Jd86d3S3jiGsO56W4_0F#50I(@e-)K*N_\
#f9!XP>n:nA49KVFCjJ&Z\66FFlW'_Pba#?Q,M25oVJt7e`HI)Ap/opVRFLq
k4U/]7os>ILR4pJa4KMK(aq@7=D2r8R&IO9f]`):)(@R;=_W/<RAma=g$/;>
)Cdd?>&&A@R]<sAg?SP7h#IQX"97'T$j-M1!YGMH!'^JNqTi0JV2B,5/+1D&
qY&K_UhL'P,TcprL_clM-<<$9%D*\4h-7C1%"o=_,sVFVoNUaa*h+di_3NU"
k;_r28P"/>FaZaaS@\$l[TWuQD%PouR$5i@aWmOL8La\eoR[)TFTj'NH!aTe
AZj,=2nPqt*do^$hu+mArd5r=d8#&f\R]0_p_c&NG>`4q?rq,4:FE\m52Uqh
4!#,@s3g/P5gS_5hq%As9&pS@O"I;X:G2YI4]AMl76M#^f!I<-!!E9]!AuC'
VuP6<Jj9rj!@9kjDc+-LB"+[[X5(pBaihl+BF!r_ge%#Xj\Di3%[A,;qE6u%
fIb'NU&P*d4&Y+u:G^pUG!a>cs4$9R?W?m12q$l3%[Pc';nn=4Di7ES1jFID
8p5n-4U*N5)0ki36cG<m2`8L_9hJBLrrE)Lms:m,VlA\bH_4e_g`59W[dO=i
:Q\$`;LD_cHqG>Q4`.4-E7P9q"XQ`9s46gqPfB/,VRG)T)d=9!=9&Ha&lUWO
rrE)P~>
endstream
endobj
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.
