Document samples

Basics

On most methods, you'll see the parameter named "docId" and "fldId". The values of these parameters can be valid document and folder UUIDs respectively.

Example of docId:

  • Using UUID -> "f123a950-0329-4d62-8328-0ff500fd42db";

Suggested code sample

First, you must create the webservice object:

OKMWebservices ws = OKMWebservicesFactory.newInstance(host);

Then you should log in using the "login" method. You can access the "login" method on the webservice object "ws" as shown below:

ws.login(user, password);

Once you are logged in with the webservices, the session is kept in the webservice object. Then you can use the other API methods.

At this point you can use all the Document methods from "document" class as shown below:

ws.document.create("1be884f4-5758-4985-94d1-f18bfe004db8", "logo.png", fs);

Methods

create

Description:

Method Return values Description

create(String fldId, FileInfo fi)

Document

Creates a new document and returns an object of type Document.

Parameters:

  • fldId is the 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.create(fldId, fileInfo); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

create

Description:

Method Return values Description

create(String uuid, String name, FileStream fs, long nodeClass)

Document

Creates a new document with nodeClass. Returns a Document object 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 business type (series) value. A nodeClass value of 0 means there's no business type (series) 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.create("4b88cbe9-e73d-45fc-bac0-35e0d6e59e43", "logo.png", fileStream, nodeClass);
fileStream.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

create

Description:

Method Return values Description

create(String fldId, String name, FileStream fs)

Document

Creates a new document and returns an object of type Document.

Parameters:

  • fldId is the 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.create(fldId, "logo.png", fileStream); fileStream.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

delete

Description:

Method Return values Description

delete(String docId)

void

Deletes a document.

When a document is deleted it is automatically moved to /okm:trash/userId folder.

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.delete("f123a950-0329-4d62-8328-0ff500fd42db"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); }
             System.Console.ReadKey(); } } }

getProperties

Description:

Method Return values Description

getProperties(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.getProperties("f123a950-0329-4d62-8328-0ff500fd42db").toString()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getContent

Description:

Method Return values Description

getContent(String docId)

Stream

Retrieves a document's content (binary data) of the current document version.

If you send the file across a Servlet response, we suggest setting the content length with:

Document doc = ws.getDocumentProperties(docId);
response.setContentLength(new Long(doc.getActualVersion().getSize()).intValue());

We've found incorrect size problems while using:

response.setContentLength(is.available());

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

Description:

Method Return values Description

getContentByVersion(String docId,String versionId)

Stream

Retrieves a document's content (binary data) of a specific document version.

If you send the file across a Servlet response, we suggest setting the content length with:

Document doc = ws.getDocumentProperties(docId);
response.setContentLength(new Long(doc.getActualVersion().getSize()).intValue());

We've found incorrect size problems while using:

response.setContentLength(is.available());

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()); } } } }

getChildren

Description:

Method Return values Description

getChildren(String fldId)

List<Document>

Returns a list of all documents whose 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.getChildren("f123a950-0329-4d62-8328-0ff500fd42db")) { System.Console.WriteLine(doc); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

rename

Description:

Method Return values Description

rename(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.rename("f123a950-0329-4d62-8328-0ff500fd42db", "new_name.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setProperties

Description:

Method Return values Description

 setProperties(String docId, String title, String description, String lang, List<String> keywords, List<String> categories)

void

Changes some document properties.

Variables allowed to be changed:

  • Title
  • Description
  • Language
  • Associated categories
  • Associated keywords

Only non-null and non-empty variables will be taken into consideration.

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()); } } } }

setNodeClass

Description:

Method Return values Description

 setNodeClass(String docId,  String ncId)

void

Sets the 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.setNodeClass("f123a950-0329-4d62-8328-0ff500fd42db",ncID); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

checkout

Description:

Method Return values Description

 checkout(String docId)

void

Marks the document for editing.

Only one user can modify a document at the same time.

Before starting editing, you must perform a check-out action that locks the editing process for other users and allows only the user who 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

Description:

Method Return values Description

cancelCheckout(String docId)

void

Cancels a document edition.

This action can only be done by the 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 action ws.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

Description:

Method Return values Description

forceCancelCheckout(String docId)

void

Cancels a document edition.

This method allows canceling the edition of any document.

It is not mandatory for the same user who previously executed the checkout action to perform this action.

This action can only be done by a superuser (user with ROLE_ADMIN).

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 action ws.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

Description:

Method Return values Description

isCheckedOut(String docId)

Boolean

Returns a boolean indicating whether the document is being edited.

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

Description:

Method Return values Description

checkin(String uuid, FileStream fs, String comment)

Version

Updates a document with a new version and returns an object with the new Version values.

Only the user who started the edition (checkout) is allowed to update the document.

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",fs,"optional some comment"); fs.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

checkin

Description:

Method Return values Description

checkin(String uuid, FileStream fs, String comment, int increment)

Version

Updates a document with a new version and returns an object with new Version values.

The value of the increment variable must be 1 or greater.

The valid values of the increment variable depend on the VersionNumberAdapter you have enabled.


Only the user who started the edition - checkout - is allowed to update the document.

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", fs, "optional some comment", 1); fs.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

purge

Description:

Method Return values Description

purge(String docId)

void

The document is permanently removed from the repository.

Usually, you will purge documents into /okm:trash/userId - the user's personal trash location - but it is possible to directly purge any document from the whole repository.

When a document is purged it can only be restored from a previous repository backup. The purge action removes the document permanently from the 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.purge("f123a950-0329-4d62-8328-0ff500fd42db"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

move

Description:

Method Return values Description

move(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.move("f123a950-0329-4d62-8328-0ff500fd42db", fldId); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

copy

Description:

Method Return values Description

copy(String uuid, String dstId, 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 the newName parameter value is null, the document will preserve the same name.

Only the binary data and the security grants are copied to the destination; the metadata, keywords, etc., of the document are not copied.

See the "extendedCopy" method for this feature.

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.copy("f123a950-0329-4d62-8328-0ff500fd42db", "0ff500fd42db-0329-4d62-8328-f123a950", "name.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getVersionHistorySize

Description:

Method Return values Description

getVersionHistorySize(String docId)

long

Returns the total size in bytes of all documents in the document 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 EB
long 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()); } } } }

isValid

Description:

Method Return values Description

isValid(String docId)

Boolean

Returns a boolean indicating whether the node is a 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); // Return true ws.document.isValid("f123a950-0329-4d62-8328-0ff500fd42db");
// Return false ws.document.isValidDocument("/okm:root"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getPath

Description:

Method Return values Description

getPath(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.getPath("e339f14b-4d3a-489c-91d3-05e4575709d2")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

extendedCopy

Description:

Method Return values Description

extendedCopy(String nodeId, String dstId, String newName, boolean categories, boolean keywords, boolean propertyGroups, boolean notes, boolean 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 the newName parameter value is null, the document will preserve the same name.

By default, only the binary data and the security grants are copied; the metadata, keywords, etc., of the document are not copied.

Additional:

  • When the categories parameter is true, the original values of the categories will be copied.
  • When the keywords parameter is true, the original values of the keywords will be copied.
  • When the property groups parameter is true, the original values of the metadata groups will be copied.
  • When the notes parameter is true, the original values of the notes will be copied.
  • When the wiki parameter is true, the original values of the wiki will be copied.
  • When the security parameter is true, the original value of the security will be copied.

  

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.extendedCopy("f123a950-0329-4d62-8328-0ff500fd42db", "d1cad1b0-3c4f-4ad3-8ee1-6ad779fa227c", "newName.docx", true, true, true, true, true); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getExtractedText

Description:

Method Return values Description

getExtractedText(String docId)

String

Returns a String with the text extracted by the text extraction process.

When a document is uploaded to OpenKM, it goes into the text extraction queue. There's a crontab that periodically processes this queue and extracts document contents.

Unfortunately, there is not a direct way to know if a document has been processed or not from the API, because this information is only stored at the database level.

Despite this restriction, database queries can be performed via the API by administrator users to retrieve this information. Check Repository samples for accessing database-level information.

More information at Statistics.

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

Description:

Method Return values Description

setExtractedText(String uuid, FileStream fileStream)

void

Sets the 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

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)

Each thumbnail type has its own image dimensions.

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

Description:

Method Return values Description

setLanguage(String docId, String lang)

void

Sets a document language.

The parameter lang must be ISO 639-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()); } } } }

setTitle

Description:

Method Return values Description

setTitle(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.setTitle("f123a950-0329-4d62-8328-0ff500fd42db", "Some title here"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

createFromTemplate

Description:

Method Return values Description

createFromTemplate(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, these values are mandatory and must be set in the properties parameter.

For more information about templates and metadata, take a look at Creating templates.

Additional:

  • When the categories parameter is true, the original values of the categories will be copied.
  • When the keywords parameter is true, the original values of the keywords will be copied.
  • When the notes parameter is true, the original values of the notes will be copied.

Example:

The example below is based on Creating PDF template sample.

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 compliant properties.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, true, properties); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

updateFromTemplate

Description:

Method Return values Description

updateFromTemplate(String uuid, String dstId, Map<String, String> properties) 

Document

Updates a document previously created from a template and returns a Document object.

The uuid value is the UUID value of the template file.

The dstId is the UUID of the document to be updated.

This method only makes sense when the template uses metadata groups to fill fields.

For more information about templates and metadata, take a look at Creating templates.

Example:

The example below is based on the Creating PDF template sample.

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 compliant properties.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

Description:

Method Return values Description

getDetectedLanguages()

List<String>

Returns a list of available document languages that 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

Description:

Method Return values Description

getAnnotations(String docId, String verName)

String

Returns the document annotations for a 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

Description:

Method Return values Description

getDifferences(String docId, String v1, String v2)

Stream

Returns 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

Description:

Method Return values Description

getCheckedOut()

List<Document>

Returns a list of documents checked out 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()); } } } }

setDescription

Description:

Method Return values Description

setDescription(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.setDescription("f123a950-0329-4d62-8328-0ff500fd42db", "Some description here"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setDispositionStage

Description:

Method Return values Description

setDispositionStage(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.setDispositionStage("f123a950-0329-4d62-8328-0ff500fd42db", stage); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

createWizard

Description:

Method Return values Description

createWizard(String docId, long stage) 

WizardNode

Creates a document with a 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.createWizard("f123a950-0329-4d62-8328-0ff500fd42db","test.docx", nodeClass, fs);
  fs.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

isOCRDataCaptureSupported

Description:

Method Return values Description

isOCRDataCaptureSupported(String docId) 

boolean

Checks if the node supports 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

Description:

Method Return values Description

recognize(String docId) 

OCRRecognise

Returns 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

Description:

Method Return values Description

captureData(String docId,  long templateId) 

void

Proceeds with the OCR data capture using the 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

Description:

Method Return values Description

getNumberOfPages(String docId) 

int

Gets 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

Description:

Method Return values Description

getPageAsImage(String uuid, int pageNumber, int maxWidth, int maxHeight) 

String

Returns the specified page as an image encoded as a Base64 string.

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

Description:

Method Return values Description

mergePdf(String destinationUuid, String docName, List<String> uuids) 

String

Merges two or more PDF files.

The parameter destinationUuid should be a 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

Description:

Method Return values Description

getLiveEditRestrictedMimeTypes() 

List<String>

Returns a list of MIME types that cannot 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

Description:

Method Return values Description

liveEditCheckin(String uuid, String comment, int increment)

void

Performs a checkin.

This method should be executed only if the document has been edited 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);
ws.document.liveEditCheckin("8b9a32c8-db65-41c8-a2a0-af03761f60b6", "Any comment", 1);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}

liveEditCancelCheckout

Description:

Method Return values Description

liveEditCancelCheckout(String uuid)

void

Cancels a document edit.

This method should be executed only if the document has been edited with the live edit feature.

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 action
                ws.document.liveEditCancelCheckout("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());
            } 
        }
    }
}

liveEditForceCancelCheckout

Description:

Method Return values Description

liveEditForceCancelCheckout(String uuid)

void

Cancel a document edition.

This method should be executed only if the document has been edited with the live edit feature.

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 action
                ws.document.liveEditForceCancelCheckout("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());
            } 
        }
    }
}

liveEditSetContent

Description:

Method Return values Description

liveEditSetContent(String uuid, FileStream fs

void

Updates the content of the document edited 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);
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

Description:

Method Return values Description

isAttachment(String docId)

Boolean

Returns a boolean indicating whether the node is a mail attachment.

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

Description:

Method Return values Description

isConvertibleToPDF(String docId)

Boolean

Returns a boolean indicating whether the node is convertible to PDF.


In the case of a node of type PDF file, a false value will be returned.

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());
}
}
}
}

getPdf

Description:

Method Return values Description

getPdf(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.getPdf(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());
            } 
        }
    }
}

saveAsPdf

Description:

Method Return values Description

saveAsPdf(String uuid, String newName, bool propertyGroups, bool security)

Document

Saves the document as a PDF in the OpenKM repository.

The value of the uuid parameter should be a Document UUID.

When the value of the newName parameter is null, the document will preserve its name.

Additional:

  • When the propertyGroups parameter is true, the metadata groups of the source are copied to the target.
  • When the security parameter is true, the security of the source is copied to the target.

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.saveAsPdf(doc.uuid, "test.pdf", true, true);
System.Console.WriteLine("Document pdf: " + docPdf.path); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

webPageImport

Description:

Method Return values Description

webPageImport(String uuid, String url)

void

Saves the content of a web page as a PDF document 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()); } } } }

stamp

Description:

Method Return values Description

stamp(String uuid, int type, long stampId)

void

Stamps the document.

The value of the uuid parameter should be a folder or record node UUID.

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);
int type=1;
stampId=1;
ws.document.stamp("271cc3aa-218e-4574-8065-c34c704f4a20", type, stampId); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getXrefs

Description:

Method Return values Description

getXRefs(String uuid)

List<XRef>

Returns a list of document references for a 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);
                foreach (XRef xRef in ws.document.getXrefs("5ce6dd37-7472-404a-878e-274005a2d6db"))
                {
                    Console.WriteLine(xRef.toString());
                }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

refresh

Description:

Method Return values Description

refresh(String uuid)

void

Refreshes the references 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;
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.refresh("5ce6dd37-7472-404a-878e-274005a2d6db");
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}