Skip to content

OKMStamp

Description:

Method Return values Description
calculateStampCoordinates(String token, long imgToStampWidth, long imgToStampHeight, long floatingDivWidth,long floatingDivHeight, String exprX, String exprY, String stampType, String stampAlign) StampCoordinates Returns the calculated stamp coordinates.
  • The parameter stampAlign.
  • The parameter stampAlign is the text alignment

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.util.ContextWrapper;
import com.openkm.ws.rest.util.StampCoordinates;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
// Parameters
long imgToStampWidth = 100;
long imgToStampHeight = 100;
long floatingDivWidth = 250;
long floatingDivHeight = 300;
String exprX = "PAGE_CENTER - IMAGE_WIDTH / 2";
String exprY = "PAGE_MIDDLE - IMAGE_HEIGHT / 2";
String stampType = "text";
String stampAlign = "center";
StampCoordinates stampCoordinates = okmStamp.calculateStampCoordinates(null, imgToStampWidth, imgToStampHeight,
floatingDivWidth, floatingDivHeight, exprX, exprY, stampType, stampAlign);
System.out.println("X = " + stampCoordinates.getX() + ", Y = " + stampCoordinates.getY());
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
calculateStampExpressions(String token, long imgToStampWidth, long imgToStampHeight, long posX, long posY) StampExpressions Returns the calculated stamp expressions for X and Y.

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.util.ContextWrapper;
import com.openkm.ws.rest.util.StampExpressions;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
// Parameters
long imgToStampWidth = 100;
long imgToStampHeight = 100;
long posX = 10;
long posY = 50;
StampExpressions stampExpressions = okmStamp.calculateStampExpressions(null, imgToStampWidth, imgToStampHeight, posX, posY);
System.out.println("X = " + stampExpressions.getExprX() + ", Y = " + stampExpressions.getExprY());
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
stampDocument(String token, long id, int type, String uuid) void Stamps the document.
  • The parameter type.

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
long stampId = 1;
okmStamp.stampDocument(null, stampId, 1, "babe24df-c443-49a5-9453-39dfc9b27924");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
stampTextCustom(String token, String docId, long stId, String exprX, String exprY, String range, String text) void Stamp a document with custom text.

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
long stampId = 3;
String exprX = "PAGE_CENTER - IMAGE_WIDTH / 2";
String exprY = "PAGE_MIDDLE - IMAGE_HEIGHT / 2";
okmStamp.stampImageCustom(null, "babe24df-c443-49a5-9453-39dfc9b27924", stampId, exprX, exprY, "",
"928de61e-6ceb-4f94-bf20-9ba2405c5cee");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
stampImageCustom(String token, String uuid, long id, String exprX, String exprY, String range, byte[] image) void Stamp a document with a custom image.

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.util.ContextWrapper;
import org.apache.commons.io.*;
import java.io.*;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
InputStream is = new FileInputStream("/home/test/image.png");
byte[] image = IOUtils.toByteArray(is);
long stampId = 3;
String exprX = "PAGE_CENTER - IMAGE_WIDTH / 2";
String exprY = "PAGE_MIDDLE - IMAGE_HEIGHT / 2";
okmStamp.stampImageCustom(null, "babe24df-c443-49a5-9453-39dfc9b27924", stampId, exprX, exprY, "", image);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getAllStamps(String token) List Returns a list of stamps.

Example:

package com.openkm;
import java.util.List;
import com.openkm.api.OKMStamp;
import com.openkm.util.ContextWrapper;
import com.openkm.ws.rest.util.StampItem;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
List<StampItem> result = okmStamp.getAllStamps(null);
for (StampItem stampItem : result) {
System.out.println(stampItem.getName());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getStampTextByPk(String token, long itemId, String docId) StampText Returns the stamp object by id.

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.db.bean.StampText;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
int stampId = 1;
StampText stampText = okmStamp.getStampTextByPk(null, stampId, "928de61e-6ceb-4f94-bf20-9ba2405c5cee");
System.out.println(stampText.getName());
System.out.println(stampText.getDescription());
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getStampImageByPk(String token, long id, String docId) StampImage Returns the stamp object by id.

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.db.bean.StampImage;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
int stampId = 3;
StampImage stampImage = okmStamp.getStampImageByPk(null, stampId, "928de61e-6ceb-4f94-bf20-9ba2405c5cee");
System.out.println(stampImage.getName());
System.out.println(stampImage.getDescription());
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getStampBarcodeByPk(String token, long id, String docId) StampBarcode Returns the stamp object by id.

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.db.bean.StampBarcode;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
int stampId = 3;
StampBarcode stampBarcode = okmStamp.getStampBarcodeByPk(null, stampId, "928de61e-6ceb-4f94-bf20-9ba2405c5cee");
System.out.println(stampBarcode.getName());
System.out.println(stampBarcode.getDescription());
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
calculateFlyImageDimensions(String token, String uuid, long imgToStampWidth, long imgToStampHeight,long floatingImageWidth, long floatingImageHeight, int pageNumber) StampImageSize Returns the calculated image dimensions of the stamp.

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.util.ContextWrapper;
import com.openkm.ws.rest.util.StampImageSize;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
// Parameters
long imgToStampWidth = 100;
long imgToStampHeight = 100;
long floatingImageWidth = 300;
long floatingImageHeight = 300;
int pageNumber = 2;
StampImageSize stampImageSize = okmStamp.calculateFlyImageDimensions(null, "babe24df-c443-49a5-9453-39dfc9b27924", imgToStampWidth, imgToStampHeight, floatingImageWidth, floatingImageHeight, pageNumber);
System.out.println(stampImageSize);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getPersonalStamps(String token) List Returns a list of personal seals.

Example:

package com.openkm;
import java.util.List;
import com.openkm.api.OKMStamp;
import com.openkm.bean.Document;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
List<Document> result = okmStamp.getPersonalStamps(null);
for (Document doc : result) {
System.out.println(doc);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getPersonalStampImage(String token, String docId, String imgId, long id) StampPersonalImage Returns the processed personal seal.

Example:

package com.openkm;
import com.openkm.api.OKMStamp;
import com.openkm.util.ContextWrapper;
import com.openkm.ws.rest.util.StampPersonalImage;
public class Test {
public static void main(String[] args) {
try {
OKMStamp okmStamp = ContextWrapper.getContext().getBean(OKMStamp.class);
long stampId = 1;
String imgId = ""; // stamp image id
StampPersonalImage stampPersonalImage = okmStamp.getPersonalStampImage(null, "928de61e-6ceb-4f94-bf20-9ba2405c5cee", imgId, stampId);
System.out.println(stampPersonalImage);
} catch (Exception e) {
e.printStackTrace();
}
}
}