PDF creation using FPDF on PHP website

Sean Fabian
Sean Fabian used Ask the Experts™
on
I have a php website that i use FPDF to create a pdf copy of a work order.  The customer signs the work order via a mobile device when the job is finished.  FPDF is supposed to pull the image into the PDF but all it shows is a file name.  Wondering if anyone can help. I have attached a copy of a workorder showing the problem and also the php code that i use to create the pdf.  thanks.
workorder_pdf.php
wo_848.pdf
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016

Commented:
This seems more like a requirement for application development than a question hat has an answer.  Maybe consider posting it in E-E Gigs so you can engage a developer.  Best of luck with it, ~Ray
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
        $this->Cell($w[$i],6,$row['job_signature'],0,0,'L',$fill);
        //$this->Image('images/captured_signature/'.$row['job_signature'],50,145, 40, 40,'PNG'); 
//        $ImgPAth='images/captured_signature/'.$row['job_signature'];
//          $ImgPAth='images/captured_signature/signature_351.jpg';
//        $this->Cell(60,60,$this->Image($ImgPAth, $this->GetX(), $this->GetY(), 45,40),0,0,'L');

Open in new window

I am not familiar with FPDF but it looks like you have commented out the code that inserts an image and replaced it with code that inserts the name.

I use MPDF (http://www.mpdf1.com/mpdf/index.php) which is a combination of FPDF and HTML2PDF. At the risk of doing an injury inducing sharp turn, have you tried creating your Work Order in HTML and then using MPDF to render it for you.
Sean FabianIT Director

Author

Commented:
No i have not... The whole site is written in php code.
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
What about the first comment in my post
it looks like you have commented out the code that inserts an image and replaced it with code that inserts the name.
Sean FabianIT Director

Author

Commented:
i have uncommented it and it is still doing the same  thing
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Here is how you are loading the cti image
$this->Cell(60,60,$this->Image('images/cti.jpg', $this->GetX(), $this->GetY(), 45,25,'JPG'),0,0,'L');

Open in new window


This is how you appear to be loading your signature
$this->Cell($w[$i],6,$row['job_signature'],0,0,'L',$fill);

Open in new window


Why not try this
$this->Cell($w[$i],6,$this->Image($row['job_signature'], $this->GetX(), $this->GetY(), 45,25,'JPG'),0,0,'L', $fill);

Open in new window

Change the width (45) and height(25) to match the size of your signature.
Sean FabianIT Director

Author

Commented:
what part should i leave and what part should i comment out.   i just commented out everything and put in what you suggested and still not working. I really appriciate the help.  Do you need any more info?
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
The best approach to getting the most out of EE is to provide as much input as you can. Saying things like it does not work - is useless to us - we can't see what you see so we need something to go on.
For instance
- posting your code to show how you implemented the latest suggestion
- letting us know if the "did not work" generated an error or did it generate the wrong result
- trying to interpret what is being recommended so you can make minor adjustments to suite your environment. We cannot always give you the exact code you need (because we don't have access to your environment) - you might need to tweak it to make it work.

In your example your code was just displaying the image name. However the CTI image at the top displays fine which seems to indicate that the method you are using for the signatures is wrong.

By using the same process for implementing the CTI image on the signature it should work. If the implementation is correct and it is still not working then the problem is data.

Your PDF says the image name is signature_848.jpeg - are you sure this image exists?
There is no path before the image - maybe there needs to be one - is the extension meant to be .jpeg.
Try hard-coding the path in the FPDF command instead of using a variable - if that works then look at what is wrong with your variable. Remember paths are usually relative to the location where the landing script is run from. By landing script I mean the script that was invoked through the URL or command line. If a script includes another script in a different location - the included script assumes the location of the parent. Check your paths are correct along with the other items mentioned above and post back with what you find.
Sean FabianIT Director

Author

Commented:
i will try that today.  The image that the pdf pulls is different for every wo order created.   Since each signature is different.  Again, thanks for the help.   I will try those suggestions in a few hours.   Its 4am here and i need to get some rest.
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Since each signature is different

Yes, got that but for testing pick one that exists and test with that. When that works you can go back to using the dynamic one.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial