Home > Back-end >  After the word how to update the catalog page is generated by a freemarker
After the word how to update the catalog page is generated by a freemarker

Time:01-05

Encounter a tricky question, freemarker generated after the word directory page how to update, online, etc., very urgent

CodePudding user response:

A month without bosses manage me

CodePudding user response:

Combined with Jacob can update directory
Package com. Key. Words. Convert;

The import com. Jacob. ActiveX. ActiveXComponent;
The import com.jacob.com.Dispatch;
The import com.jacob.com.Variant;
Public class WordCatalog {

/* *
* directory to generate
* @ param oldPath source file
* @ param wirtePath store path
* @ return
*/
Public static void updateWord (String oldPath, String wirtePath) {
ActiveXComponent app=new ActiveXComponent (" Word. Application ");//start word
Try {
//app. SetProperty (" Visible ", new Variant (true));//set the word invisible
App. SetProperty (" Visible ", new Variant (false));
Dispatch docs=app. GetProperty (" Documents "). ToDispatch ();

Dispatch doc=Dispatch. Invoke (docs, "Open", Dispatch Method,
The new Object [] {oldPath, new Variant (false), the new Variant (true)}, new int [1]). ToDispatch ();
Dispatch activeDocument=app. GetProperty (" activeDocument "). ToDispatch ();
/* *
* part of the code update directory
*
* access catalog */
Dispatch tablesOfContents=Dispatch. Get (activeDocument, "tablesOfContents"). The toDispatch ();
/* * get the first catalogue, if you have multiple directories, then transfer the corresponding parameter */
The Variant tablesOfContent=Dispatch. Call (tablesOfContents, "Item", the new Variant (1));
/* * Update catalog, there are two methods: Update to Update the domain, UpdatePageNumbers Update only page */
Dispatch the toc=tablesOfContent. ToDispatch ();
Toc. Call (toc, "Update");

Complete System. Out. Println (" save as ");
Dispatch. Call (doc, "SaveAs", wirtePath);//save file
Dispatch. Call (doc, "Close", the new Variant (false));
System. The out. Println (" is over ");
} the catch (Exception e) {
e.printStackTrace();
} the finally {
App. Invoke (" Quit ", new Variant [] {});
App. SafeRelease ();
}
}

}

CodePudding user response:

Thanks for this I know but this only supports Windows environment in Linux is not supported by the

CodePudding user response:

reference var_Cui reply: 3/f
thanks for this I know but this only supports Windows environment in Linux is not supported by the


CodePudding user response:

Mass update this support? The way I use now is inserted into the directory, but kind of way can not support large files update, can not find a solution...

CodePudding user response:

Mass update you said is what mean??????? Several directory???

CodePudding user response:

refer to the original poster var_Cui response:
encounter a tricky question, freemarker generated after the word directory page how to update, online, etc., very urgent
did you solve the problem
  • Related