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 10 of 10
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    55
    Thanks
    8
    Thanked 2 Times in 1 Post

    Exclamation PHP, MySQL & PDF's

    Ok, small problem here and I've been scouring the web trying to find a solution. I've found references to doing this but no real meat & potatoes answers. Anyways I have a form I created in Adobe LiveCycle, with this form I can submit and record data to a MySQL database, this works great. However the problem I am having is when it comes time to view a record I need to populate the form with the information to view/print or whatever. How do you do this? For arguments sake the reason I want to go with PDF forms over HTML is that I have quite a few forms I need to recreate and some of them are very large, it would save me a lot of time if I was able to use a pdf form over hand writing a bunch of HTML forms and then creating the view scripts in PHP/HTML and making sure they will print correctly. Hope this makes sense.

    Thanks!

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Posts
    271
    Thanks
    3
    Thanked 40 Times in 40 Posts
    I haven't been able to find a way just using php to do this. I use coldfusion for it. If you have access to it I can show you my code.
    If you can't stand behind your troops, feel free to stand in front of them
    Semper Fidelis

  • #3
    New Coder
    Join Date
    Nov 2004
    Posts
    55
    Thanks
    8
    Thanked 2 Times in 1 Post
    I am unfamiliar with ColdFusion, I do know my current host hostgator.com doesn't support it but I'd be willing to change to another one if this would solve my problem, looks like hostek.com has reasonable rates.

  • #4
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    This doesn't quite make sense to me. You would normally use PHP to construct a page which displays all the information, with the information itself being returned from the database. So, there is only one page but its data changes when the page is requested.

    You could use PHP to create or modify a PDF and then forward this to the browser. The browser will normally either offer to download the pdf (and save it) or open it in an in-browser pdf-viewer.

    There are a number of PHP-PDF libraries that enable you to create or modify pdfs.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #5
    New Coder
    Join Date
    Nov 2004
    Posts
    55
    Thanks
    8
    Thanked 2 Times in 1 Post
    Quote Originally Posted by AndrewGSW View Post
    This doesn't quite make sense to me. You would normally use PHP to construct a page which displays all the information, with the information itself being returned from the database. So, there is only one page but its data changes when the page is requested.

    You could use PHP to create or modify a PDF and then forward this to the browser. The browser will normally either offer to download the pdf (and save it) or open it in an in-browser pdf-viewer.

    There are a number of PHP-PDF libraries that enable you to create or modify pdfs.
    The reason I want to stick to using PDF forms is just the shear amount and size of the forms I have to recreate, I could go through and recreate all of these in HTML if I have too, I would just rather not. Instead of coding out the form then making the processing scripts for viewing and posting and such I figured if possible, I could redo the forms in LiveCycle, which is pretty much just drag and drop, then save the information to the database from that form and then somehow pull the database information back out and put it in the form using php or possibly some other language. If it's not possible I will have to go this route I guess, not fun but I may have to do it.

  • #6
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    I don't know about LiveCycle but it's an Adobe product and it seems then can create PDF forms that are viewable in a browser, according to this.

    A terrible hack would be to save a pdf as an image, set it as the background to a div, and use absolutely positioned form-elements to sit above it
    Attached Thumbnails Attached Thumbnails PHP, MySQL & PDF's-adobepdf.jpg  
    Last edited by AndrewGSW; 01-19-2013 at 07:49 PM.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #7
    Regular Coder
    Join Date
    Jul 2010
    Posts
    271
    Thanks
    3
    Thanked 40 Times in 40 Posts
    If you use pdf's alot Coldfusion is an Adobe product and has some great interactivity in creating pdfs
    Code:
    <cfparam name="URL.access" default="0">
    <cfquery name="get_admin" datasource="#request.dsn#">
    SELECT * FROM admin WHERE uuid = '#URL.access#' LIMIT 1
    </cfquery>
    
    <cfpdfform source="YOUR-URL\www\purchase_contract.pdf"  action="populate" destination="#session.document_root#\#URL.access#.pdf" overwrite="yes"> 
            <cfpdfformparam name="admin" value="#get_admin.first_name# #get_admin.last_name#"> 
            <cfpdfformparam name="admin_email" value="#get_admin.email#"> 
    </cfpdfform>
    <!--- This flattens the file and shows it with no editable fields. Dont use this if you want them to be able to change.--->
    <cfpdf action="write" destination="#session.document_root#\#URL.access#" source="#session.document_root#\#URL.access#.pdf" flatten="yes" overwrite="yes">
    <cfheader name="Content-Disposition" value="inline; filename=#session.document_root#\#URL.access#"> 
    <cfcontent file="#session.document_root#\#URL.access#" type="application/pdf" >
    If you can't stand behind your troops, feel free to stand in front of them
    Semper Fidelis

  • #8
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,622
    Thanks
    0
    Thanked 645 Times in 635 Posts
    The easiest way to create PDFs from PHP is to use FPDF.

    http://fpdf.org/
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #9
    Regular Coder
    Join Date
    Jul 2010
    Posts
    271
    Thanks
    3
    Thanked 40 Times in 40 Posts
    I have looked at that felgall but I couldn't find any way to populate a pdf form. Do you know if they have a way to do that? I have some clients that are strictly php.
    If you can't stand behind your troops, feel free to stand in front of them
    Semper Fidelis

  • #10
    Regular Coder
    Join Date
    Jul 2010
    Posts
    271
    Thanks
    3
    Thanked 40 Times in 40 Posts
    Actually I think I just found it. I have not tried this and just found it on the internet. On this site http://fpdf.org/ in the examples

    PHP Code:
    <?php

    /***************************
      Sample using a PHP array
    ****************************/

    require('fpdm.php');

    $fields = array(
        
    'name'    => 'My name',
        
    'address' => 'My address',
        
    'city'    => 'My city',
        
    'phone'   => 'My phone number'
    );

    $pdf = new FPDM('template.pdf');
    $pdf->Load($fieldsfalse); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
    $pdf->Merge();
    $pdf->Output();
    ?>
    If you can't stand behind your troops, feel free to stand in front of them
    Semper Fidelis


  •  

    Tags for this Thread

    Posting Permissions

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