Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7704245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:38:33+00:00 2026-05-31T23:38:33+00:00

I’m sending user data via jQuery to TCPDF, but it does not display any

  • 0

I’m sending user data via jQuery to TCPDF, but it does not display any value received from jQuery in the PDF file.

I have even tried to capture the value in a session variable but it still doesn’t display. Where am I going wrong?

HTML:

<div id="p">
    FOO
    <input type="text" id="nop" />
</div>

 <div id="e_table">
                <table>
                    <thead>
                        <th><h3>ABC</h3></th>
                        <th><h3>PQR</h3></th>
                        <th><h3>XYS</h3></th>
                    </thead>
                    <tbody>
                    <tr>
                        <td>Staff</td>
                        <td><input type="text" id="as" /></td>
                        <td><label id="las">label</label></td>
                    </tr>
                    <tr>
                        <td>Office</td>
                        <td><input type="text" id="bo"/></td>
                        <td><label id="lbo">label</label></td>
                    </tr>
                    <tr>
                        <td>Administrative</td>
                        <td><input type="text" id="mca" /></td>
                        <td><label id="lmca">label</label></td>
                    </tr>
                    </tbody>
                </table>
</div>

jQuery:

$('#pdf').click(function() {                    
                    var nop = $('#nop').val();
                    var as = $('#as').val();
                    var las = $('#las').text();
                    var bo = $('#bo').val();
                    var lbo = $('#lbo').text();
                    var mca = $('#mca').val();
                    var lmca = $('#lmca').text();

                    var postData = {
                         "nop" : nop,
                         "as" : as,
                         "las" : las,
                         "bo" : bo,
                         "lbo" : lbo,
                         "mca" : mca,
                         "lmca" : lmca
                    };

                    $.ajax({
                            type: "POST",
                            url: "pdf.php",
                            data: postData, 
                            success: function(data){
                                window.open("pdf.php"); 
                            }
                        });


        });

TCPDF pdf.php:

<?php
session_start(); 

//============================================================+
// Author: Nicola Asuni
//
// (c) Copyright:
//               Nicola Asuni
//               Tecnick.com s.r.l.
//               Via Della Pace, 11
//               09044 Quartucciu (CA)
//               ITALY
//               www.tecnick.com
//               info@tecnick.com
//============================================================+

/**
 * @author Nicola Asuni
 * @since 2009-03-20
 */

require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');

// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {


    // Page footer
    public function Footer() {
        // Position at 15 mm from bottom
        $this->SetY(-15);
        // Set font
        $this->SetFont('helvetica', 'B', 8);
        $this->SetTextColor(247, 147, 29); 


        $this->Cell(0, 10, 'ABC', 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }
}

// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('ABC');
$pdf->SetTitle('ABC');
$pdf->SetSubject('ABC');
$pdf->SetKeywords('ABC');


// set default header data
$pdf->SetHeaderData(false);


$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, 5, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------


// add a page
$pdf->AddPage();

$pdf->SetFont('helvetica', '', 8);

// -----------------------------------------------------------------------------


//request parameters
    $nop = strip_tags($_POST['nop']);
    $_SESSION['nop'] = $nop;
    $nop = $_SESSION['nop'];
    $as = strip_tags($_POST['as']);
    $las = strip_tags($_POST['las']);
    $bo = strip_tags($_POST['bo']);
    $lbo = strip_tags($_POST['lbo']);
    $mca = strip_tags($_POST['mca']);
    $lmca = strip_tags($_POST['lmca']);

$tbl = <<<EOF
          <div>
                <table border="0" cellpadding="5" cellspacing="2">
                    <tr>
                        <td>FOO</td>
                        <td>$nop</td>
                    </tr>
                    </tbody>
                </table>
              </div>
              <hr>
              <div>
                <table border="0" cellpadding="5" cellspacing="2">
                    <thead>
                    <tr>
                        <th><h3>ABC</h3></th>
                                        <th><h3>PQR</h3></th>
                                        <th><h3>XYS</h3></th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>Staff</td>
                        <td>$as</td>
                        <td>$las</td>
                    </tr>
                    <tr>
                        <td>Office</td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Administrative</td>
                        <td></td>
                        <td></td>
                    </tr>
                    </tbody>
                </table>
              </div>
         </div>
EOF;

$pdf->writeHTML($tbl, true, false, false, false, '');

$txt = $nop . 'This';

 // print a block of text using Write()
$pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0); 
// -----------------------------------------------------------------------------


//Close and output PDF document
$pdf->Output('ABC.pdf', 'I');

//============================================================+
// END OF FILE                                                
//============================================================+
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:38:34+00:00Added an answer on May 31, 2026 at 11:38 pm

    you are calling your pdf.php 2 times, one with the post data, and one without

    $.ajax({ // call 1, with post data
        type: "POST",
        url: "pdf.php",
        data: postData, 
        success: function(data){
            window.open("pdf.php"); // call 2, without post data
        }
    });
    

    what you can do is to remove your ajax request, and send the data via GET instead with

    var getString = "nop=" + nop "&as=" + as; // .....
    window.open("pdf.php?" + getString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.