Jump to content

Export Table to Pdf


Naveed786

Recommended Posts

Hello All,

I am currently working on export to pdf, below is the code, i am able to see the data is getting retrieved from mysql table. I am having 2 issue:

1. When data is getting retrieved one column is on left corner it's now showing the data as it's Sno it gets hidden from left corner.

2. Second issue when i click on the link it's just adding a # tag on the url nothing else. 

 

Please guide me to fix the code.

 

<!DOCTYPE html>
<html>
<head>
<Title> Export Supplier / Visiters Details</Title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
<script type="text/javascript" src="tableExport.js"></script>
<script type="text/javascript" src="jquery.base64.js"></script>
<script type="text/javascript" src="html2canvas.js"></script>
<script type="text/javascript" src="jspdf/libs/sprintf.js"></script>
<script type="text/javascript" src="jspdf/jspdf.js"></script>
<script type="text/javascript" src="jspdf/libs/base64.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<?php
$con=mysqli_connect("localhost", "root", "", "cvmsdb");
 
$qry="SELECT * FROM tblsupvisitor";
$result=mysqli_query($con, $qry);
 
$records = array();
 
while($row = mysqli_fetch_assoc($result)){ 
   $records[] = $row;
}
?>

<div class="row" style="height:300px;overflow:scroll;">
                        <table id="tblsupvisitor" class="table table-striped">
                <thead>         
                    <tr class="warning">
                        <th>SNO.</th>
                        <th>Full Name</th>
                        <th>Mobile Number</th>
                        <th>Address</th>
                    </tr>
                </thead>
                <tbody>
                <?php foreach($records as $rec):?>
                    <tr>
                        <td><?php echo $rec['ID']?></td>
                        <td><?php echo $rec['FullName']?></td>
                        <td><?php echo $rec['MobileNumber']?></td>
                        <td><?php echo $rec['Address']?></td>
                    </tr>
                    <?php endforeach; ?>
                    </tbody>
                    </table>
</div>
<li><a href="#" onclick="$('#tblsupvisitor').tableExport({type:'json',escape:'false'});"> <img src="images/icon/logo.png" width="24px"> Export to Pdf</a></li>
<li><a href="#" onclick="$('#tblsupvisitor').tableExport({type:'json',escape:'false'});"><img src="images/icon/logo.png" width="24px">JSON (ignoreColumn)</a></li>
</html>							

 

Kind Regards,

Naveed.

Link to comment
Share on other sites

1 hour ago, Naveed786 said:

1. When data is getting retrieved one column is on left corner it's now showing the data as it's Sno it gets hidden from left corner.

What? Screenshot?

 

1 hour ago, Naveed786 said:

2. Second issue when i click on the link it's just adding a # tag on the url nothing else.

Check your browser's Javascript console for errors.

  • Thanks 1
Link to comment
Share on other sites

7 hours ago, requinix said:

What? Screenshot?

 

Check your browser's Javascript console for errors.

Hi requinix,

 

I am attaching the screen shot for the first part and for the second part also i am uploading the javascript console error if you can help me to understand these error shall i replace these libs if yes can you please refer me to right libs.

Export.jpg

Error in Export.jpg

Edited by Naveed786
Link to comment
Share on other sites

44 minutes ago, Naveed786 said:

Hi requinix,

 

I am attaching the screen shot for the first part and for the second part also i am uploading the javascript console error if you can help me to understand these error shall i replace these libs if yes can you please refer me to right libs.

Export.jpg

Error in Export.jpg

 

All errors are gone i copied the required plugins but the only issue now is table export function, please see the attached screen shot.

 

Export Table Error.jpg

Link to comment
Share on other sites

Hi,

Just want to post update now all errors are gone, but only one issue once i click on export to pdf it's getting exported in .json instead of .pdf.

 

Can anyone help me on this and first column is not appearing properly i have posted the screen shot.

 

Kind Regards,

Naveed.

Link to comment
Share on other sites

Hello,

Quick update on progress, I found there was some issue with java scripts I have updated with new java scripts from github but now it is working but now it gets exported in csv but I need in pdf, can anyone help me with libs and data table export pdf Java scripts please.

Link to comment
Share on other sites

Thanks to all for help and guidance, it's working fine now the issue was with Java script @requinix thanks for the guidance it's always fantastic and great. One quick question i want to put some formatting in the file as currently it looks very simple and still first column serial number is getting hidden i can not see the number under it but when i export the data is there.

Can any one help on this code is already posted above.

 

 

Thanks in advance. 

Naveed.

Edited by Naveed786
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.