Document samples
Basics
Section titled “Basics”On most methods, you’ll see the parameter named “docId” and “fldId”. The values of this parameter can be a valid document and folder UUID respectively.
Suggested code sample
Section titled “Suggested code sample”First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(host);Then should login using the method “login”. You can access the “login” method from webservice object “ws” as is shown below:
ws.login(user, password);At this point you can use all the Document methods from “document” class as is shown below:
ws.document.createDocument("1be884f4-5758-4985-94d1-f18bfe004db8", "logo.png", fs);Methods
Section titled “Methods”createDocument
Section titled “createDocument”Description:
| Method | Return values | Description |
|---|---|---|
| createDocument(String fldId, FileInfo fi) | Document | Creates a new document and returns an object of type Document. |
Parameters:
- fldId is UUID of the folder where the document will be created.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.impl;using System.IO;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password); FileInfo fileInfo = new FileInfo("E:\\doc.docx");ws.document.createDocument(fldId, fileInfo);} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}createDocument
Section titled “createDocument”Description:
| Method | Return values | Description |
|---|---|---|
| createDocument(String uuid, String name, FileStream fs, long nodeClass) | Document | Creates a new document with nodeClass. Return an object Document with the properties of the created document. |
The values of the uuid parameter should be a folder or record node UUID.
The nodeClass parameter should be a valid bussiness type ( serie ) value. A nodeClass with value 0 means there’s no business type ( serie ) selected.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.impl;using System.IO;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password); FileStream fileStream = new FileStream("E:\\logo.png", FileMode.Open);long nodeClass = 0;ws.document.createDocument("4b88cbe9-e73d-45fc-bac0-35e0d6e59e43", "logo.png", fileStream, nodeClass);fileStream.Dispose();} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}createDocument
Section titled “createDocument”Description:
| Method | Return values | Description |
|---|---|---|
| createDocument(String fldId, String name, FileStream fs) | Document | Creates a new document and returns and object of type Document |
Parameters:
- fldId is UUID of the folder where the document will be created.
- name is the name of the document including the extension.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.impl;using System.IO;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);FileStream fileStream = new FileStream("E:\\logo.png", FileMode.Open);ws.document.createDocument(fldId, "logo.png", fileStream);fileStream.Dispose();} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}deleteDocument
Section titled “deleteDocument”Description:
| Method | Return values | Description |
|---|---|---|
| deleteDocument(String docId) | void | Deletes a document. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.impl;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.deleteDocument("f123a950-0329-4d62-8328-0ff500fd42db");} catch (Exception e) {System.Console.WriteLine(e.ToString());}
System.Console.ReadKey();}}}getDocumentProperties
Section titled “getDocumentProperties”Description:
| Method | Return values | Description |
|---|---|---|
| getDocumentProperties(String docId) | Document | Returns the document properties. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.impl;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine(ws.document.getDocumentProperties("f123a950-0329-4d62-8328-0ff500fd42db").toString());} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getContent
Section titled “getContent”Description:
| Method | Return values | Description |
|---|---|---|
| getContent(String docId) | Stream | Retrieves a document content - binary data - of the actual document version. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.impl;using System.IO;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Stream tmpFile = ws.document.getContent("f123a950-0329-4d62-8328-0ff500fd42db");FileStream destFile = new FileStream("C:\\test.png", FileMode.OpenOrCreate);tmpFile.CopyTo(destFile);destFile.Close();tmpFile.Close();} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getContentByVersion
Section titled “getContentByVersion”Description:
| Method | Return values | Description |
|---|---|---|
| getContentByVersion(String docId,String versionId) | Stream | Retrieves a document content ( binary data ) of some specific document version. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using System.IO;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Stream tmpFile = ws.document.getContentByVersion("f123a950-0329-4d62-8328-0ff500fd42db","1.1");FileStream destFile = new FileStream("C:\\test.png", FileMode.OpenOrCreate);tmpFIle.CopyTo(destFile);destFile.Close();tmpFile.Close();} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getDocumentChildren
Section titled “getDocumentChildren”Description:
| Method | Return values | Description |
|---|---|---|
| getDocumentChildren(String fldId) | List |
Returns a list of all documents which their parent is fldId. |
The parameter fldId can be a folder or a record node.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (Document doc in ws.document.getDocumentChildren("f123a950-0329-4d62-8328-0ff500fd42db")){System.Console.WriteLine(doc);}} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}renameDocument
Section titled “renameDocument”Description:
| Method | Return values | Description |
|---|---|---|
| renameDocument(String docId, String newName) | document | Changes the name of a document. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Document doc = ws.document.renameDocument("f123a950-0329-4d62-8328-0ff500fd42db", "new_name.png");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}setProperties
Section titled “setProperties”Description:
| Method | Return values | Description |
|---|---|---|
| setProperties(String docId, String title, String description, String lang, List |
void | Changes some document properties. |
Variables allowed to be changed:
- Title
- Description
- Language
- Associated categories
- Associated keywords
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);List<string> keywords = new List<string>();keywords.Add("testA");keywords.Add("testB");List<string> categories = new List<string>();categories.Add("/okm:categories");ws.document.setProperties("f123a950-0329-4d62-8328-0ff500fd42db", "anyTitle", "anyDescription", "es-ES", keywords, categories);} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}setDocumentNodeClass
Section titled “setDocumentNodeClass”Description:
| Method | Return values | Description |
|---|---|---|
| setDocumentNodeClass(String docId, String ncId) | void | Set document node class ID. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.setDocumentNodeClass("f123a950-0329-4d62-8328-0ff500fd42db",ncID);} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}checkout
Section titled “checkout”Description:
| Method | Return values | Description |
|---|---|---|
| checkout(String docId) | void | Marks the document for the edition. |
Only one user can modify a document at the same time.
Before starting edition you must do a check-out action that locks the edition process for other users and allows only to the user who has executed the action.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.checkout("f123a950-0329-4d62-8328-0ff500fd42db");// At this point the document is locked for other users except for the user who executed the action} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}cancelCheckout
Section titled “cancelCheckout”Description:
| Method | Return values | Description |
|---|---|---|
| cancelCheckout(String docId) | void | Cancel a document edition. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);// At this point the document is locked for other users except for the user who executed the actionws.document.cancelCheckout("f123a950-0329-4d62-8328-0ff500fd42db");// At this point other users are allowed to execute a checkout and modify the document} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}forceCancelCheckout
Section titled “forceCancelCheckout”Description:
| Method | Return values | Description |
|---|---|---|
| forceCancelCheckout(String docId) | void | Cancels a document edition. |
This method allows canceling the edition on any document.
It is not mandatory to execute this action by the same user who previously executed the checkout action.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);// At this point the document is locked for other users except for the user who executed the actionws.document.forceCancelCheckout("f123a950-0329-4d62-8328-0ff500fd42db");// At this point other users are allowed to execute a checkout and modify the document} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}isCheckedOut
Section titled “isCheckedOut”Description:
| Method | Return values | Description |
|---|---|---|
| isCheckedOut(String docId) | Boolean | Returns a boolean that indicates if the document is being edited or not. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine("Is the document checkout:"+ ws.document.isCheckedOut("f123a950-0329-4d62-8328-0ff500fd42db").ToString());} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}checkin
Section titled “checkin”Description:
| Method | Return values | Description |
|---|---|---|
| checkin(String docId, String comment, FileStream fs) | Version | Updates a document with a new version and returns an object with new Version values. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);FileStream fs = new FileStream("E:\\logo.png", FileMode.Open);ws.document.checkin("f123a950-0329-4d62-8328-0ff500fd42db","optional some comment",fs);fs.Dispose();} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}checkin
Section titled “checkin”Description:
| Method | Return values | Description |
|---|---|---|
| checkin(String docId, String comment, FileStream fs, int increment) | Version | Updates a document with a new version and returns an object with new Version values. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);FileStream fs = new FileStream(@"C:\Desktop\logo.png", FileMode.Open);ws.document.checkin("f123a950-0329-4d62-8328-0ff500fd42db", "optional some comment", fs, 1);fs.Dispose();} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}lockDocument
Section titled “lockDocument”Description:
| Method | Return values | Description |
|---|---|---|
| lockDocument(String docId) | LockInfo | Locks a document and returns an object with the Lock information. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.lockDocument("f123a950-0329-4d62-8328-0ff500fd42db");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}unlockDocument
Section titled “unlockDocument”Description:
| Method | Return values | Description |
|---|---|---|
| unlockDocument(String docId) | void | Unlocks a locked document. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.unlockDocument("f123a950-0329-4d62-8328-0ff500fd42db");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}forceUnlockDocument
Section titled “forceUnlockDocument”Description:
| Method | Return values | Description |
|---|---|---|
| forceUnlockDocument(String docId) | void | Unlocks a locked document. |
This method allows unlocking any locked document.
It is not mandatory to execute this action by the same user who previously executed the checkout lock action.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.forceUnlockDocument("f123a950-0329-4d62-8328-0ff500fd42db");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}isLocked
Section titled “isLocked”Description:
| Method | Return values | Description |
|---|---|---|
| isLocked(String docId) | Boolean | Returns a boolean that indicates if the document is locked or not. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine("Is document locked:" + ws.document.isLocked("f123a950-0329-4d62-8328-0ff500fd42db").ToString());} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getLockInfo
Section titled “getLockInfo”Description:
| Method | Return values | Description |
|---|---|---|
| getLockInfo(String docId) | LockInfo | Returns an object with the Lock information |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine(ws.document.getLockInfo("f123a950-0329-4d62-8328-0ff500fd42db"));} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}purgeDocument
Section titled “purgeDocument”Description:
| Method | Return values | Description |
|---|---|---|
| purgeDocument(String docId) | void | The document is definitely removed from repository. |
Usually, you will purge documents into /okm:trash/userId - the personal trash user locations - but is possible to directly purge any document from the whole repository.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.purgeDocument("f123a950-0329-4d62-8328-0ff500fd42db");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}moveDocument
Section titled “moveDocument”Description:
| Method | Return values | Description |
|---|---|---|
| moveDocument(String docId, String dstId) | void | Moves a document into a folder or record. |
The values of the dstId parameter should be a folder or record UUID or path.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.moveDocument("f123a950-0329-4d62-8328-0ff500fd42db", fldId);} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}copyDocument
Section titled “copyDocument”Description:
| Method | Return values | Description |
|---|---|---|
| copyDocument(String docId, String fldId, String newName) | Document | Copies a document into a folder or record. |
The values of the fldId parameter should be a folder or record UUID.
When parameter newName value is null, the document will preserve the same name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.copyDocument("f123a950-0329-4d62-8328-0ff500fd42db", fldId, "name.png");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getVersionHistorySize
Section titled “getVersionHistorySize”Description:
| Method | Return values | Description |
|---|---|---|
| getVersionHistorySize(String docId) | long | Returns the sum in bytes of all documents into documents history. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password); long byteCount = ws.document.getVersionHistorySize(docUUid);string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EBlong bytes = Math.Abs(byteCount);int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));double num = Math.Round(bytes / Math.Pow(1024, place), 1);System.Console.WriteLine((Math.Sign(byteCount) * num).ToString() + suf[place]);} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}isValidDocument
Section titled “isValidDocument”Description:
| Method | Return values | Description |
|---|---|---|
| isValidDocument(String docId) | Boolean | Returns a boolean that indicates if the node is a document or not. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);// Return truews.document.isValidDocument("f123a950-0329-4d62-8328-0ff500fd42db");
// Return falsews.document.isValidDocument("/okm:root");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getDocumentPath
Section titled “getDocumentPath”Description:
| Method | Return values | Description |
|---|---|---|
| getDocumentPath(String docId) | String | Converts a document UUID to a document path. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine(ws.document.getDocumentPath("e339f14b-4d3a-489c-91d3-05e4575709d2"));} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}extendedDocumentCopy
Section titled “extendedDocumentCopy”Description:
| Method | Return values | Description |
|---|---|---|
| extendedDocumentCopy(String docId, String fldId, String name, bool categories, boolean keywords, bool propertyGroups, bool notes, bool wiki, bool security) |
void | Copies a document with associated data into a folder or record. |
The values of the nodeId parameter should be a Document UUID.
The values of the dstId parameter should be a folder or a record UUID.
When parameter newName value is null, the document will preserve the same name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password); ws.document.extendedDocumentCopy("f123a950-0329-4d62-8328-0ff500fd42db", "d1cad1b0-3c4f-4ad3-8ee1-6ad779fa227c", "newDoc.docx", true, true, true, true, true, true);} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getExtractedText
Section titled “getExtractedText”Description:
| Method | Return values | Description |
|---|---|---|
| getExtractedText(String docId) | String | Returns a String with the extracted text by text extractor process. |
When a document is uploaded into OpenKM goes into text extraction queue. There’s a crontab tab that periodically processes this queue and extracts document contents.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine(ws.document.getExtractedText("f123a950-0329-4d62-8328-0ff500fd42db"));} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}setExtractedText
Section titled “setExtractedText”Description:
| Method | Return values | Description |
|---|---|---|
| setExtractedText(String uuid, FileStream fileStream) | void | Set extracted text |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);FileStream fs = new FileStream(@"C:\test.pdf", FileMode.Open, FileAccess.Read);ws.document.setExtractedText("f123a950-0329-4d62-8328-0ff500fd42db", fs);fs.Close();} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getThumbnail
Section titled “getThumbnail”Description:
| Method | Return values | Description |
|---|---|---|
| getThumbnail(String docId, ThumbnailType type) | Stream | Returns a thumbnail image data. |
Available types:
- ThumbnailType.THUMBNAIL_PROPERTIES ( shown in properties view )
- ThumbnailType.THUMBNAIL_LIGHTBOX ( shown in light box )
- ThumbnailType.THUMBNAIL_SEARCH ( shown in search view )
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using System.IO;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Stream st = ws.document.getThumbnail("f123a950-0329-4d62-8328-0ff500fd42db", ThumbnailType.THUMBNAIL_LIGHTBOX);} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}setLanguage
Section titled “setLanguage”Description:
| Method | Return values | Description |
|---|---|---|
| setLanguage(String docId, String lang) | void | Sets a document language. |
The parameter lang must be ISO 691-1 compliant.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.setLanguage("f123a950-0329-4d62-8328-0ff500fd42db", "es-ES");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}setDocumentTitle
Section titled “setDocumentTitle”Description:
| Method | Return values | Description |
|---|---|---|
| setDocumentTitle(String docId, String title) | void | Sets a document title. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.setDocumentTitle("f123a950-0329-4d62-8328-0ff500fd42db", "Some title here");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}createDocumentFromTemplate
Section titled “createDocumentFromTemplate”Description:
| Method | Return values | Description |
|---|---|---|
| createDocumentFromTemplate(String uuid, String dstPath , Boolean categories, Boolean keywords, Boolean notes, Boolean security, Dictionary<String, String> properties) | Document | Creates a new document from a template and returns an object Document. |
The uuid parameter is the UUID value of the template file.
The dstPath value is the document destination path.
When the template uses metadata groups to fill in fields, then these values are mandatory and must be set into properties parameter.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.util;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Dictionary<String, String> properties = new Dictionary<String, String>();properties.Add("okp:tpl.name", "Some name");DateTime date = DateTime.Now;// Value must be converted to String ISO 8601 compliantproperties.Add("okp:tpl.bird_date", ISO8601.formatBasic(date));properties.Add("okp:tpl.language", "java");ws.document.createFromTemplate("f123a950-0329-4d62-8328-0ff500fd42db", "/okm:root/test.pdf", false, false, false, false, properties);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}updateDocumentFromTemplate
Section titled “updateDocumentFromTemplate”Description:
| Method | Return values | Description |
|---|---|---|
| updateDocumentFromTemplate(String uuid, String dstId, Map<String, String> properties) | Document | Updates a document previously created from a template and returns an object Document. |
The uuid value is the UUID value of the template file.
The dstId is the document to updated UUID.
This method only has a sense when template use metadata groups to fill fields into.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.util;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Dictionary<String, String> properties = new Dictionary<String, String>();properties.Add("okp:tpl.name", "Some name");DateTime date = DateTime.Now;// Value must be converted to String ISO 8601 compliantproperties.Add("okp:tpl.bird_date", ISO8601.formatBasic(date));properties.Add("okp:tpl.language", "java");
ws.document.updateFromTemplate("9fa9787e-d8b0-4ff7-905a-a89f0b228ec8", "058b9379-b441-454d-8590-00d5a280ce79", properties);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getDetectedLanguages
Section titled “getDetectedLanguages”Description:
| Method | Return values | Description |
|---|---|---|
| getDetectedLanguages() | List |
Return a list of available document languages what OpenKM can identify. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);foreach (String lang in ws.document.getDetectedLanguages()){System.Console.WriteLine(lang);}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getAnnotations
Section titled “getAnnotations”Description:
| Method | Return values | Description |
|---|---|---|
| getAnnotations(String docId, String verName) | String | Return the document annotations of some document version. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine(ws.document.getAnnotations("2b9721e7-f186-4eea-ad61-42c97353548f", "1.0"));}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getDifferences
Section titled “getDifferences”Description:
| Method | Return values | Description |
|---|---|---|
| getDifferences(String docId, String v1, String v2) | Stream | Return a PDF document with the differences between two document versions. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.util;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);BeanHelper beanHelper = new BeanHelper();Stream stream = ws.document.getDifferences("22799885-973f-46dc-a82c-dd11d2c65c65", "1.0", "1.1");Byte[] data = beanHelper.ReadToEnd(stream);FileStream fileStream = new FileStream(@"C:\Desktop\out.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite);foreach (byte b in data){fileStream.WriteByte(b);}fileStream.Close();}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getCheckedOut
Section titled “getCheckedOut”Description:
| Method | Return values | Description |
|---|---|---|
| getCheckedOut() | List |
Return a list of documents checkout by the user. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);List<Document> docs = ws.document.getCheckedOut();foreach (Document doc in docs){System.Console.WriteLine(doc.toString());}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}setDocumentDescription
Section titled “setDocumentDescription”Description:
| Method | Return values | Description |
|---|---|---|
| setDocumentDescription(String docId, String description) | void | Sets a document description. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.setDocumentDescription("f123a950-0329-4d62-8328-0ff500fd42db", "Some description here");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}setDocumentDispositionStage
Section titled “setDocumentDispositionStage”Description:
| Method | Return values | Description |
|---|---|---|
| setDocumentDispositionStage(String docId, long stage) | void | Sets a document disposition stage. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password); long stage = 1;ws.document.setDocumentDispositionStage("f123a950-0329-4d62-8328-0ff500fd42db", stage);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}createWizardDocument
Section titled “createWizardDocument”Description:
| Method | Return values | Description |
|---|---|---|
| createWizardDocument(String docId, long stage) | WizardNode | Create a document with wizard. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password); FileStream fs = new FileStream(LOCAL_DOC, FileMode.Open, FileAccess.Read); long nodeClass= 1;WizardNode wizardNode = ws.document.createWizardDocument("f123a950-0329-4d62-8328-0ff500fd42db","test.docx", nodeClass, fs); fs.Close();}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}isOCRDataCaptureSupported
Section titled “isOCRDataCaptureSupported”Description:
| Method | Return values | Description |
|---|---|---|
| isOCRDataCaptureSupported(String docId) | boolean | Check if the node supports an OCR data capture. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);if(ws.document.isOCRDataCaptureSupported("f123a950-0329-4d62-8328-0ff500fd42db")){System.Console.WriteLine("Yes supported OCR Data capture");}else{System.Console.WriteLine("No supported OCR Data capture");}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}recognize
Section titled “recognize”Description:
| Method | Return values | Description |
|---|---|---|
| recognize(String docId) | OCRRecognise | Return an OCRRecognise object. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);OCRRecognise ocr = ws.document.recognize("f123a950-0329-4d62-8328-0ff500fd42db");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}captureData
Section titled “captureData”Description:
| Method | Return values | Description |
|---|---|---|
| captureData(String docId, long templateId) | void | Proceed to the OCR data capture using OCR template identified by templateId. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);long templateId = 1;ws.document.captureData("f123a950-0329-4d62-8328-0ff500fd42db", templateId);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getNumberOfPages
Section titled “getNumberOfPages”Description:
| Method | Return values | Description |
|---|---|---|
| getNumberOfPages(String docId) | int | Get the number of pages of a document. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine("The number of pages is : " + ws.document.getNumberOfPages("f123a950-0329-4d62-8328-0ff500fd42db").ToString());}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getPageAsImage
Section titled “getPageAsImage”Description:
| Method | Return values | Description |
|---|---|---|
| getPageAsImage(String uuid, int pageNumber, int maxWidth, int maxHeight) | String | Return specific page as an image encoded as a String in b64. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.WriteLine(ws.document.getPageAsImage("f123a950-0329-4d62-8328-0ff500fd42db", 1, 150, 150));}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}mergePdf
Section titled “mergePdf”Description:
| Method | Return values | Description |
|---|---|---|
| mergePdf(String destinationUuid, String docName, List |
String | Merge two or more PDF files. |
The parameters destinationUuid should be any valid folder or record UUID.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);List<string> uuids = new List<string>();uuids.Add("a978f8e6-aa87-4f0f-b7bc-6f44cb090fdf");uuids.Add("56a6d75f-563e-4ccd-ace6-d07d7860bae5");string folderUuid = "15e35aef-f1bb-451e-ac86-3b0f7c88ca9f";string uuid = ws.document.mergePdf(folderUuid, "MergePdf.pdf", uuids);Document mergePdf = ws.document.getDocumentProperties(uuid);Console.WriteLine(mergePdf.path);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getLiveEditRestrictedMimeTypes
Section titled “getLiveEditRestrictedMimeTypes”Description:
| Method | Return values | Description |
|---|---|---|
| getLiveEditRestrictedMimeTypes() | List |
Return a list of mime types that can not be used with the live edit feature. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);List<String> mymeTypes = ws.document.getLiveEditRestrictedMimeTypes();}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}liveEditCheckin
Section titled “liveEditCheckin”Description:
| Method | Return values | Description |
|---|---|---|
| liveEditCheckin(String uuid, String comment, int increment) | void | It does a checkin. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.liveEditCheckin("8b9a32c8-db65-41c8-a2a0-af03761f60b6", "Any comment", 1);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}liveEditSetContent
Section titled “liveEditSetContent”Description:
| Method | Return values | Description |
|---|---|---|
| liveEditSetContent(String uuid, FileStream fs | void | Update the content of the document edited with live edit feature. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);FileStream fs = new FileStream(@"D:\Test.pdf", FileMode.Open, FileAccess.Read);ws.document.liveEditSetContent("1ec49da9-1746-4875-ae32-9281d7303a62", fs); fs.Close();}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}IsAttachment
Section titled “IsAttachment”Description:
| Method | Return values | Description |
|---|---|---|
| isAttachment(String docId) | Boolean | Returns a boolean that indicates if the node is a mail attachment or not. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.Writeline(ws.document.isAttachment("1ec49da9-1746-4875-ae32-9281d7303a62").ToString());}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}isConvertibleToPDF
Section titled “isConvertibleToPDF”Description:
| Method | Return values | Description |
|---|---|---|
| isConvertibleToPDF(String docId) | Boolean | Returns a boolean that indicates if the node is convertible to PDF or not. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);System.Console.Writeline(ws.document.isConvertibleToPDF("1ec49da9-1746-4875-ae32-9281d7303a62").ToString());}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}forceLockDocument
Section titled “forceLockDocument”Description:
| Method | Return values | Description |
|---|---|---|
| forceLockDocument(String uuid) | LockInfo | Locks a document and returns an object with the Lock information. |
This method allows to lock any document.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);LockInfo lockInfo = ws.document.forceLockDocument("1ec49da9-1746-4875-ae32-9281d7303a62")System.Console.Writeline("Author:" + lockInfo.owner);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}getDocumentPdf
Section titled “getDocumentPdf”Description:
| Method | Return values | Description |
|---|---|---|
| getDocumentPdf(String uuid) | Stream | Returns a PDF of the document. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.impl;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Document doc = ws.document.getDocumentProperties("4b88cbe9-e73d-45fc-bac0-35e0d6e59e43");Stream stream = ws.document.getDocumentPdf(doc.uuid);FileStream docFile = new FileStream("D:\\test.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite);stream.CopyTo(docFile);stream.Close();docFile.Close();}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}saveDocumentAsPdf
Section titled “saveDocumentAsPdf”Description:
| Method | Return values | Description |
|---|---|---|
| saveDocumentAsPdf(String uuid, String newName, bool propertyGroups, bool security) | Document | Save the document as PDF in the OpenKM repository. |
The value of the uuid parameter should be a Document UUID.
When the parameter newName value is null, the document will preserve the same name.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.impl;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);Document doc = ws.document.getDocumentProperties("4b88cbe9-e73d-45fc-bac0-35e0d6e59e43");Document docPdf = ws.document.saveDocumentAsPdf(doc.uuid, "test.pdf", true, true);System.Console.WriteLine("Document pdf: " + docPdf.path);}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}webPageImport
Section titled “webPageImport”Description:
| Method | Return values | Description |
|---|---|---|
| webPageImport(String uuid, String url) | void | Save the content of a web page as a document as a PDF in the OpenKM repository. |
The value of the uuid parameter should be a folder or record node UUID.
The value of the url parameter should be a valid web page URL.
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using com.openkm.sdk4csharp.impl;
namespace OKMRest{public class Program{static void Main(string[] args){String host = "http://localhost:8080/openkm";String username = "okmAdmin";String password = "admin";OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try{ws.login(user, password);ws.document.webPageImport("271cc3aa-218e-4574-8065-c34c704f4a20", "https://www.google.com/");}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}