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 8897171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:16:11+00:00 2026-06-15T00:16:11+00:00

I need to generate pdf using dom pdf and php. I tried this but

  • 0

I need to generate pdf using dom pdf and php.
I tried this but I get error 500, I have no syntax errors. If I try : $html='Title here' it works. I tried using an external php script and by using file_get_contents() function but it didn’ work. Anybody can help me find a solution to generate the pdf using a php script?

This is my script (dompdf/index.php):

<?php

include("dompdf_config.inc.php");
include "../config.php";
include("../db/mysql.php");

$pers=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$inv=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$cli=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$proj=$db->sql_fetchrow($db->sql_query('//-----query here--------'));


$total=$db->sql_query('//-----query here--------');

$ret.=
  '
<html>
<head>

</head>

<body>

<div id="left" style="float:left; margin:0 auto;width400px;">
<strong><h2></h2></strong>

</div>

<div id="left" style="float:left; margin:0 auto;  width:300px; ">
<h2 style="">INVOICE</h2>
<table style="border-style : solid;
border-width:2 px;
border-color : black; width:300px; ">
<tr style="border-bottom: 2px solid black !important;"><th style="border-bottom: 2px solid black !important;">Invoice Date</th><th style="border-bottom: 2px solid black !important;">Invoice No.</th></tr>
<tr><td align="center">'.$inv["date_due"].'</td><td align="center">'.$inv["invoice_no"].'</td></tr>
</table>

</div>
<br />
<div  style="float:left; margin:0 auto;width:100%;margin-top:50px; width=300px;">

<table style="border-style : solid; border-width:2 px; border-color : black; width=400px;">
<tr border="1"><th style="border-bottom: 2px solid black !important;" width="400">INVOICE TO:'.$pers['name'].'</th></tr>
<tr><td width="400">
    '.$cli["name"].'<br />
   '.$cli["street"].'<br />
    '.$cli["city"].'<br /><br />
'.$cli["country"].'<br />
</td></tr>
</table>
</div>
<br />
<div style="float:left; width:600; margin-top:50px;margin-bottom:50px;">

<table style="border-style : solid; border-width:2 px; border-color : black; width=600px;">
<tr width=800px; border="2" style="bordder-bottom: #000 solid;"><th colspan="2" style="border-bottom: 2px solid black !important;width:600px;">INVOICE DESCRIPTION</th></tr>

<tr ><td align="right" width="300"><strong>Project name:</strong></td>
<td>'.$proj["name"].'</td></tr>

<tr><td align="right" width="300"><strong>Job number:</strong></td>
<td width="300">'.$proj["job_no"].'</td></tr>

<tr><td align="right" width="300"><strong>Job reference:</strong></td>
<td width="300"> '.$proj["job_reference"].'</td></tr>

<tr><td align="right" width="300"><strong>Source Language:</strong></td>
<td width="300">'.$proj["source_lang"].'</td></tr>

<tr><td align="right" width="300"><strong>Target Language:</strong></td>
<td width="300">'.$proj["targ_lang"].'</td></tr>

<tr><td align="right" width="300"><strong>Deadline:</strong></td>
<td width="300">'.$proj["deadline"].'</td></tr>


</table>
</div>
<br />
<br />
<div style="margin-top:50px;width:600px;">

<table style="border-style : solid; border-width:2 px; border-color : black; width:600px;">
<tr border="1" style="border-bottom: black solid"><th style="border-bottom: 2px solid black !important;">Task description</th><th  style="border-bottom: 2px solid black !important;">Unit</th><th style="border-bottom: 2px solid black !important;">Qty</th><th  style="border-bottom: 2px solid black !important;">Fee Unit</th><th style="border-bottom: 2px solid black !important;">Amount</th></tr>';
  $ret1="";
 $sum=0;
while($r=$db->sql_fetchrow($total)){

    $task_type=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$quote_type=$db->sql_fetchrow($db->sql_query('//-----query here--------')); 
$unit=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
 $t_lang=$db->sql_fetchrow($db->sql_query('//-----query here--------')); 
 $s_lang=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
 $price=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
 $amount=$price["unit_fee"]*$r["unit_qty"];
 $sum+=$amount;
$ret.='   
<tr style="alignment-adjust: central;"><td>'.$task_type["task"].'&nbsp;&nbsp;&nbsp; '.$quote_type["client_quote"].'</td><td>'.$unit["name"].'</td><td>'.$r["unit_qty"].'</td><td>'.$price["unit_fee"].'</td><td align="right">'.$amount.' '.$r["currency"].'</td></tr>
 ';
 $curr=$r["currency"];


$ret.= '<tr ><td colspan="4" align="right">Subtotal</td><td colspan="4" align="right">'.$sum.' '.$curr.'</td></tr>
<tr ><td colspan="4" align="right">100% due on'.$r["date_due"].'</td><td colspan="4" align="right">'.$sum.' '.$curr.'</td></tr>
<tr ><td colspan="4" align="right">VAT 0%</td><td colspan="4" align="right">0,0 '.$curr.'</td></tr>
<tr ><td colspan="4" align="right"><strong>TOTAL</strong></td><td colspan="4" align="right"><strong>'.$sum.' '.$curr.'</strong></td></tr>
</tr>
</table>
</div>
<br />
  </table><br />
  </div>

  </body>
  </html>';




  $dompdf = new DOMPDF();
  $dompdf->load_html($ret);
  $dompdf->render();
  $dompdf->stream("Invoice.pdf");
  ?>
  • 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-06-15T00:16:12+00:00Added an answer on June 15, 2026 at 12:16 am

    Your content() function echoes the text. It pushes it to the screen, while you want to catch it in $html.
    Use return instead.

    UPDATE

    In order to catch all query results to one return, you could append them to a variable like this:

    function content() {
    // Define the output variable
    $output = "";
    
    //Run query
    $pers=$db->sql_fetchrow($db->sql_query('select * from clients_persons where person_id='.$_GET["ps"].''));
    
    //Combine query results and html
    $output .= $pers['name'];
    $output .= " <i>";
    $output .= $pers['email'];
    $output .= " </i>";
    
    return $output;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to generate a PDF file using some data I get from a
I'm using tcpdf to generate PDF files with PHP and I have no problem
I'm currently using FOP to generate PDF from an XML file. But I am
I already use iText to generate pdf, but now I need to read pdfs(no
I generate PDF's using FPDF and I need to email it to a customer.
Working on a project and need to generate pdf of the product details using
I need to generate a 2 pages pdf report. Pages are completely independent. tried
I need to generate a PDF file with some information i get from a
I need to generate a pdf from a tex file, as a temporary file.
I need to generate a pdf from Ubecarts orders. I know how to access

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.