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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:57:00+00:00 2026-05-28T05:57:00+00:00

I have an html file named welcomemailtemplate.html and I need to convert that file

  • 0

I have an html file named welcomemailtemplate.html and I need to convert that file to a PDF.

I first read this file using the following method provided by Yii framework:

$filename = Yii::app()->basePath.'\views\email\welcomemailtemplate.html';
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
$name = $model->name;
fclose($handle);
$message = str_replace ( "[username]", $name, $contents );

Then, to generate the PDF file, the following parameters are set:

 Yii::import('application.vendors.*');
       require_once('tcpdf/tcpdf.php');
       require_once('tcpdf/config/lang/eng.php');
       $pdf = new TCPDF();
       $pdf->SetCreator("Torget");
       $pdf->SetAuthor('test name');
       $pdf->SetTitle('Savani Test');
       $pdf->SetSubject(' Torget Order Confirmation');
       $pdf->SetKeywords(' Torget, Order, Confirmation');
       //$pdf->SetHeaderData('', 0, PDF_HEADER_TITLE, '');
       $pdf->SetHeaderData('', 0, "Torget Order", '');
       $pdf->setHeaderFont(Array('helvetica', '', 8));
       $pdf->setFooterFont(Array('helvetica', '', 6));
       $pdf->SetMargins(15, 18, 15);
       $pdf->SetHeaderMargin(5);
       $pdf->SetFooterMargin(10);
       $pdf->SetAutoPageBreak(TRUE, 0);
       $pdf->SetFont('dejavusans', '', 7);
       $pdf->AddPage();

If I pass the content as follows, it creates the PDF:

 $pdf->writeHTML("<span>Hello World!</span>", true, false, true, false, '');

But if I pass the read html file content for pdf creating using following method it gives following error:

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

Error message:

Undefined index: thead
  • 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-28T05:57:00+00:00Added an answer on May 28, 2026 at 5:57 am

    Try to validate the file using the w3c validator http://validator.w3.org/.

    I’ve worked with tcpdf before but i gave it up because it didn’t seem reliable. You can also try wkhtmltopdf binary (only if your hosting allows you to use proc_open/proc_close). Seems a little more stable to me. It also has a PHP class to help you use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML file that has code similar to the following. <table> <tr>
In my HTML file, I have a JavaScript function named CheckCaptcha. I am using
I have a url like this : http://www.refskou.dk/safari-%F8.html The file is named like this:
I have an html file named videoplay.html with following content <!DOCTYPE html> <html> <head>
I have html-file. I have to replace all text between this: [%anytext%]. As I
I have a html file that has invoice details I would like to know
I have a html file that contains urls that start with ftps, http, https,
I have a html file that I want to trim. I want to remove
I'm new to DOM parsing in PHP: I have a HTML file that I'm
I have many html files named 12345.html, 12346.html, etc. I need to change style.css

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.