SnowDoc Persistent Documents
SnowDoc is a new way of managing and manipulating documents in RasterMaster 20.0+. A SnowDoc can generate images just like Snowbnd, with several powerful new features and a few caveats.
SnowDocFactory is a new class that provides useful functions for creating SnowDoc objects.
SnowException is a new way for RasterMaster to provide meaningful feedback about failed operations.
SnowDoc
SnowDocs are created by SnowDocFactory. Once a SnowDoc has been created by SnowDocFactory, it is able to generate pages of output in any export format that RasterMaster supports. Retrieving pages from a SnowDoc is thread-safe, meaning that it’s possible to retrieve an arbitrary number of pages at the same time from a single SnowDoc object.
Currently supports legacy Word and Office Open XML formats.
Page Generation Functions
public byte[] generateImage(int imgType, int pageNum) throws SnowException
- Generates a
byte[]
representation of the specified page in the specified format - The imgType should be one of the format codes specified in
Snow.Defines.java
- The byte array returned is a complete image of the page, ready to be viewed or written to a file system
- Generates a
public byte[] extractText(int pageNum) throws SnowException
- Generates a SNBD_EXTSTREAM of the specified page and returns its ASCII form
public void saveImageAs(String fileSave, int imgType, int pageNum) throws SnowException
public void saveImageAs(byte[] dataOutput, int imgType, int pageNum) throws SnowException
- Each of these functions performs the same operations as generateImage, then goes a step further to save the resultant byte array
- The version that takes a String will write the file to the system path location specified by fileSave
- The version that takes a byte array will store the file in that byte array
Search Functions
public SNBD_SEARCH_RESULT[] searchText(int pageNum, String searchString, boolean isCaseSensitive) throws SnowException
public SNBD_SEARCH_RESULT[] searchRegex(int pageNum, String regexPattern) throws SnowException
public SNBD_SEARCH_RESULT[] searchTextFromBuffer(byte[] buff, String text, int case_sense, int[] error)
public SNBD_SEARCH_RESULT[] searchRegexFromBuffer(byte[] buff, String regexPattern, int[] error)
Accessor Functions
Currently, resolution and bit depth must be set before decompress()
is called. Once the document has been parsed, it will produce pages at the resolution that was set prior to decompressing.
public void setPageHeight(int pgHeight)
:public void setPageWidth(int pgWidth)
public int bitDepth()
public int resolution()
public void setBitDepth(int depth)
public void setResolution(int resolution)
SnowDocFactory
SnowDocFactory provides two essential functions for SnowDoc creation.
Each function accepts any of three possible representations of an input file.
- A
java.io.DataInputStream
created from the input file - A
java.lang.String
consisting of the system path to the input file - A
byte[]
containing the byte data of the input file
The Functions
-
public static boolean isSnowDocFormat(DataInputStream fileStream)
- Determines format of the input file & returns true if that format is supported by SnowDoc
- Will continue to be updated as more formats are adapted to support SnowDoc
-
public static SnowDoc createSnowDoc(DataInputStream fileStream)
- Creates a SnowDoc from the input file & returns it
- Accepts optional parameters to specify layout resolution & bit depth, as well as the ability to override the file’s default page width & height. For example:
public static SnowDoc createSnowDoc(DataInputStream fileStream, int resolution, int bitDepth)
public static SnowDoc createSnowDoc(DataInputStream fileStream, int resolution, int bitDepth, int width, int height)
- These optional parameters are also available for the
String
&byte[]
versions of createSnowDoc - The default resolution is 300dpi
- The default bit depth is 24
- The optional width and height parameters are in pixels at the specified resolution
SnowException
The SnowException class extends java.lang.Exception
and will be thrown from some SnowDoc and SnowDocFactory functions. There are currently three types of SnowException.
InvalidLicenseException
is thrown when SnowDoc is unable to locate a valid RasterMaster licensePageNotFoundException
is thrown when a requested page number doesn’t exist in the documentUnsupportedFormatException
is thrown bySnowDocFactory.createSnowDoc()
when the input file is in a format not supported by SnowDoc
Have questions, corrections, or concerns about this topic? Please let us know!