簡體   English   中英

在MS-Office COM對象中添加Word OLE自動化水印

[英]Word OLE Automation Watermark adding in MS-Office COM Object

我正在使用PHP COM對象,但我猜它在所有其他語言中都是相同的。 如何使用COM / OLE Automation將水印添加到.doc / .docx Microsoft Word?

    try
    {
        $word = new COM("word.application") //$word = new COM("C:\\x.docx");
or die(error::asString("couldnt create an instance of word", 20100408.01812, true));

        //bring word to the front
        $word->Visible = 1;

        //open a word document
        $word->Documents->Open($abs_filename);

        $range = $word->ActiveDocument->Content();
        $this->text = iconv('CP1255', 'UTF-8', $range->Text);

        //save the document as html
        // format: 0 - same?, 1 - doc?, 2 - text,  4 - text other encoding, 5 - ?, 6 - rtf , 8 - html
        $word->Documents[1]->SaveAs($result_file_name, 8);

謝謝。

在Word中,啟動一個新的宏,並記錄將水印添加到文檔中所需的步驟。 然后查看生成的宏代碼,並將其轉換為php腳本中的OLE Automation調用。

提示:打開文檔$word->Documents->Open($abs_filename); 您將獲得對該文檔的參考。 與現在一樣,使用該引用比使用ActiveDocumentDocuments[1]更好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM