Class DocumentUtil
java.lang.Object
com.ssgllc.fish.service.util.registered.DocumentUtil
Utility class to fetch documents of an entity.
-
Constructor Summary
ConstructorsConstructorDescriptionDocumentUtil
(com.ssgllc.fish.dms.util.CasetivityDmsActiveProviderResolver casetivityDmsActiveProviderResolver) -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Fetch the base64 data bytes of anyBlob document stored in given field of a given entity.static String
toBase64Png
(String entityName, String entityId, String anyBlobfieldName, String anyBlobIdentifier) Returns image data stored in given field of a specific entity in PNG format with base64 encoding.toBase64PngRange
(String entityName, String entityId, String anyBlobfieldName, String anyBlobIdentifier, Integer startPageIndex, Integer endPageIndex) Same astoBase64Png(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
with extra ability to accept page start and end indexes for PDF document types.
-
Constructor Details
-
DocumentUtil
public DocumentUtil(com.ssgllc.fish.dms.util.CasetivityDmsActiveProviderResolver casetivityDmsActiveProviderResolver)
-
-
Method Details
-
toBase64
public static String toBase64(String entityName, String entityId, String anyBlobfieldName, String anyBlobIdentifier) Fetch the base64 data bytes of anyBlob document stored in given field of a given entity. In case of pdf documents, this fetches only first page.
Example:
toBase64("WidgetDemo", "0ac82bdb-869f-1838-8186-9f6b011a0cf5", "anyBlob", "0ac83245-86c7-1fa3-8186-c7cfcc6c0000")
Returns:
"data:image/jpeg;base64,/9j/4AAQSkZJRgABA.....
" i.e corresponding document(image here) data as String encoded in base 64 format
- Parameters:
entityName
- Name of the entity in referenceentityId
- ID of the entityanyBlobfieldName
- field name of type anyBlob in the given entity whose document data needs to be accessedanyBlobIdentifier
- identifier of anyBlob field- Returns:
- document data as String encoded in base 64 format, null if document is not present or has no access
-
toBase64Png
public static String toBase64Png(String entityName, String entityId, String anyBlobfieldName, String anyBlobIdentifier) throws IOException Returns image data stored in given field of a specific entity in PNG format with base64 encoding. If the original image stored is PDF/JPG, its converted to PNG and sent as base64 encoded string. If original image is already in PNG format, its returned as base64 encoded string. Supported source document content types: image/jpeg, image/png, application/pdf
Example:
toBase64Png("WidgetDemo", "0ac82bdb-869f-1838-8186-9f6b011a0cf5", "anyBlob", "0ac83245-86c7-1fa3-8186-c7cfcc6c0000")
Returns:
"data:image/png;base64,/9j/iVBORw0KGg.....
" i.e corresponding PNG image data as String encoded in base 64 format
- Parameters:
entityName
- Name of the entity in referenceentityId
- ID of the entityanyBlobfieldName
- field name of type anyBlob in the given entity whose image data needs to be accessedanyBlobIdentifier
- identifier of anyBlob field- Returns:
- PNG image data as String encoded in base 64 format, null if image is not present or has no access
- Throws:
IOException
- if an error occurs during reading image or if unable to convert to PNG format
-
toBase64PngRange
public static List<String> toBase64PngRange(String entityName, String entityId, String anyBlobfieldName, String anyBlobIdentifier, Integer startPageIndex, Integer endPageIndex) throws IOException Same astoBase64Png(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
with extra ability to accept page start and end indexes for PDF document types. If startPageIndex and endPageIndex are null, all pages are fetched.
Example:
toBase64Png("WidgetDemo", "0ac82bdb-869f-1838-8186-9f6b011a0cf5", "anyBlob", "0ac83245-86c7-1fa3-8186-c7cfcc6c0000", 0, 2)
- Parameters:
entityName
- Name of the entity in referenceentityId
- ID of the entityanyBlobfieldName
- field name of type anyBlob in the given entity whose image data needs to be accessedanyBlobIdentifier
- identifier of anyBlob fieldstartPageIndex
- start page index, inclusive(for pdf documents only)endPageIndex
- end page index, inclusive(for pdf documents only)- Returns:
- PNG image data as String encoded in base 64 format, null if image is not present or has no access
- Throws:
IOException
- if an error occurs during reading image or if unable to convert to PNG format
-