Enterprise Information Portal APIs

com.ibm.mm.viewer
Class CMBCMDocumentEngineEx

java.lang.Object
  |
  +--com.ibm.mm.viewer.CMBDocumentEngine
        |
        +--com.ibm.mm.viewer.CMBCMDocumentEngineEx
All Implemented Interfaces:
CMBViewerConstants

public class CMBCMDocumentEngineEx
extends CMBDocumentEngine

CMBCMDocumentEngineEx is an implementation of the abstract class CMBDocumentEngine. It uses the componentry of the Content Manager client to render and convert pages of documents and annotations on the pages. Instead of calling of the CM DLLs, however, it spawns an executable for viewing requests. This engine is only available on Windows.

The following engine properties are understood by this engine:

CACHE_DIR
A directory where files are cached for conversion The files will be erased when a document is dropped. More than one directory may be specified (separate each name with a semicolon).
MAX_GDI_BMP_WIDTH
The maximum width in pixels of the memory GDI bitmap that will be used for converting a page. If the GDI bitmap exceeds this size, the remainder of the scaling will be performed by by interpolation. The tradeoff is as follows: As this value increases, the fidelity of the image will increase, but the RAM consumption of the application increases as well.As this value decreases, the fidelity of the image becomes poorer, but the RAM consumption will be lower. The default value here is 2400.
MAX_GDI_BMP_HEIGHT
The maximum height in pixels of the memory GDI bitmap that will be used for converting a page. The default value here is 2400.
TRACE_LEVEL
The trace level: 0 - no trace, 2 - detailed tracing. The default is 0.
DOCTYPE_AUTODETECT
if "true" then the engine will attempt to 'sniff' the file to determine the right engine for conversion. Otherwise, the descision will be based on the mime type.

Since:
7.1

Fields inherited from interface com.ibm.mm.viewer.CMBViewerConstants
DEFAULT_PAGE_NUMBER, ROTATE_0, ROTATE_180, ROTATE_270, ROTATE_90
 
Constructor Summary
CMBCMDocumentEngineEx()
           
 
Method Summary
 boolean canEnhance(java.lang.Object hDocument, java.lang.String destMimeType)
          Returns true if the document pages can be enhanced when written in the specified format.
 boolean canInvert(java.lang.Object hDocument, java.lang.String destMimeType)
          Returns true if the document page colors can be inverted when written in the specified format.
 boolean canLoadDocument(java.lang.String mimeType)
          Returns true if the specified document type is handled by the engine.
 boolean canPaginate(java.lang.String mimeType)
          Returns true if the engine can convert documents of the specified MIME content type as pages.
 boolean canProvidePageImage(java.lang.String mimeType)
          Returns true if the engine can provide images of pages.
 boolean canRotate(java.lang.Object hDocument, java.lang.String destMimeType)
          Returns true if the document pages can be rotated when written in the specified format.
 boolean canShowAnnotations(java.lang.Object hDocument, java.lang.String destMimeType)
          Returns true if the document pages can be shown with annotations when written in the specified format.
 boolean canWriteDocument(java.lang.String sourceMimeType, java.lang.String destMimeType)
          Returns true if the specified document type can be written by the engine using the writeDocument method in the specified format.
 boolean canWriteDocumentFromPages(java.lang.String sourceMimeType, java.lang.String destMimeType)
          Returns true if a series of pages from the document can be written by the engine using the writePages method in the specified format.
 boolean canWritePage(java.lang.String sourceMimeType, java.lang.String destMimeType)
          Returns true if a page of the document can be written by the engine using the writePage method in the specified format.
 void dropDocument(java.lang.Object hDocument)
          Terminates processing of a document by the document engine.
 void dropPage(java.lang.Object hPage)
          Terminates processing of a page.
 java.lang.String getFormFileName(java.lang.String formName)
          This method is called from PVIEngineBridge in response for bedrock asking for a form overlay I made it synchronized since this is not hDocument specific, and therefore will use a directory that is common to all documents, and so the synchronized is there to prevent multiple writes to the same file at the same time.
 int getNumberOfPages(java.lang.Object hDocument)
          Warning: this loads ALL the parts of the document.
 double getPageHeight(java.lang.Object hPage)
          Returns the height of the page, in inches.
 java.awt.Image getPageImage(java.lang.Object hPage, int rotation, double scale, boolean enhance, boolean invert, boolean withAnnotations)
          Returns an image of the page.
 double getPageMaxScale(java.lang.Object hPage, java.lang.String destMimeType)
          Returns the maximum scale of document pages when written in the specified format.
 double getPageMinScale(java.lang.Object hPage, java.lang.String destMimeType)
          Returns the minimum scale of document pages when written in the specified format.
 double getPageWidth(java.lang.Object hPage)
          Returns the width of the page, in inches.
 void initialize(CMBDocumentEngineCallbacks callbacks, java.util.Properties properties)
          Initializes the document engine.
 boolean isInitialized()
          Returns true if the initialize method has been called and the engine initialized successfully.
 java.lang.Object loadDocument(java.io.InputStream partStream, int numberOfParts, java.lang.String mimeType, java.io.InputStream annotationStream, java.io.InputStream resourceStream)
          Initializes processing of a document by the document engine.
 java.lang.Object loadPage(java.lang.Object hDocument, int page)
          Initialized processing of a page within the document.
 void terminate()
          Terminates the engine.
 void writeDocument(java.lang.Object hDocument, java.lang.String destMimeType, java.io.OutputStream output)
          Writes the document to an output stream, in the specified format.
 void writeDocumentFromPages(java.lang.Object hDocument, int startingPage, int endingPage, java.lang.String destMimeType, java.io.OutputStream output, boolean withAnnotations)
          Writes the specified pages to an output stream in the specified format.
 void writePage(java.lang.Object hPage, int rotation, double scale, boolean enhance, boolean invert, boolean withAnnotations, java.io.OutputStream output, java.lang.String destMimeType)
          Writes the page to an output stream in the specified format.
 
Methods inherited from class com.ibm.mm.viewer.CMBDocumentEngine
canWritePage, getImageResolution, getPageMimeType, getPageResourceMimeType, loadDocument, loadDocument, loadDocument, writePage, writePageResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CMBCMDocumentEngineEx

public CMBCMDocumentEngineEx()
Method Detail

initialize

public void initialize(CMBDocumentEngineCallbacks callbacks,
                       java.util.Properties properties)
Description copied from class: CMBDocumentEngine
Initializes the document engine. This method must be called before other methods on the document engine can be used.
Overrides:
initialize in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
callbacks - methods to get background forms and additional parts of a multi-part document.
properties - engine specific properties.

terminate

public void terminate()
Description copied from class: CMBDocumentEngine
Terminates the engine. All documents and pages being processed are dropped. System resources are released.
Overrides:
terminate in class CMBDocumentEngine

isInitialized

public boolean isInitialized()
Description copied from class: CMBDocumentEngine
Returns true if the initialize method has been called and the engine initialized successfully.
Overrides:
isInitialized in class CMBDocumentEngine

canLoadDocument

public boolean canLoadDocument(java.lang.String mimeType)
Description copied from class: CMBDocumentEngine
Returns true if the specified document type is handled by the engine.
The default implementation returns false in all cases.
Overrides:
canLoadDocument in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
mimeType - the MIME content type for the document type being tested.

loadDocument

public java.lang.Object loadDocument(java.io.InputStream partStream,
                                     int numberOfParts,
                                     java.lang.String mimeType,
                                     java.io.InputStream annotationStream,
                                     java.io.InputStream resourceStream)
                              throws java.io.IOException
Description copied from class: CMBDocumentEngine
Initializes processing of a document by the document engine.
Overrides:
loadDocument in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
partStream - An input stream containing the data for the document. If the document is a multi-part document, this input stream contains the data for the first part of the document.
numberOfParts - the number of parts that compose the document. This will be 1 for a single-part document.
mimeType - the MIME content type of the first part.
annotationStream - An input stream containing the annotations for the document. This will only have data in those cases where the annotations are stored separately from the document. The format of the annotations is dependent on the tool that wrote the annotations. Only those formats understood by the document engine will be processed.
resourceStream - an InputStream containing engine specific resources.
Returns:
a unique object representing the document (a document handle). If the document cannot be loaded, null is returned.

dropDocument

public void dropDocument(java.lang.Object hDocument)
Description copied from class: CMBDocumentEngine
Terminates processing of a document by the document engine.
The default implementation does nothing.
Overrides:
dropDocument in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hDocument - the handle of the document, as returned from loadDocument.

canWriteDocument

public boolean canWriteDocument(java.lang.String sourceMimeType,
                                java.lang.String destMimeType)
Description copied from class: CMBDocumentEngine
Returns true if the specified document type can be written by the engine using the writeDocument method in the specified format.
The default implementation returns false in all cases.
Overrides:
canWriteDocument in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
sourceMimeType - the MIME content type for the source document.
destMimeType - the MIME content type for the document to be written.

writeDocument

public void writeDocument(java.lang.Object hDocument,
                          java.lang.String destMimeType,
                          java.io.OutputStream output)
                   throws java.io.IOException
Description copied from class: CMBDocumentEngine
Writes the document to an output stream, in the specified format.
Overrides:
writeDocument in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hDocument - the handle of the document, as returned from loadDocument.
destMimeType - the MIME content type for the format that the document is to be written.
output - the output stream where the document is written.

canPaginate

public boolean canPaginate(java.lang.String mimeType)
Description copied from class: CMBDocumentEngine
Returns true if the engine can convert documents of the specified MIME content type as pages. This is typically the case when the document itself is formatted for printing, but is desirable in many cases because it enables functions in a viewer such as navigation by page and viewing of page thumbnails.
The default implementation returns false for all types.
Overrides:
canPaginate in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
mimeType - the MIME content type for the document type being tested.

getNumberOfPages

public int getNumberOfPages(java.lang.Object hDocument)
                     throws java.io.IOException
Warning: this loads ALL the parts of the document. Avoid calling it if you can
Overrides:
getNumberOfPages in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hDocument - the handle of the document, as returned from loadDocument.

loadPage

public java.lang.Object loadPage(java.lang.Object hDocument,
                                 int page)
                          throws java.io.IOException
Description copied from class: CMBDocumentEngine
Initialized processing of a page within the document.
Overrides:
loadPage in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hDocument - the handle of the document, as returned from loadDocument.
page - the index of the page (zero is the first page)
Returns:
a unique object representing the page (the page handle). If the page cannot be loaded, null is returned.

dropPage

public void dropPage(java.lang.Object hPage)
Description copied from class: CMBDocumentEngine
Terminates processing of a page.
Overrides:
dropPage in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hPage - the handle of the page, as returned from loadPage.

getPageWidth

public double getPageWidth(java.lang.Object hPage)
Description copied from class: CMBDocumentEngine
Returns the width of the page, in inches. This is the width without rotation and scale=1.0.
Overrides:
getPageWidth in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hPage - the handle of the page, as returned from loadPage.

getPageHeight

public double getPageHeight(java.lang.Object hPage)
Description copied from class: CMBDocumentEngine
Returns the height of the page, in inches. This is the height without rotation and scale=1.0.
Overrides:
getPageHeight in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hPage - the handle of the page, as returned from loadPage.

canRotate

public boolean canRotate(java.lang.Object hDocument,
                         java.lang.String destMimeType)
Description copied from class: CMBDocumentEngine
Returns true if the document pages can be rotated when written in the specified format.
The default implementation returns false in all cases.
Overrides:
canRotate in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hDocument - the handle of the document, as returned from loadDocument
destMimeType - the MIME content of the page when written. If this is null, then the call is to query capabilities when providing page images.

getPageMinScale

public double getPageMinScale(java.lang.Object hPage,
                              java.lang.String destMimeType)
Description copied from class: CMBDocumentEngine
Returns the minimum scale of document pages when written in the specified format.
The default implementation returns 1.0 in all cases.
Overrides:
getPageMinScale in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hPage - the handle of the page, as returned from loadPage
destMimeType - the MIME content of the page when written. If this is null, then the call is to query capabilities when providing page images.

getPageMaxScale

public double getPageMaxScale(java.lang.Object hPage,
                              java.lang.String destMimeType)
Description copied from class: CMBDocumentEngine
Returns the maximum scale of document pages when written in the specified format.
The default implementation returns 1.0 in all cases.
Overrides:
getPageMaxScale in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hPage - the handle of the document, as returned from loadPage
destMimeType - the MIME content of the page when written. If this is null, then the call is to query capabilities when providing page images.

canEnhance

public boolean canEnhance(java.lang.Object hDocument,
                          java.lang.String destMimeType)
Description copied from class: CMBDocumentEngine
Returns true if the document pages can be enhanced when written in the specified format.
The default implementation returns false in all cases.
Overrides:
canEnhance in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hDocument - the handle of the document, as returned from loadDocument
destMimeType - the MIME content of the page when written. If this is null, then the call is to query capabilities when providing page images.

canInvert

public boolean canInvert(java.lang.Object hDocument,
                         java.lang.String destMimeType)
Description copied from class: CMBDocumentEngine
Returns true if the document page colors can be inverted when written in the specified format.
The default implementation returns false in all cases.
Overrides:
canInvert in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hDocument - the handle of the document, as returned from loadDocument
destMimeType - the MIME content of the page when written. If this is null, then the call is to query capabilities when providing page images.

canShowAnnotations

public boolean canShowAnnotations(java.lang.Object hDocument,
                                  java.lang.String destMimeType)
Description copied from class: CMBDocumentEngine
Returns true if the document pages can be shown with annotations when written in the specified format.
The default implementation returns false in all cases.
Overrides:
canShowAnnotations in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hDocument - the handle of the document, as returned from loadDocument
destMimeType - the MIME content of the page when written. If this is null, then the call is to query capabilities when providing page images.

canWritePage

public boolean canWritePage(java.lang.String sourceMimeType,
                            java.lang.String destMimeType)
Description copied from class: CMBDocumentEngine
Returns true if a page of the document can be written by the engine using the writePage method in the specified format.
The default implementation returns false in all cases.
Overrides:
canWritePage in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
sourceMimeType - the MIME content type for the document.
destMimeType - the MIME content type for the page.

writePage

public void writePage(java.lang.Object hPage,
                      int rotation,
                      double scale,
                      boolean enhance,
                      boolean invert,
                      boolean withAnnotations,
                      java.io.OutputStream output,
                      java.lang.String destMimeType)
               throws java.io.IOException,
                      CMBDocumentEngineException
Description copied from class: CMBDocumentEngine
Writes the page to an output stream in the specified format.
Overrides:
writePage in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hPage - the handle of the page, as returned from loadPage.
rotation - the rotation of the page. One of the constants ROTATE_0, ROTATE_90, ROTATE_180, or ROTATE_270.
scale - the scale for the page (1.0 is actual size)
enhance - if true, the page should be enhanced to improve text readability if possible.
invert - if true, the image should be color inverted.
output - the stream to write the page to.
destMimeType - the MIME content type for the format that the page is to be saved.

canWriteDocumentFromPages

public boolean canWriteDocumentFromPages(java.lang.String sourceMimeType,
                                         java.lang.String destMimeType)
Description copied from class: CMBDocumentEngine
Returns true if a series of pages from the document can be written by the engine using the writePages method in the specified format.
The default implementation returns false in all cases.
Overrides:
canWriteDocumentFromPages in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
sourceMimeType - the MIME content type for the document.
destMimeType - the MIME content type for the page.

writeDocumentFromPages

public void writeDocumentFromPages(java.lang.Object hDocument,
                                   int startingPage,
                                   int endingPage,
                                   java.lang.String destMimeType,
                                   java.io.OutputStream output,
                                   boolean withAnnotations)
                            throws java.io.IOException
Description copied from class: CMBDocumentEngine
Writes the specified pages to an output stream in the specified format.
Overrides:
writeDocumentFromPages in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hDocument - the handle of the document, as returned from loadDocument.
startingPage - the index of the starting page (page 0 is the first page)
endingPage - the index of the ending page
destMimeType - the MIME content type for the format that the pages are to be saved.
output - the stream to write the page to.
withAnnotations - if true, then the pages should be saved with their annotations.

canProvidePageImage

public boolean canProvidePageImage(java.lang.String mimeType)
Description copied from class: CMBDocumentEngine
Returns true if the engine can provide images of pages. If false is returned, the getPageImage method is not implemented by the engine for documents of the indicated MIME content type.
The default implementation returns false in all cases.
Overrides:
canProvidePageImage in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
mimeType - the MIME content type for the document type being tested.

getPageImage

public java.awt.Image getPageImage(java.lang.Object hPage,
                                   int rotation,
                                   double scale,
                                   boolean enhance,
                                   boolean invert,
                                   boolean withAnnotations)
Description copied from class: CMBDocumentEngine
Returns an image of the page.
Overrides:
getPageImage in class CMBDocumentEngine
Following copied from class: com.ibm.mm.viewer.CMBDocumentEngine
Parameters:
hPage - the handle of the page, as returned from loadPage.
rotation - the rotation of the page. One of the constants ROTATE_0, ROTATE_90, ROTATE_180, or ROTATE_270.
scale - the scale for the page (1.0 is actual size)
enhance - if true, the page should be enhanced to improve text readability if possible.
invert - if true, the image should be color inverted.

getFormFileName

public java.lang.String getFormFileName(java.lang.String formName)
This method is called from PVIEngineBridge in response for bedrock asking for a form overlay I made it synchronized since this is not hDocument specific, and therefore will use a directory that is common to all documents, and so the synchronized is there to prevent multiple writes to the same file at the same time.

EIP JavaBeans

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.