## 文件信息[](https://phpword.readthedocs.io/en/latest/general.html#document-information "永久鏈接到這個標題")
您可以設置文檔信息,例如標題,創建者和公司名稱。使用以下功能:
~~~
$properties = $phpWord->getDocInfo();
$properties->setCreator('My name');
$properties->setCompany('My factory');
$properties->setTitle('My title');
$properties->setDescription('My description');
$properties->setCategory('My category');
$properties->setLastModifiedBy('My name');
$properties->setCreated(mktime(0, 0, 0, 3, 12, 2014));
$properties->setModified(mktime(0, 0, 0, 3, 14, 2014));
$properties->setSubject('My subject');
$properties->setKeywords('my, key, word');
~~~
## 測量單位[](https://phpword.readthedocs.io/en/latest/general.html#measurement-units "永久鏈接到這個標題")
Open Office XML中的基本長度單位是twip。緹意味著“英寸點的第二十”,即1緹= 1/1440英寸。
您可以使用PHPWord輔助函數將英寸,厘米或點轉換為twip。
~~~
// Paragraph with 6 points space after
$phpWord->addParagraphStyle('My Style', array(
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(6))
);
$section = $phpWord->addSection();
$sectionStyle = $section->getStyle();
// half inch left margin
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
// 2 cm right margin
$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));
~~~
## 文件保護[](https://phpword.readthedocs.io/en/latest/general.html#document-protection "永久鏈接到這個標題")
文檔(或其中的一部分)可以受密碼保護。
~~~
$documentProtection = $phpWord->getSettings()->getDocumentProtection();
$documentProtection->setEditing(DocProtect::READ_ONLY);
$documentProtection->setPassword('myPassword');
~~~
## 打開時自動重新計算字段[](https://phpword.readthedocs.io/en/latest/general.html#automatically-recalculate-fields-on-open "永久鏈接到這個標題")
要強制更新文檔中存在的字段,請將updateFields設置為true
~~~
$phpWord->getSettings()->setUpdateFields(true);
~~~
## 連字[](https://phpword.readthedocs.io/en/latest/general.html#hyphenation "永久鏈接到這個標題")
連字符描述了用連字符打破單詞的過程。有幾種控制連字符的選項。
### 自動連字[](https://phpword.readthedocs.io/en/latest/general.html#auto-hyphenation "永久鏈接到這個標題")
自動連接文本設置`autoHyphenation`為`true`。
~~~
$phpWord->getSettings()->setAutoHyphenation(true);
~~~
### 連續連字符限制[](https://phpword.readthedocs.io/en/latest/general.html#consecutive-hyphen-limit "永久鏈接到這個標題")
可以通過`consecutiveHyphenLimit`選項控制以連字符結尾的連續文本行的最大數量。如果未設置選項或提供的值,則沒有限制`0`。
~~~
$phpWord->getSettings()->setConsecutiveHyphenLimit(2);
~~~
### 連字區[](https://phpword.readthedocs.io/en/latest/general.html#hyphenation-zone "永久鏈接到這個標題")
連字符區域(以*twip為單位*)是在應用連字符之前允許的空白量。連字區越小,連字越多。或者換句話說,連字區域越寬,連詞越少。
~~~
$phpWord->getSettings()->setHyphenationZone(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(1));
~~~
### 連字帽[](https://phpword.readthedocs.io/en/latest/general.html#hyphenate-caps "永久鏈接到這個標題")
要控制是否所有大寫字母的單詞都應使用連字符,請使用doNotHyphenateCaps選項。
~~~
$phpWord->getSettings()->setDoNotHyphenateCaps(true);
~~~