Thanks for Downloading Dynamic Web TWAIN 30-Day Trial!
Your download will start shortly. If your download does not begin, click here to retry.
{WebTwainObject}.Addon.PDF
{WebTwainObject} denotes the
WebTwaininstance.
Methods
GetConvertMode() |
GetReaderOptions() |
IsModuleInstalled() |
IsRasterizationRequired() |
IsTextBasedPDF() |
SetConvertMode() |
SetPassword() |
SetResolution() |
Write.Setup() |
SetReaderOptions() |
GetConvertMode()
This API has been deprecated as of release 18.4. Please use the
GetReaderOptions()function.
Return the convert mode.
Syntax
GetConvertMode(): number;
Please refer to EnumDWT_ConvertMode.
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v17.2+ | v17.2+ | v17.2+ | v17.2+ |
GetReaderOptions()
Returns the current PDF reader options. Please refer to ReaderOptions.
Syntax
GetReaderOptions(): ReaderOptions;
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v18.4+ | v18.4+ | v18.4+ | v18.4+ |
IsModuleInstalled()
Return whether the PDF module has been installed.
Syntax
IsModuleInstalled(): boolean;
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v14.1+ | v14.1+ | v14.1+ | v14.1+ |
IsRasterizationRequired()
Return whether a local PDF file needs rasterization. If each PDF page contains only one image, return false. Otherwise, return true.
Syntax
IsRasterizationRequired(path: string): boolean;
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v19.0+ | v19.0+ | v19.0+ | v19.0+ |
IsTextBasedPDF()
Detect whether a local PDF file is text based or not.
Syntax
IsTextBasedPDF(path: string): boolean;
Parameters
path: Specify the path of the PDF file.
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v11.2+ | v11.2+ | v11.2+ | v11.2+ |
SetConvertMode()
This API has been deprecated as of release 18.4. Please use the
SetReaderOptions()function.
Set the convert mode.
Syntax
SetConvertMode(mode: Dynamsoft.DWT.EnumDWT_ConvertMode | number): boolean;
Parameters
mode: Specify the mode. Please refer to EnumDWT_ConvertMode. The default value is 3 (Dynamsoft.DWT.EnumDWT_ConvertMode.CM_AUTO)
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v11.2+ | v11.2+ | v11.2+ | v11.2+ |
Usage notes
There are three conversion modes
CM_RENDERALL(1): All the content in the target PDF file will be rasterized.CM_IMAGEONLY(2): The PDF Rasterizer is turned off.CM_AUTO(3): The library automatically detect whether a file needs to be rasterized or not and then process the file accordingly.
Use this method before you import a PDF into the viewer with methods such as LoadImage(), HTTPDownload(), and FTPDownload().
SetReaderOptions()
Sets the current PDF reader options.
Syntax
SetReaderOptions(options: ReaderOptions): boolean;
Parameters
options: Please see the ReaderOptions interface.
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v18.4+ | v18.4+ | v18.4+ | v18.4+ |
Usage Notes
Use this method before you import a PDF into the viewer with methods such as LoadImage(), HTTPDownload(), and FTPDownload().
Examples
-
Render the PDF file to grayscale images without annotations.
DWTObject.Addon.PDF.SetReaderOptions({ convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL, renderOptions: { renderAnnotations: false, renderGrayscale: true, }, }); -
Render the PDF file to images, but when saving, preserve the original data if the content of a page is not modified.
DWTObject.Addon.PDF.SetReaderOptions({ convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL, preserveUnmodifiedOnSave: true, //only available for v19.0+ });
SetPassword()
This API has been deprecated as of release 18.4. Please use the
SetReaderOptions()function.
Set the password for reading encrypted PDF files.
Syntax
SetPassword(password: string): boolean;
Parameters
password: Specify the password.
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v11.2+ | v11.2+ | v11.2+ | v11.2+ |
Usage notes
Use this method before you import a PDF into the viewer with methods such as LoadImage(), HTTPDownload(), and FTPDownload().
SetResolution()
This API has been deprecated as of release 18.4. Please use the
SetReaderOptions()function.
Set the resolution for rasterizing.
Syntax
SetResolution(resolution: number): boolean;
Parameters
resolution: Specify the resolution.
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v11.2+ | v11.2+ | v11.2+ | v11.2+ |
Usage notes
The default resolution for the conversion is 200. We recommend that you set a value smaller than 300, otherwise it might slow down the program or cause the process to fail.
Use this method before you import a PDF into the viewer with methods such as LoadImage(), HTTPDownload(), and FTPDownload().
Write.Setup()
Set up the PDF writing engine.
Syntax
Write.Setup(settings: PDFWSettings): boolean;
Parameters
settings: Configures how the PDF is generated. Please refer to PDFWSettings.
Availability
| H5(Windows) | H5(macOS/TWAIN) | H5(macOS/ICA) | H5(Linux) |
| v15.0+ | v15.1+ | v15.1+ | v15.1+ |
Example
DWTObject.Addon.PDF.Write.Setup({
author: "Dynamsoft",
compression: Dynamsoft.DWT.EnumDWT_PDFCompressionType.PDF_JPEG,
pageType: Dynamsoft.DWT.EnumPDF_Page.Page_A4,
creator: "DWT",
creationDate: "D:20230101085959",
keyWords: "samplepdf",
modifiedDate: "D:20230101090101",
producer: "Dynamic Web TWAIN",
subject: "SamplePdf",
title: "SamplePdf",
version: "1.5",
quality: 90,
});
DWTObject.SaveAllAsPDF("DynamicWebTWAIN.pdf", OnSuccess, OnFailure);
function OnSuccess() {
console.log("successful");
}
function OnFailure(errorCode, errorString) {
if (errorCode != -2326) alert(errorString);
}
Usage notes
Use this method before you create a PDF with methods such as HTTPUpload(), SaveAsPDF(), and SaveAllAsPDF().
Only the core module license is required to use this method.