Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Location
    Oklahoma
    Posts
    249
    Thanks
    11
    Thanked 13 Times in 13 Posts

    form fields to gif

    I'm working on a personal project that came to me while needing a scanner to scan documents that i needed to email to banks or other places.

    I needed to email a copy of my paystub to a loan office which isn't local, and I don't have a scanner so I ended up recreating the paystub in Word, then taking a screenshot.

    What I want to make is a php generator where you would enter your info in the form and it generates a jpg of your paystub for download. It would not save any info or images on the server.

    The only thing I have worked on before was a contact form, I don't know how to make it generate an image. Can someone help me with the php code to make a jpg from form field contents?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,466
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    It can be done easily with PHP GD, but I question the legality of it.
    They want an actual paystub (or actual copy). Simply generating a fake
    one using PHP would seem like an illegal thing to do. A person could make
    a fake paystub with anyone's name on it. I don't think a bank would find
    that acceptable.

    But to answer your question, for other things, you need to start with a "blank"
    JPEG image. An image of a paystub, ticket, etc. that has no words on it.
    PHP would then place the words on it with any font and color you want. The
    final image is ONE image, that can be JPEG, PNG, or GIF with the text on it.

    Look up on Google: PHP GD text on image


    .

  • #3
    Regular Coder
    Join Date
    Sep 2008
    Location
    Oklahoma
    Posts
    249
    Thanks
    11
    Thanked 13 Times in 13 Posts
    i want this as an offline only personal project. and, all they want is a copy of the paystub, so if i only use it to make copies of my actual paystubs to use, as long as all the info is the same it would still be legal to do.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,466
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Well, to use PHP, you have to either have your own server, or run it on a webhost.
    Display a blank JPEG image of a paystub, and I'll show you some PHP scripting for it.

  • #5
    Regular Coder
    Join Date
    Sep 2008
    Location
    Oklahoma
    Posts
    249
    Thanks
    11
    Thanked 13 Times in 13 Posts
    here is a template, and a blank one
    Attached Thumbnails Attached Thumbnails form fields to gif-paystub-template-blank.jpg   form fields to gif-paystub-template.jpg  

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,466
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I was able to come up with a simple test example:
    http://www.catpin.com/paystub/index.php

    It puts in some default text just for the name and address.
    Scroll down that screen for a form, to enter your own name.

    You have a lot of data, so you should be populating the image
    using a database or text file (not a form) ... as you have a ton of numbers.

    I only did this much ... you get the idea.
    You have to provide the JPEG and .ttf file in your directory.
    You can use any font you choose (just provide the .ttf file).

    Here is the index.php page:
    PHP Code:
    <?php

    $user
    ="John Doe";
    if(
    $_POST['pname']){
    $pname=$_POST['pname'];
    }
    $paddress="1234 W. Elm St.";
    if(
    $_POST['paddress']){
    $paddress=$_POST['paddress'];
    }
    $pstate="St. Paul, MN  55101";
    if(
    $_POST['pstate']){
    $pstate=$_POST['pstate'];
    }
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
      <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>Paystub Test</title>
       </head>
      <body>
    <center>
      <br /><br />
    <img src="print.php?pname=<?=$pname?>&paddress=<?=$paddress?>&pstate=<?=$pstate?>" alt="" />
    <br /><br />
    <form action="index.php" method="post">
    Name: <input type="text" name="pname" value="John Doe"><br />
    Address: <input type="text" name="paddress" value="1234 W. Elm St."><br />
    State Zip: <input type="text" name="pstate" value="St. Paul, MN  55101"><br />
    <input type="submit" name="submit" value="Display Graphic">
    </form>
    </center>
      </body>
    </html>
    Here is the "print.php" file:
    PHP Code:
    <?php 
    // Paystub Sample - Generator 

    // Get form variables
    $pname $_GET['pname'];
    $paddress $_GET['paddress']; 
    $pstate $_GET['pstate'];

    // Generate Image & set width 
    $image imagecreatefromjpeg("paystubtemplateblank.jpg"); 
    $imageWidth imagesx($image); 

    // Generate Main Name 
    $color imagecolorallocate($image000); 
    $font "arial.ttf"
    $fontSize "11";

    // This is the coordinates for each text string ... in this case: 80=left, 92=top  
    imagettftext($image$fontSize08092$color$font$pname); 

    // Generate Name Section 
    $color imagecolorallocate($image000); 
    $font "arial.ttf"
    $fontSize "10";
    imagettftext($image$fontSize050150$color$font$pname); 
    imagettftext($image$fontSize050165$color$font$paddress);
    imagettftext($image$fontSize050180$color$font$pstate);

    // Output & Free Memory 
    header("Content-type: image/jpeg"); 
    imagejpeg($image); 
    imagedestroy($image); 
    ?>

  • Users who have thanked mlseim for this post:

    owt200x (03-16-2010)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •