0
我正在嘗試使用PHPWord創建word文件。我已經設置了一些字體樣式和段落樣式。即使沒有給出文本打破,我在行1和行2之間得到6行空白。有什麼建議?抑制PHPWord中兩行文本之間的空白
這裏是我的代碼
$this->word->addFontStyle('titleStyle', array('bold' => true, 'size' => 16, 'name'=>'Calibri'));
$this->word->addFontStyle('lineStyle', array('align'=>'left','size' => 10, 'name'=>'Calibri'));
$this->word->addParagraphStyle('pStyle', array('align' => 'center', 'spaceBefore' => 0, 'spaceAfter' => 0, 'spacing' => 0));
$section = $this->word->createSection(array('breakType'=>'continuous'));
// Simple text
$section->addText('Text Document','titleStyle','pStyle');
$section->addText('Line1 : ','lineStyle');
$section->addText('Line2 : ','lineStyle');
$section->addText('Line3 : ','lineStyle');
$section->addText('Line4 : ','lineStyle');
$filename='NewDoc.docx'; //save our document as this file name
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); //mime type
header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
$objWriter = PHPWord_IOFactory::createWriter($this->word, 'Word2007');
$objWriter->save('php://output');
任何幫助將不勝感激。
你的問題中的代碼片段(當用一些常量字符串替換$ line1等)沒有爲我創建任何額外的空格或行。你的變量中是否有可能導致多餘行的內容? – ejuhjav
那麼,現在我已經刪除了所有的變量,並使用簡單的常量字符串,如你已經嘗試過。但我仍然遇到同樣的問題。我已經更新了我的代碼。可能是我正在使用不同版本的PHPWord比你。我從gitHUb下載了一個。 – KloppForKop
是的,我使用0.12.0這不是最新的 - 所以如果你使用的0.13.0版本可能會有一些差異... – ejuhjav