Trouble with line heights (spacing, spaceBefore, spaceAfter)

Jun 3, 2011 at 10:33 PM

I am having trouble controlling the space between lines of text.  I know there were a couple earlier discussions about a bug related to paragraph style with text within table cells, but I am not drawing a table.  My code is below:

 

		$word = new PHPWord();
		$properties = $word->getProperties();
		
		$properties = $word->getProperties();
		$properties->setCreator(auth()->getRecord()->getTitle()); 
		$properties->setCompany('Testing Company');
		$properties->setTitle('');
		$properties->setDescription(''); 
		$properties->setCategory('');
		$properties->setLastModifiedBy(auth()->getRecord()->getTitle());
		$properties->setCreated( time() );
		$properties->setModified( time() );
		
		$word->setDefaultFontName('Georgia');
		$word->setDefaultFontSize('12');
		
		// 'normal' font and paragraph styles
		$word->addFontStyle('normal', array('color' => '#000000', 'name' => 'Georgia', 'size' => 12, 'bold' => false));
		$word->addParagraphStyle('normal', array('align' => 'left', 'spaceBefore' => 0, 'spaceAfter' => 0, 'spacing' => 0));
		
		// 'big heading' font and paragraph styles
		$word->addFontStyle('bigHeading', array('color' => '#000000', 'name' => 'Georgia',  'size' => 16, 'bold' => true));
		$word->addParagraphStyle('bigHeading', array('align' => 'center', 'spaceBefore' => 0, 'spaceAfter' => 0, 'spacing' => 0));

		// heading
		$s = $word->createSection();
		$s->addText("Executive Summary for Elmer Fudd", 'bigHeading', 'bigHeading');
		$s->addText("Name: Elmer Fudd", 'normal', 'normal');
		$s->addText("Age: 49", 'normal', 'normal');
		$s->addText("Date of Admission: 4/9/11, 'normal', 'normal');
		$s->addText("Date of Evaluation: 5/1/11", 'normal', 'normal');

 

This is resulting in a document with 10pt spacing after each line, as seen here:  

http://img28.imageshack.us/img28/9774/screenshotzuf.png

 

This is with Word in Office Professional 2010 Plus.  Any help would be greatly appreciated.  

 

Thanks!

Jun 3, 2011 at 10:40 PM

Okay, after messing with it a bit, it appears that font and paragraph style names cannot collide.  So, I'm now doing:

 

// 'normal' font and paragraph styles
$word->addFontStyle('fNormal', array('color' => '#000000', 'name' => 'Georgia', 'size' => 12, 'bold' => false));
$word->addParagraphStyle('pNormal', array('align' => 'left', 'spaceBefore' => 0, 'spaceAfter' => 0, 'spacing' => 0));
	
// 'big heading' font and paragraph styles
$word->addFontStyle('fBigHeading', array('color' => '#000000', 'name' => 'Georgia',  'size' => 16, 'bold' => true));
$word->addParagraphStyle('pBigHeading', array('align' => 'center', 'spaceBefore' => 0, 'spaceAfter' => 0, 'spacing' => 0));


And that works.