Skip to content

I’m having a php error can someone provide some solutions

I am having an error in my PHP code and I need help. If anyone knows the solution to this issue, please help me. The error message I am seeing is

[Fatal error: Uncaught BadMethodCallException: Method createtemplate is not defined. in C:xampphtdocsphpvendorphpofficephpwordsrcPhpWordPhpWord.php:148 Stack trace: #0 C:xampphtdocsphpindex1.php(10): PhpOfficePhpWordPhpWord->__call(‘createtemplate’, Array) #1 {main} thrown in C:xampphtdocsphpvendorphpofficephpwordsrcPhpWordPhpWord.php on line 148].

This is my code

<!-- HTML form for selecting the Word document to convert -->
<form method="post" enctype="multipart/form-data">
  <label for="word-file">Select Word document:</label>
  <input type="file" name="word-file" id="word-file">
  <input type="submit" value="Convert">


// Check if the form has been submitted
  // Get the uploaded Word document
  $wordFile = $_FILES['word-file']['tmp_name'];

  // Include the PHPWord library
  require_once 'vendor/autoload.php';

  // Create a new PHPWord object
  $PHPWord = new PhpOfficePhpWordPhpWord();

  // Load the Word document
  $document = $PHPWord->loadTemplate($wordFile);

  // Save the document as a PDF

  // Show a message to the user
  echo '<p>The Word document has been converted to PDF.</p>';


have tried many solutions but nothing works….



I think you can use save method not to loadTemplate… please replace your code…


    $document = $PHPWord->loadTemplate($wordFile);


    $document = $PHPWord->save($wordFile);
User contributions licensed under: CC BY-SA
3 People found this is helpful