我正在使用 PHP COM 对象,但我想它在所有其他语言中都是相同的。如何使用 COM / OLE 自动化向 .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);
谢谢。