Dynamically creating a member ID card as pdf using PHP? -
I need a PHP script code which I need to generate a PDF file which is a member ID card (a credit Card to recognize yourself at a certain resolution).
Explain to me:
I have a basic form of card in PGG file format. A script will have to drop in the member's name and birthday with a serial. So far, no problem - there are so many good PHP libraries
My problem is to ensure that the resultant PDF (the generated image of the card, to be accurate) meets a certain resolution (preferably 300 dpi) That's right, so it's worth printing.
Any thoughts?
Edit
I solved it using TCPDF Library which lets you scale the images at a certain resolution.
Get it here:
Edit @ don
need_once (dirname (__ file __). '/ Tcpdf / config / Lang / eng.php '); Need_once (dirname (__ file __) '/ tcpdf / tcpdf.php'.); // Create new PDF document $ PDF = New TCPDF (PDF, Document, PDF, PDF, PDF, Data, UTF-8 ', Incorrect); // Set Document Information $ pdf- & gt; Setciter ('SO-young'); // default header / footer $ pdf- & gt; SetPrintHeader (wrong); $ Pdf- & gt; SetPrintFooter (wrong); // Set the default monospace font $ pdf- & gt; Set default mono-spaced font (pdf_phone_mnosacademy); // set margins $ pdf- & gt; Setgargin (PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); // set auto page $ pdf- & gt; SetAutoPageBreak (TRUE, PDF_MARGIN_BOTTOM) breaks; // set image scale factor $ pdf- & gt; SetImageScale (PDF_IMAGE_SCALE_RATIO); // set font $ pdf-> Setfont ('courier', '', 10); // Add a page $ pdf- & gt; AddPage (); // set JPEG quality $ pdf-> SetJPEG quality (100); $ Cred = & lt; & Lt; & Lt; EOT & lt; P & gt; & Lt; B & gt; {$ Userdata- & gt; First_name} {$ userdata-> Last_name} & lt; / B & gt; & Lt; Br / & gt; & Lt; Span style = "font-size: 80%;" & Gt; {$ Userdata- & gt; Geburtstag} & lt; / Span & gt; & Lt; / P & gt; EOT; $ Id = & lt; & Lt; & Lt; EOT & lt; Span style = "font-size: 60%;" & Gt; {$ Userdata- & gt; Club_id} & lt; / Span & gt; EOT; $ Pdf- & gt; Image (Dynom (__ file __). '/ Img / clubcard.jpg', 10, 10, 85.6, 53.98, empty, empty, empty, false, 300); $ Pdf- & gt; Write HTMLCell (60, 15, 50.5, 20.5, $ cred); $ Pdf- & gt; Write HTMLCell (50, 20, 77, 50.5, $ id); // Close and output pdf document $ pdf- & gt; Output ($ userdata-> File Name, 'F');
I will use for this purpose, as well as able to access it directly Php will be
Then you can take the original image, add some text to it, and do the output (or store) as a PDF:
$ Image = new emacs ($ filename); $ Draw = New ImagickDraw (); $ Draw & gt; SetFont ($ font); $ Draw & gt; SetFontSize ($ FONTSIZE); $ Image- & gt; Annotated image ($ draw, $ xpos, $ ypos, $ rotation, $ text); // dpi $ image- & gt; Set Image Resolutions (200,200);
I can not get the right code to output / quickly store it as PDF, but it should be documented on the ImageMagic site.
Comments
Post a Comment