HOWTO: Register the PDF Reader (PdfDecoder)


If you are trying to read a PDF without using the PdfDecoder directly and you want DotImage to discover the type automatically, you need to register the PdfDecoder so that DotImage knows that it can use it to try to read a file. If you do not do this, you will always get an Unrecognized Image Type exception when trying to open a PDF.

You would need to do this if you had code like this:

   AtalaImage img = new AtalaImage("mydoc.pdf"); 

To read this file, DotImage uses its list of registered decoders and asks each one in turn if it can read the passed in file. Here are the steps to registering the PDF Decoder:

  1. Request an Eval license of the PDF Reader (PdfRasterizer if you're on 10.2 or earlier) if you don't already have a license
  2. Add a PDF Reader (PdfRasterizer if you're on 10.2 or earlier) reference to your project
  3. Add this code so that it runs before any code that tries to read a PDF -- we recommend that you put it somewhere so that it will run once in your whole program, like in a static constructor for your main form.

C#

 
Atalasoft.Imaging.Codec.RegisteredDecoders.Decoders.Add(new Atalasoft.Imaging.Codec.Pdf.PdfDecoder() { Resolution = 200 }); 

VB.NET

 
Atalasoft.Imaging.Codec.RegisteredDecoders.Decoders.Add(New Atalasoft.Imaging.Codec.Pdf.PdfDecoder() With {.Resolution = 200})

See Also:

HOWTO: Safely Change / Set Resolution of PdfDecoder

Original Article:
Q10175 - HOWTO: Registering the PDF Reader (PDF Rasterizer)