PDF samples
Basics
Section titled “Basics”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 Pdf methods from “pdf” class as is shown below:
Stream stream = ws.pdf.getImage("e7d6860a-7e0b-4823-bd3d-75f88be1eedf", 1);Methods
Section titled “Methods”getImage
Section titled “getImage”Description:
| Method | Return values | Description |
|---|---|---|
| getImage(String uuid, int page, String size) | Stream | Returns the image of a page. |
The value of the uuid is the UUID of the document.
The page is the number of the page in the document starting from the value “1”.
The size value is optional. When set is used to resize the image of the page, otherwise is used the default value.
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);Stream stream = ws.pdf.getImage("1ec49da9-1746-4875-ae32-9281d7303a62", 1, null);FileStream destFile = new FileStream("D:\\test.png", FileMode.OpenOrCreate, FileAccess.ReadWrite);stream.CopyTo(destFile);destFile.Close();stream.Close();}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}Description:
| Method | Return values | Description |
|---|---|---|
| split(String uuid, String dstId, String baseName, List |
bool | Return true when the pages of the document have been split. |
The value of the uuid is the UUID of the document.
The value of baseName is the base name to create a split document, for example, if baseName value is “test” and pages value is “1,3”, the files created will be “test-001.pdf” and “test-003.pdf”.
The value of pages is the number of pages to be split.
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<int> pages = new List<int>();pages.Add(5);pages.Add(10);bool result = ws.pdf.split("e7d6860a-7e0b-4823-bd3d-75f88be1eedf", "1ec49da9-1746-4875-ae32-9281d7303a62", "split", pages);if(result){System.Console.Writeline("Split done");}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}extract
Section titled “extract”Description:
| Method | Return values | Description |
|---|---|---|
| extract(String uuid, String dstId, String name, List |
bool | Return true when the chosen pages of the document have been extracted. |
The value of the uuid is the UUID of the document.
The value of the dstId is the UUID of the destination ( folder or record ).
The value of name is the name of the new document with extracted pages.
The value of pages is the number of pages to be extracted.
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<int> pages = new List<int>();pages.Add(5);pages.Add(10);bool result = ws.pdf.extract("e7d6860a-7e0b-4823-bd3d-75f88be1eedf", "1ec49da9-1746-4875-ae32-9281d7303a62", "extract", pages);if(result){System.Console.Writeline("Extract done");}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}remove
Section titled “remove”Description:
| Method | Return values | Description |
|---|---|---|
| remove(String uuid, String dstId, String name, List |
bool | Return true when the pages of the document have been removed. |
The value of the uuid is the UUID of the document.
The value of the dstId is the UUID of the destination ( folder or record ).
The value of name is the name of the new document with extracted pages.
The value of pages is the number of pages to be removed.
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<int> pages = new List<int>();pages.Add(5);pages.Add(10);bool result = ws.pdf.remove("e7d6860a-7e0b-4823-bd3d-75f88be1eedf", "1ec49da9-1746-4875-ae32-9281d7303a62", "remove", pages);if(result){System.Console.Writeline("Remove done");}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}rotate
Section titled “rotate”Description:
| Method | Return values | Description |
|---|---|---|
| rotate(String uuid, String dstId, String name, int angle, List |
bool | Return true when the pages of the document have been rotated. |
The value of the uuid is the UUID of the document.
The value of the dstId is the UUID of the destination ( folder or record ).
The value of name is the name of the new document with extracted pages.
The value of angle is rotation applied in the chosen pages..
The value of pages is the number of pages to be rotated.
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<int> pages = new List<int>();pages.Add(5);pages.Add(10);bool result = ws.pdf.rotate("e7d6860a-7e0b-4823-bd3d-75f88be1eedf", "1ec49da9-1746-4875-ae32-9281d7303a62", "rotate", 180, pages);if(result){System.Console.Writeline("Rotate done");}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}insertPages
Section titled “insertPages”Description:
| Method | Return values | Description |
|---|---|---|
| insertPages(String uuid, String srcId, int sourceFromPage, int sourceToPage, int insertFromPage) | bool | Return true when the pages of the document have been inserted. |
The value of the uuid is the UUID of the document.
The value of the srcId is the UUID of the source document.
The value of sourceFromPage indicates from which page number of the source document will be inserted into the document.
The value of sourceToPage indicates up to which page number of the source document is to be inserted into the document.
The value of insertFromPage indicates from which page number the pages will be inserted into the 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);List<int> pages = new List<int>();pages.Add(5);pages.Add(10);bool result = ws.pdf.insertPages("e7d6860a-7e0b-4823-bd3d-75f88be1eedf", "1ec49da9-1746-4875-ae32-9281d7303a62", 5, 10, 1);if(result){System.Console.Writeline("Insert pages done");}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}