Replies: 6   Views: 2637
Add progress bar
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by irishadar  · 18-02-2018 - 12:59


I am trying to add a progress bar to a "phpdocx" script.

but keep getting the error:

"Warning: Cannot modify header information - headers already sent by (output started at C:\phpdocx\dev\TetsugaPhotHeborg080218.php:332) in C:\phpdocx\classes\ on line 369"

Is it even possible?

can anyone shear with me what can I do?


I'm using this code in the PHP part :

echo " $vcurrent is $percent% of $vtotal <p/>";
ob_end_clean() ;

and this code after the PHP code:

          border:solid 1px #000;
          width:<?php echo $percent ?>%;
          border-right:solid 1px #000;

  <div class="outter">
    <div class="inner"></div>


Posted by admin  · 19-02-2018 - 08:05


The following error:

Cannot modify header information - headers already sent by

is from PHP. PHP can't display output before using the header function; from

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.

We recommend you to check your script to find where it's getting any output before the header.



Posted by irishadar  · 19-02-2018 - 20:22


I have looked at my script but couldnt find what am i missing .

I have written a simple test case to demonstrate my problem .

so if I'm not using "createDocxAndDownload" all works well if i do i gets the warning

"Cannot modify header information - headers already sent by"

can someone point what is wrong with the script ?

thanks in advanced,

iris hadar

header( 'Content-type: text/html; charset=utf-8' );
require_once '../classes/';
$docx = new CreateDocx();

echo 'Begin ...<br />';
for( $i = 0 ; $i < 10; $i++ )
    echo $i . '<br />';
echo 'End ...<br />';

$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.';

$paragraphOptions = array(
    'bold' => true,
    'font' => 'Arial'

$docx->addText($text, $paragraphOptions);


Posted by admin  · 20-02-2018 - 07:17


You are using the echo method from PHP to print strings and then you are using the createDocxAndDownload method that uses the header function to download a document. PHP doesn't allow to do that (print strings before using the header function), please read the information about the header function on the PHP page.


Posted by irishadar  · 20-02-2018 - 13:54

Thank you for the prompt answer.

So what is your suggestion for a "progress bar" displaying the creation status of the document ? 




Posted by admin  · 21-02-2018 - 07:19


You can use XMLHTTPRequest using javascript or you can use PHP to generate a progress bar and other script to download it when it's finished or you can generate and use a hook system. There're many approaches to generate a custom progress bar, and the best and easiest solution depends on the project and the developer.


Posted by irishadar  · 26-02-2018 - 07:09

To whom it may concern,

I have found this article and implanted it in my script it is working very well.

I've added some action to do when it reaches 100%.