Register Lost your password?

public function fAddText(string text, array arrParamsText = array())

public function fAddText(array text = array()) Version Pro

Parameters

text : Text to insert into the document
$arrParamsText

  • ‘b’ (bold): ’single’
  • ‘color’ (color RGB): FF0000, 000000, FFFFFF,…
  • ‘i’ (italic): ’single’
  • ‘jc’ (text alignment): ‘left’, ‘center’, ‘right’, ‘both’, ‘distribute’
  • ’sz’ (size): 1, 2, 3, 4,…
  • ‘u’ (underline): ’single’, ‘words’, ”double’, ‘dotted’, ‘dash’, ‘wave’
  • ‘pageBreakBefore’ (forces a page break before a paragraph) : on, off
  • ‘widowControl’ (prevents Word from printing the last line of a paragraph by itself at the top of the page (widow) or the first line of a paragraph at the bottom of a page (orphan)) : on, off
  • ‘wordWrap’ (breaks a line in the middle of a word) : on, off
  • ‘font’ (A specific size and style of font type within a type family. Example ‘Times New Roman’, ‘Arial’,…)

text : creating a multi-format text Version Pro

  • ‘b’ (bold): ’single’
  • ‘color’ (color RGB): FF0000, 000000, FFFFFF,…
  • ‘i’ (italic): ’single’
  • ‘jc’ (text alignment): ‘left’, ‘center’, ‘right’, ‘both’, ‘distribute’
  • ’sz’ (size): 1, 2, 3, 4,…
  • ‘u’ (underline): ’single’, ‘words’, ”double’, ‘dotted’, ‘dash’, ‘wave’
  • ‘pageBreakBefore’ (forces a page break before a paragraph) : on, off
  • ‘widowControl’ (prevents Word from printing the last line of a paragraph by itself at the top of the page (widow) or the first line of a paragraph at the bottom of a page (orphan)) : on, off
  • ‘wordWrap’ (breaks a line in the middle of a word) : on, off
  • ‘font’ (A specific size and style of font type within a type family. Example ‘Times New Roman’, ‘Arial’,…)
  • ‘text’ (Text string for multi-format)

Examples

Example 1


require_once('../classes/cCreateDocx.inc');
$objDocx = new cCreateDocx();
$arrParamsText = array(
    'b' => 'single'
  );
$objDocx->fAddText('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', $arrParamsText);
$objDocx->fCreateDocx('ejemplo_texto');


Example 2


require_once('../classes/cCreateDocx.inc');
$objDocx = new cCreateDocx();
$arrParamsText = array(
    'u' => 'single',
	'pageBreakBefore' => 'on'
  );
$objDocx->fAddText('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', $arrParamsText);
$objDocx->fCreateDocx('ejemplo_texto');


Example 3 Version Pro


require_once('../classes/cCreateDocx.inc');
$objDocx = new cCreateDocx();
$arrText = array();
$arrText[] =
        array(
            'text' => 'Lorem ipsum ',
            'u' => 'single',
);
$arrText[] =
        array(
            'text' => ' sed do eiusmod tempor incididunt'
);
$objDocx->fAddText($arrText);
$objDocx->fCreateDocx('example_text_multi');

    5 Responses

  • nico

    Hello,

    Is it possible possible to change the style of a part of a text in the same paragraph ?

    fAddText(’Start of the line without style’);
    $arrParamsText = array(
    ‘b’ => ’single’
    );
    $objDocx->fAddText(’ the line continue without return to line ?’,$arrParamsText);
    ?>

    If I write two fAddText methods, I have a return to line in my sentence :(

    Regards,

  • admin

    Hi,

    The next version of phpdocx will include this feature. We’re working actually on it.

  • bneal010

    how would I go about making text within a table cell bold?

  • Colin

    Cant get this to work with line feeds. What characters will it convert into line feeds?

  • Mutske

    This looks like a promising product. However, it would be good to have a users forum.
    I would be interested to buy a license if I would be able to get the example files to work.

    Even the simple ‘hello world’ example is not working. GEt the error :syntax error, unexpected T_STRING, expecting ‘)’. (error comes from $objDocx->fAddText)

    There is a big need for such a product but PLEASE PROVIDE A FORUM. I have been purchasing too many softwares that I never used. So, put us in a position to share experience between users and you will see your sales boosting !

    Support is maybe an important revenue source but make sure your cutomers can first have a good expecience with the product.

    Mutske

Your comments