Stamp samples

Methods

getAllStamps

Description:

MethodReturn valuesDescription

getAllStamps()

List<StampItem>

Returns a list of the stamp items

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.StampItem;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            List<StampItem> result = ws.getAllStamps();
            for (StampItem stampItem : result) {
                System.out.println(stampItem.getName());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getStampTextByPk

Description:

MethodReturn valuesDescription

getStampTextByPk(long id, String uuid)

StampText

Return the stamp of type Text by Id.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.StampText;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            int stampId = 1;
            StampText stampText = ws.getStampTextByPk(stampId, "928de61e-6ceb-4f94-bf20-9ba2405c5cee");
            System.out.println(stampText.getName());
            System.out.println(stampText.getDescription());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getStampImageByPk

Description:

MethodReturn valuesDescription

getStampImageByPk(long id, String uuid)

StampImage

Return the stamp of type image by Id.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.StampImage;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            int stampId = 3;
            StampImage stampImage = ws.getStampImageByPk(stampId, "928de61e-6ceb-4f94-bf20-9ba2405c5cee");
            System.out.println(stampImage.getName());
            System.out.println(stampImage.getDescription());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

calculateStampCoordinates

Description:

MethodReturn valuesDescription

calculateStampCoordinates(long imgToStampWidth, long imgToStampHeight, long floatingDivWidth,
            long floatingDivHeight, String exprX, String exprY, String stampType, String stampAlign)

StampCoordinates

Return the calculated stamp coordinates.

In Expr. X and Expr. Y input fields you can put more than a simple number. Currently, the following macros are defined:

  • IMAGE_WIDTH
  • IMAGE_HEIGHT
  • PAGE_WIDTH
  • PAGE_HEIGHT
  • PAGE_CENTER
  • PAGE_MIDDLE

So to center a stamp in the page you can use:

Expr. X

PAGE_CENTER

Expr. Y

PAGE_MIDDLE

The parameter stampAlign.

Available values:

  • text
  • image

The parameter stampAlign is the Text Align

Available values:

  • left
  • center
  • right

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.StampCoordinates;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            // 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 = ws.calculateStampCoordinates(imgToStampWidth, imgToStampHeight,
                    floatingDivWidth, floatingDivHeight, exprX, exprY, stampType, stampAlign);
            System.out.println("X = " + stampCoordinates.getX() + ", Y = " + stampCoordinates.getY());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

calculateStampExpressions

Description:

MethodReturn valuesDescription

calculateStampExpressions(long imgToStampWidth, long imgToStampHeight, long posX, long posY)

StampExpressions

Return the calculated stamp expressions for X and Y.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.StampExpressions;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            // Parameters
            long imgToStampWidth = 100;
            long imgToStampHeight = 100;
            long posX = 10;
            long posY = 50;
            StampExpressions stampExpressions = ws.calculateStampExpressions(imgToStampWidth, imgToStampHeight, posX, posY);
            System.out.println("X = " + stampExpressions.getExprX() + ", Y = " + stampExpressions.getExprY());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

stampText

Description:

MethodReturn valuesDescription

stampText(String uuid, String id)

void

Stamp text in a document.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            String stampId = "1";
            ws.stampText("babe24df-c443-49a5-9453-39dfc9b27924", stampId);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

stampImage

Description:

MethodReturn valuesDescription

stampImage(String uuid, String id)

void

Stamp image in a document.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            String stampId = "3";
            ws.stampImage("babe24df-c443-49a5-9453-39dfc9b27924", stampId);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

stampImageCustom

Description:

MethodReturn valuesDescription

void stampImageCustom(String uuid, String id, String exprX, String exprY, String range, String personalStampUuid)

void

Stamp in a document with a custom image.

The personalStampUuid must be a valid document UUID. The document must be an image ( jpg or png ).

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            String stampId = "3";
            String exprX = "PAGE_CENTER - IMAGE_WIDTH / 2";
            String exprY = "PAGE_MIDDLE - IMAGE_HEIGHT / 2";
            ws.stampImageCustom("babe24df-c443-49a5-9453-39dfc9b27924", stampId, exprX, exprY, "", "928de61e-6ceb-4f94-bf20-9ba2405c5cee");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

calculateFlyImageDimensions

Description:

MethodReturn valuesDescription

calculateFlyImageDimensions(String uuid, long imgToStampWidth, long imgToStampHeight,
            long floatingImageWidth, long floatingImageHeight, int pageNumber)

StampImageSize

Return the calculated image to stamp height and width size.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.StampImageSize;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            // Parameters
            long imgToStampWidth = 100;
            long imgToStampHeight = 100;
            long floatingImageWidth = 300;
            long floatingImageHeight = 300;
            int pageNumber = 2;

            StampImageSize stampImageSize = ws.calculateFlyImageDimensions("babe24df-c443-49a5-9453-39dfc9b27924", imgToStampWidth, imgToStampHeight, floatingImageWidth, floatingImageHeight, pageNumber);
            System.out.println(stampImageSize);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getPersonalStamps

Description:

MethodReturn valuesDescription

getPersonalStamps()

List<Document>

Returns a list of personal seals.

Return a list of documents of type image ( jpg or png ) from /okm:templates/ userId/stamps

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Document;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            List<Document> result = ws.getPersonalStamps();
            for (Document doc : result) {
                System.out.println(doc);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getPersonalStampImage

Description:

MethodReturn valuesDescription

getPersonalStampImage(String uuid, long id)

StampPersonalImage

Return the personal seal processed.

When stamping a document with an image, the image also can have a text layer.

This method processes the image and returns an image with the text layer.

The uuid must be an uuid returned by the method getPersonalStamps.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.StampPersonalImage;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long stampId = 1;
            StampPersonalImage stampPersonalImage = ws.getPersonalStampImage("928de61e-6ceb-4f94-bf20-9ba2405c5cee", stampId);
            System.out.println(stampPersonalImage);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}