on 2015 Apr 01 3:46 AM
Hi Experts,
We try to convert the final contract document docx type conversion become pdf type,and then upload the file to generate a new contract document version.But we encountered the following problems:
1.We use Jacob to do the type conversion,but the program at the time of new ActiveXComponent is not error termination,but in a server directly use Java operation is no problem.We do not konw the reason.
ActiveXComponent app = null;
try {
debugMessage = "Debug:chengxi4:start" ;
logMsg(debugMessage);
app = new ActiveXComponent("Word.Application");
debugMessage = "Debug:chengxi4:new ActiveXComponent" ;
logMsg(debugMessage);
app.setProperty("Visible", false);
Dispatch docs = app.getProperty("Documents").toDispatch();
Dispatch doc = Dispatch.call(docs,//
"Open", //
docFilename,// FileName
false,// ConfirmConversions
true // ReadOnly
).toDispatch();
2.We use the following code to generate a new contract document version,but did not success.
public void addAtta(){
//1. get document version
DocumentVersionIBeanImpl docVersionBean = (DocumentVersionIBeanImpl)doc.getDocVersions().get(0);
//DocumentVersionIBeanImpl docVersionBean = null;
//AssociativeCollectionIfc colli = doc.getDocVersions();
//docVersionBean = (DocumentVersionIBeanImpl) colli.create();
// AttachmentIfc attachment = docVersionBean.getDoc();
//2.create empty New Attachment
AttachmentIfc newAttachment= TypeFactory.createAttachment();
//3. read file to inputstream
InputStream is = null;
try {
is = new FileInputStream("E:\\usr\\sap\\deve_file\\0000449270.pdf");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//4. get ParentObjectReference
ParentObjectReferenceIfc parentRef = TypeFactory.createParentObjectReference(doc);
//5. set context for new attachment
newAttachment.setFileData("chengxi.pdf", is, parentRef, session);
//6. set new version
docVersionBean.setDoc(newAttachment);
}
addAtta();
It only covers the last version of the file,and can not save this change.
Please help to answer the following code what the lack or what is wrong,and how to generate a new version of document in clm(SAP Sourcing) system and save.
Request clarification before answering.
I have to solve second problems.Just add the following line of code can be.
//6. set new version
docVersionBean.setDoc(newAttachment);
colli.add(docVersionBean);
For the first question, is the following sentence code causes the JACOB error(Can't co-create object).I don't konw how to solve.So plan to use JAVA POI.
app = new ActiveXComponent("Word.Application");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.