473,419 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

How do you write a php vairable to PDF using FPDF library?

45 32bit
I've tried using the following code to write a variable to a PDF file, but it only returns a blank PDF. How do you write a php variable to a library using the FPDF library?
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. require('../fpdf.php');
  4. if (isset ($_POST['sig'])) {
  5. $_POST['sig'] = $SESSION['sig'];
  6. $pdf = new FPDF();
  7. $pdf->AddPage();
  8. $pdf->SetFont('Arial','B',16);
  9. $_SESSION['sig'] = $sig;
  10. $pdf->Cell(40,10, $sig);
  11. $filename = '/var/www/html/foo/foo.pdf';
  12. $pdf-> Output($filename, 'F');
  13. }
  14. session_destroy();
  15. exit;
  16. ?>
  17. <!DOCTYPE html>
  18. <body>
  19. <br>&nbsp;<br>&nbsp;
  20. <form action="" method="post'>
  21. <label for "sig">Signature: </label>
  22. <input type="text" name="sig" placeholder="your signature here" id="sig" required>
  23. <br>&nbsp;<br>&nbsp;
  24. <input type="submit" value="Sign Document">
  25. </form>
  26. </body>
  27. </html>
  28.  
Feb 23 '21 #1

✓ answered by Niheel

You seem to sending a blank $sig in to the Cell method.

Change this:
Expand|Select|Wrap|Line Numbers
  1. $_SESSION['sig'] = $sig;
  2. $pdf->Cell(40,10, $sig);
to:
Expand|Select|Wrap|Line Numbers
  1. $sig = $_SESSION['sig'];
  2. $pdf->Cell(40,10, $sig);
  3.  
See if that works. :)

2 3382
Niheel
2,460 Expert Mod 2GB
You seem to sending a blank $sig in to the Cell method.

Change this:
Expand|Select|Wrap|Line Numbers
  1. $_SESSION['sig'] = $sig;
  2. $pdf->Cell(40,10, $sig);
to:
Expand|Select|Wrap|Line Numbers
  1. $sig = $_SESSION['sig'];
  2. $pdf->Cell(40,10, $sig);
  3.  
See if that works. :)
Feb 25 '21 #2
bakertaylor28
45 32bit
@niheel
Yep, that was the problem. A simple oversight on setting the var.
Feb 25 '21 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Surendra | last post by:
Hi to all, Can any one of u solve my problem. How can i show a message box on client side using class library of .net it may be vb.net or c#.net. If any1 has any idea about it. Please let me...
0
by: Eniac | last post by:
Hello, I've started using Enterprise Library 2.0 recently and I've encountered a problem that seems to be ... well... undocumented :) Basically, when I set a Trace Listener (formatted event...
0
by: Burki | last post by:
Hi I want to know how to configure Access database using Enterprise Library Data block. I want to be able to spacify local path to mdb file in configuration file. I do not want users to creat...
2
by: aarrojado | last post by:
I´m trying to implement Rijndael algorithm AES in C language using the library GMP. And it is dificult to start programming because it as been years i do not program in C. Well if there is anybody...
6
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
5
by: cappieins | last post by:
Hi, i've got a problem using PHP FPDF library to create PDF files send inline to a browser window. The created PDF file opens correctly in the browser (IE 6), but if I want to save it to my...
0
by: zeenets | last post by:
I am using Enterprise library v3.1 for developing a windows application. its working well. but there is a security issue, when i deploy this application on client machine the...
0
by: =?Utf-8?B?U2hyaWthbnQgTW9yZQ==?= | last post by:
Using enterprise library's 3.1 Logging Application Block , how can i get the custom source name in the windows event log.When ever i am logging an error in windows event log , it gives the source...
0
by: srizzler | last post by:
Hi All: I am trying to implement Exception Handling using Enterprise Library 3.1's Exception Handling Application Block as well as Logging Blocks. I have a windows application developed in...
4
by: tvnaidu | last post by:
I created an executable using static library instead shared lib, I am running multipe instances of this executable, does it takes more memory with static library compare to shared library?. Does...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.