PDFRasterizer.NET 3.0 PDFRasterizer.NET 3.0

Namespace TallComponents.PDF.Rasterizer

Class DrawJob

Represents an asynchronous drawing job.

The code below shows one way to use a DrawJob. Instead of simply calling Page.Draw(), one can create a DrawJob, start it, and then do some additional work before obtaining the drawn bitmap. drawJob = new DrawJob(page); Bitmap mybitmap = new Bitmap( ( int ) ( page.Width / 72 * dpi ), ( int ) ( page.Height / 72 * dpi ) ); float scale = ( float ) ( dpi / 72F ); Matrix transformation = new Matrix(); transformation.Scale( scale, scale ); drawJob.Start(mybitmap, renderSettings, PageBoundary.Default, transformation); // ...Drawing will start on a separate thread. In the meantine, one could do // some additional work here. // Wait until drawing has finished. drawJob.Wait(); // Obtain a copy of the bitmap that has been drawn. System.Drawing.Bitmap bitmap = drawJob.GetBitmap(); One will typically use a DrawJob to render a page progesssively. After a drawing job has been started, it is possible to obtain intermediate bitmap results by calling DrawJob.GetImage() while the job is running. This can be done at arbitrary moments, for example via a timer.An easier way is to subscribe to the Updated event of the DrawJob and retrieve a new bitmap in the event handler. The Updated event will be fired regularly, but it will only be fired when the bitmap has actually been updated. After finishing the drawing job, the Updated event will be raised one last time. drawJob = new DrawJob(page); drawJob.Updated += new EventHandler(drawJob_Updated); ... drawJob.Start(...); ... void drawJob_Updated(object sender, EventArgs e) { // Obtain a copy of the bitmap for as far as it has been drawn. System.Drawing.Bitmap bitmap = drawJob.GetBitmap(); ... }


public class DrawJob : Object , IDisposable


Create a new asynchronous drawing job for the given page.


The job status.

The summary of the current drawing job.


Stops, and Disposes the draw job. The job may not stop immediately, but at a moment that permits it.

Get a copy of the bitmap for as far as it has been drawn. This may return null, e.g. when the job has not yet been started, or after calling Dispose for the job.

Start drawing the page to the given bitmap.

Stop drawing. The job may not stop immediately, but at a moment that permits it.

Wait until the job has stopped, or is ready.


Raised regularly while the job is running and immediately after drawing has finished. This event is provided as a convenience so that the generated bitmap can be inspected regularly, without needing to implement this functionality oneself. As a rule of thumb, this event gets fired at a higher frequency for simple drawing jobs, so that results can be shown quickly, and at a lower frequency for complex jobs, so that the drawing job itself will not be slowed down too much by frequent updates.