Using PDFView class to add viewing support for TIFF, BMP, GIF, PNG, JPEG, JPEG2000, JBIG2 ... (and of course) PDF.


I would like to open other image types (such as JPEG, PNG, and TIFF)
besides PDF.
In PDFView sample project I can see how to open PDF, but how can I
open other image types?


You can use PDFNet SDK to add interactive viewing support for other
image types besides PDF.

For example, the following code illustrates how pdftron.PDF.PDFView
class can be used to view TIFF, BMP, GIF, PNG, JPEG, JPEG2000,
JBIG2, ... (and of course PDF).

The idea is to place the image on a blank PDF document prior to
calling pdfview.SetDoc(temp_doc).

// Based on PDFView and AddImageTest sample projects.
public bool OpenImage(string filename) {
  this.pdfDoc = new PDFDoc(); // create new document
  ElementBuilder f = new ElementBuilder();
  ElementWriter writer = new ElementWriter();page

  Page page = this.pdfDoc.PageCreate(); // Add a blank page

  // Add image to the document.
  pdftron.PDF.Image img = pdftron.PDF.Image.Create(this.pdfDoc,

  // get image rectangle
  Rect box = new Rect(0, 0, img.GetImageWidth(),

  // set crop and media box of this page to fit with the image

  // create the image element and add it to the page
  int width = img.GetImageWidth();
  int height = img.GetImageHeight();
  int offsetX = 0;
  int offsetY = 0;

  Element element = f.CreateImage(img, new Matrix2D(width, 0, 0,
height, offsetX, offsetY));
  writer.End(); // Finish writing to the page

  return true;
catch (Exception ex) {
  return false;