Functions Related To Archiving

Top  Previous  Next

When processing a job, UnForm can not only add documents to an archive, but it can also extract documents from a library for use in processing.  For example, a statement job could be designed to extract a list of invoice PDF images and attach them to the statement using the images command.

 

The library object provides a large suite of functions and properties related to a library and is often used for archive retrieval and manipulation from a rule set.  In addition, the following functions are provided for functional programming work:

 

To retrieve a document during an UnForm job, use this function in a code block:

 

getarc(library$,doctype$,docid$,subid$,filename$[,errmsg$])

 

If filename$="", it will return a temporary file containing the document. This temporary file will be erased at the end of the job.  If a filename is supplied, that file will be created and will not be erased at the end of the job.

 

If errmsg$ is present, it will return any error if the document can't be found or if another unexpected error occurs.

 

To convert a PDF file into an image, using Ghostscript, use this function:

 

pdftoimage(fromfile$,tofile$,format$ [,resolution [,errmsg$]])

 

This function will invoke Ghostscript, either on the UnForm server or on the UnForm Support Server, to convert the PDF file in fromfile$ to an image file in tofile$.  The format of the output will is named in format$, and it must match one of the [driver] names found in uf90d.ini.  The image is created at the dpi specified in resolution, or 300 dpi if not.

 

If tofile$ is null, it will be returned with a temporary file name that will be erased when the job is complete.

 

Any error message is returned in errmsg$.

 

Ghostscript must be configured in the [drivers] section of the uf90d.ini file, or an UnForm Support Server with Ghostscript configured must be available.  Note that the images command automatically performs this step function if it encounters a PDF file name.

 

To test if a library exists, use the libexists() function:

 

libexists(lib$) returns 0 if library lib$ doesn't exist, or 1 if it does.

 

To obtain a list of image subids associated with a document, use the getsubids() function:

 

getsubids(lib$,doctype$,docid$[,dlm$])

 

Returns a list of document sub IDs, such as the @text and @UnForm subids automatically generated by the archive command.  The list is returned as a delimited string, with the default delimiter being a semicolon.  If the delimiter occurs in any subid, it is escaped with a \.  The returned value may be used by the parse functions.

 

When a series of document images should be attached to a page produced by an UnForm job, you can extract the desired documents to work files, using the getarc() function, and append them to the page, optionally tiled, using the images command.

 

To determine if a document or sub document exists, use these functions, which return 0 if the specified entity does not exists, or 1 if it does:

 

 docidexists(lib$,doctype$,docid$)

 subidexists(lib$,doctype$,docid$,subid$)