Class PageToImageWorker
- java.lang.Object
-
- com.levigo.jadice.server.core.NodeWorker<T>
-
- com.levigo.jadice.server.core.StreamWorker<PageToImageNode>
-
- com.levigo.jadice.server.documentplatform.PageToImageWorker
-
- All Implemented Interfaces:
QualifiedLogEventReceiver
,WorkerController<PageToImageNode>
,Runnable
public class PageToImageWorker extends StreamWorker<PageToImageNode>
This worker converts the pages of a document into images of a defined target format.
-
-
Constructor Summary
Constructors Constructor Description PageToImageWorker()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static int
calcPNGCompressionLevel(float compressionQuality)
This method calculates the appropriate compression level for a given compression quality.protected static BufferedImage
convertPageToBufferedImage(com.levigo.jadice.document.Page page, Dimension maximumSize)
Converts the document page to a buffered image.protected static void
convertPageToTargetFormat(com.levigo.jadice.document.Page page, PageToImageNode.Format targetFormatName, Dimension maximumSize, int colorModel, float compressionQuality, OutputStream out)
Converts the current page to an input stream of the target format.protected static com.levigo.jadice.document.Document
readDocument(Stream stream)
Read the stream into the document data structure.protected void
work(Stream stream)
Converts the pages of a document into images in the target format.-
Methods inherited from class com.levigo.jadice.server.core.StreamWorker
accept, reject, work
-
Methods inherited from class com.levigo.jadice.server.core.NodeWorker
abort, abortNow, addInputBundle, addOutputBundle, doAbort, doAbortNow, error, error, error, fail, fail, fail, getController, getInputBundle, getInputBundles, getJob, getLimitSupport, getNode, getOutputBundle, getOutputBundles, getServerJob, getState, getStreamTransportFactory, getTransportSender, initialize, isAbortRequested, postWork, preWork, run, setDescriptor, setJob, toString, warn, warn, warn
-
-
-
-
Method Detail
-
work
protected void work(Stream stream) throws Throwable
Converts the pages of a document into images in the target format.- Specified by:
work
in classStreamWorker<PageToImageNode>
- Parameters:
stream
- the input stream.- Throws:
Throwable
- if an uncaught exception occurs.
-
convertPageToBufferedImage
protected static BufferedImage convertPageToBufferedImage(com.levigo.jadice.document.Page page, Dimension maximumSize)
Converts the document page to a buffered image.- Parameters:
page
- the given document page.- Returns:
- the corresponding buffered image.
-
convertPageToTargetFormat
protected static void convertPageToTargetFormat(com.levigo.jadice.document.Page page, PageToImageNode.Format targetFormatName, Dimension maximumSize, int colorModel, float compressionQuality, OutputStream out) throws IOException
Converts the current page to an input stream of the target format.- Parameters:
page
- the document's page.targetFormatName
- the desired target format.maximumSize
- the maximum bounds of the image result.colorModel
- a specified color model.compressionQuality
- the desired compression quality 1.0f (no compression) - 0.0 (full compression)out
- theOutputStream
to which the image is written.- Throws:
IOException
- if an I/O error occurs.
-
calcPNGCompressionLevel
protected static int calcPNGCompressionLevel(float compressionQuality)
This method calculates the appropriate compression level for a given compression quality.- Parameters:
compressionQuality
- the desired compression quality.- Returns:
- the calculated compression level.
-
readDocument
protected static com.levigo.jadice.document.Document readDocument(Stream stream) throws com.levigo.jadice.document.JadiceException, IOException
Read the stream into the document data structure.- Parameters:
stream
- the document's stream.- Returns:
- the corresponding document.
- Throws:
com.levigo.jadice.document.JadiceException
- if the document couldn't be read.IOException
- if an I/O error occurs.
-
-