php com word set font and font size

// 打开word 编辑
        $file = 'C:/Users/Administrator/Desktop/11.doc';
        $word = new \com("word.application",null,CP_UTF8) or die("Unable to instantiate Word");
        $word->Visible = 0;
        $word->Documents->Open($file,true,false);
        
        $Paragraphs = $word->ActiveDocument->Paragraphs;
      
        for ($i = 1; $i <= $Paragraphs->Count; $i++) {
             $font = $Paragraphs->Item($i)->Range->Font;
            $font->Name='仿宋_GB2312';
            $font->Size=16;
        }

        $word->ActiveDocument->Save();
        $word->Quit();
        $word = null;

The font size of some documents may be in the form of Chinese characters such as No. 3, small second, etc., then use this method to print it and $font->Sizeconvert it into a number.

Guess you like

Origin blog.csdn.net/wang740209668/article/details/108601638