Addon.PDF.SetConvertMode()

Description

Sets the image convert mode for the PDF Rasterizer.

Data type

EnumDWT_ConverMode

Syntax

.Addon.PDF.SetConvertMode(EnumDWT_ConverMode.CM_RENDERALL);

Remarks

Use this method before you import a PDF into the control with methods such as LoadImage() and FTPDownload().

Value Description
CM_DEFAULT (0) It's the default mode. In this mode, the PDF Rasterizer is turned off.
CM_RENDERALL (1) All the content in the target PDF file will converted in a set resolution in this mode.
The value of the resolution is 200 by default but can be set via the method Addon.PDF.SetResolution.
CM_AUTO (2) With this mode, the PDF rasterizer will auto-detect the content of each page in the target PDF file. For a page that is itself an image,
the add-on will load it directly with its original resolution. Otherwise, it will be converted
to an image with the resolution set by Addon.PDF.SetResolution first and then loaded into the control.

The default mode is CM_DEFAULT (0).

When an error occurs, check ErrorCode or ErrorString for error information.

See also

Addon.PDF.SetResolution()
LoadImage()
HTTPDownload()

Example

// Callback functions for async APIs
  function OnSuccess() {
      console.log('successful');
  }
  function OnFailure(errorCode, errorString) {
      alert(errorString);
  }
  function LoadImage() {
      if (DWObject) {
          // Call DWObject.Addon.PDF.Download(url) to download PDF Rasterizer module to local.
          DWObject.Addon.PDF.SetConvertMode(EnumDWT_ConverMode.CM_RENDERALL);
          DWObject.Addon.PDF.SetResolution(100);  
          // Open the system's file dialog to load image
          DWObject.IfShowFileDialog = true;
          // Load images in all supported formats (.bmp, .jpg, .tif, .png, .pdf). 
          // OnSuccess or OnFailure will be called after the operation.
          DWObject.LoadImageEx("", EnumDWT_ImageType.IT_PDF, OnSuccess, OnFailure);
      }
  }