How to use the PDF Rasterizer

The PDF Rasterizer was designed to support non-image PDF files. There are merely 3 APIs

Addon.PDF.Download, Addon.PDF.SetResolution, Addon.PDF.SetConvertMode

There are 3 JS files and 2 zip files directly related to this add-on, they are found under /Resources/addon/

image029

In order to use this add-on, the steps are

1.  Reference the file dynamsoft.webtwain.addon.pdf.js in your code.

<script type="text/javascript" src="Resources/dynamsoft.webtwain.initiate.js"> </script>
<script type="text/javascript" src="Resources/dynamsoft.webtwain.config.js"> </script>
<script type="text/javascript" src="Resources/addon/dynamsoft.webtwain.addon.pdf.js"> </script>

2.  Download the necessary DLL file and Set up the add-on

function Dynamsoft_OnReady() {
     
     DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
     if (DWObject) {

       DWObject.Addon.PDF.Download(
            "http://localhost/dwt/addon/Pdf.zip",
           function () { console.log('Successfully Downloaded PDF add-on');},
           function (errorCode, errorString) {alert(errorString); }
        );
        DWObject.Addon.PDF.SetResolution(200);
        DWObject.Addon.PDF.SetConvertMode(EnumDWT_ConverMode.CM_RENDERALL);
     }
}

How it works

Dynamsoft has optimized this PDF Rasterizer internally so that when you have done the 2 steps above, the PDF rasterizer will be ready to work in your application. Basically, when you try to load or download any PDF file, the rasterizer will be called automatically to convert the PDF into images before loading them. In other words, the feature is turned on and you don’t need to write any extra code to use it.

Here is how the 'download' method works

Syntax
.Addon.PDF.Download(remoteFile, [optionalAsyncSuccessFunc, optionalAsyncFailureFunc])

Workflow

image030