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 one of the following methods LoadImage, LoadImageExFTPDownloadFTPDownloadEx, HTTPDownload, HTTPDownloadEx.

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) Deprecated With this mode, the PDF rasterizer will automatically 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. This mode is no longer available in v13.3 onwards, please make use of the API Addon.PDF.IsTextBasedPDF instead.

The default mode is CM_DEFAULT (0).

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

See also

Addon.PDF.SetResolution()
LoadImage()

Example

function LoadImage() {
  if (DWObject) {
    var aryFilePaths = [];
    function ds_load_file_with_pdfr(bSave, filesCount, index, path, filename) {
      nCount = filesCount;
      var filePath = path + "\\" + filename;
      aryFilePaths.push(filePath);
      if (aryFilePaths.length == nCount) {
        for(var i = 0; i < nCount; i++) {
          if(DWObject.Addon.PDF.IsTextBasedPDF(aryFilePaths[i])){
            DWObject.Addon.PDF.SetResolution(200);
            DWObject.Addon.PDF.SetConvertMode(EnumDWT_ConverMode.CM_RENDERALL);
          } else {
            DWObject.Addon.PDF.SetConvertMode(EnumDWT_ConverMode.CM_DEFAULT);
          }
          DWObject.LoadImage(aryFilePaths[i]);
        }
      }
    }
    DWObject.RegisterEvent('OnGetFilePath', ds_load_file_with_pdfr);
    DWObject.ShowFileDialog(false, "Any File | *.*", 0, "", "", true, true, 0);
  }
}
Is this page helpful?

Leave a Reply

Your email address will not be published.