Forum


Replies: 2   Views: 3131
Linebreak in addtext function
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 mbcalvin  · 12-01-2013 - 00:09

Hello, I am using the following code to generate a word doc:

[code]
docx = new CreateDocx();
$id = req('fd_id');
$field = Field_day::db_field_day($id);
$text = array();
$factory = new employee_factory();

$salesperson = new Salesperson($field->employee_id);
if(!($salesperson instanceof Salesperson))
die('You must be a salesperson to use the field day tool');
$filename = $salesperson->get_lname() . "_" . date('m-d-Y', strtotime($field->date)) . "_" . time();
$text[] = array('text'=>"Field Day For: " . $salesperson->get_full_name(), 'b'=>'on', 'lineBreak'=>'both');
$text[] = array('text'=>'Date: ' . $field->date);
$text[] = array('text'=>'Starting Mileage: ' . $field->starting_mileage . ' Ending Mileage: ' . $field->ending_mileage);
$docx->addText($text);

foreach($field->stops as $stop)
{
$text = array();
$stop['phone'] = 'change this, its static';
$text[]=array('text'=>'Referral: ' . $stop['name'], 'spaces'=>2, 'lineBreak'=>'after');
$text[]=array('text'=>'Mileage: ' . $stop['mileage'],'spaces'=>2, 'lineBreak'=>'after');
$text[]=array('text'=>'Address: ' . $stop['address'],'spaces'=>2, 'lineBreak'=>'after');
$text[]=array('text'=>'Phone: ' . $stop['phone'], 'spaces'=>2, 'lineBreak'=>'after');
$docx->addText($text);
$tbox = array(
'width'=> 18,
'height'=>10,
'padding_left'=> 1,
'padding_top'=>1,
'margin_top'=>2,
'margin_left'=>2,
'border'=> 5,
'border_color'=>'black'
);
$docx->addTextBox(array('text'=>$stop['note'], 'args'=>array(), $tbox));
$docx->addTextBox(array('text'=>$stop['result'], 'args'=>array(), $tbox));
}

$docx->createDocxAndDownload($filename);
[/code]

The problem I am having is that my 'lineBreak'=>'after' option is being ignored. I have tried using 'both' and 'before' also and don't get any results. My goal is to have each array in $text get added to a new line (I tried adding it like a paragraph using addText on each array of text, but that puts 10 pts of spacing after each line, and it is too large then).

Any suggestions would be very appreciated.

Posted by admin  · 11-04-2013 - 12:13

Hello,

We're testing your issue.

Which version of phpdocx are you using?. Are you using pro, pro+ or corporate?

Regards.