Mht React Native Reference Documentation
Mht
Current Version: 11.6.1
Chilkat.Mht
Convert a web page, local HTML file, or HTML string into an MHT archive
with supported related resources embedded when settings permit and each
resource can be obtained.
Produce an HTML-email MIME draft from HTML. Image embedding follows
Capture images, CSS, CSS imports and backgrounds, and—when producing
MHT—frames and supported external scripts.
Use proxy settings, authentication, caching, redirects, capture-scoped cookies,
and related options when fetching pages and dependent resources.
Return generated MHT or EML text in memory, save it to disk, or place it
into a ZIP archive.
Extract an MHT archive into an HTML file plus supporting resource files
for inspection, editing, or republishing.
Default static resource handling:
For an extended overview, see
Mht Class Overview.
Create, save, zip, email, and unpack MHT web archives.
Chilkat.Mht creates MHT web archives and EML email messages
from HTTP/HTTPS pages, local HTML files, or in-memory HTML strings. It
analyzes the supplied HTML source, resolves and retrieves supported static
resources, rewrites references as needed, and packages the result as MIME.
It also supports disk caching, proxies, authentication, file or ZIP output,
and unpacking existing MHT data.
Create MHT archives
Generate EML messages
EmbedImages and EmbedLocalOnly; scripts, frames, and
comments are removed. Addressing, subject, and sending remain application tasks.
Embed static resources
Network configuration
Save or zip output
Unpack MHT files
Mht does not execute JavaScript, build or wait for a browser DOM,
trigger lazy loading, or capture AJAX, fetch, XHR, React, Angular,
Vue, or other client-rendered content. It captures the original HTML source
and resources that are statically referenced by that source. MHT output can
preserve scripts so they may execute when the saved archive is later opened;
EML output always removes scripts.
http: or
https:. Every other value is treated as a local path.
file:// is not recognized. Relative paths use the process current
working directory, and a local source file must already exist and be readable.
<base href> element, then
BaseUrl, then the source page URL or local file directory. Use a
URL—not a filesystem directory—for BaseUrl, and end a directory-style
base URL with /. Downloaded CSS resolves its own relative
url(...) and @import references against the stylesheet URL;
inline CSS resolves against the page base.
HTML/CSS reference
Behavior
<img src>Captured by default, subject to EmbedImages and EmbedLocalOnly.srcset / sizesNot used for candidate selection. These attributes are stripped and the ordinary src is used; obvious spacer placeholders are detected so the real image can be captured.CSS url(...)Captured from external style sheets, <style> blocks, and inline style attributes.CSS @importDownloaded, inlined, and processed recursively. <link rel="stylesheet">Downloaded and inlined; its CSS references are then processed recursively. <iframe> / <frame>Fetched and captured for MHT; removed for EML. <script src>Supported external scripts are captured for MHT and inline scripts may be retained; all scripts are removed for EML. Script handling remains subject to NoScripts and PreferMHTScripts.<object data>, <embed src>, media elementsReferences are made absolute, but the payload is not downloaded. This includes video, audio, source, and track.Favicons Not captured. Navigation and form URLs Made absolute when possible, but their targets are not downloaded. HTTP redirects Followed for the primary page and dependent resources. After a primary redirect, relative references use the final landing URL as their base. LastErrorText, and continues with a successful result.
No empty placeholder part is created. Failure to load the primary URL or
local HTML file does fail the operation. Consequently, output is fully
self-contained only to the extent allowed by the embedding properties and
the resources that were successfully obtained.
GetMHT, GetEML, HtmlToMHT,
HtmlToEML, and GetCacheRoot, check
LastMethodSuccess. Do not infer success or failure from whether
the returned string is empty. On failure the string is cleared or may contain
partial output, and LastErrorText contains the diagnostic.
Mht settings.
RestoreDefaults clears only the external
style-sheet and exclusion-pattern collections; it does not clear custom headers or
cache roots. Cache roots can be reset only by using a new object.
Authorization and Content-Length are
rejected, but other sensitive fields such as a manually supplied Cookie
can be sent to third-party hosts.
Date and X-Unsent. EML adds the
current Date and X-Unsent: 1, removes scripts, frames, and
comments, and is best treated as an HTML-email draft. It has no generated
Message-ID and no plain-text alternative; the application must add the
required addressing and subject information before sending.
Content-Location values and skips parts whose locations
are full URLs.
HtmlTo* method.
Object Creation
// npm install @chilkat/react-native react-native-nitro-modules
// (React Native 0.76+ with the New Architecture; then `pod install` for iOS. The Chilkat
// native library is downloaded and verified during the native build -- see the package README.)
import { Chilkat, Mht } from '@chilkat/react-native'
// Once per app start, before any other Chilkat call:
Chilkat.unlockBundle('Anything for 30-day trial') // shorthand for new Global().unlockBundle(..)
const mht = new Mht()
// ... the native object is released when `mht` is garbage collected, or now with mht.dispose()Creates the underlying native Chilkat object. Mht is a Nitro Module HybridObject: use it from the JavaScript thread only (it cannot be passed to a Worklet or another runtime). Every member is synchronous and blocks the JavaScript thread until Chilkat returns; a method that can take a while also exists as a ...Async twin returning a Promise, which runs the same call on a native worker thread so the UI keeps rendering. While such a call is pending, every other call on this object throws, except abort() and assigning onPercentDone / onProgressInfo.
Releases the native object immediately instead of waiting for garbage collection (useful for a large BinData or an open socket). Calling it more than once is harmless; any other use of the object afterwards throws. An object with a pending ...Async call cannot be disposed until the promise settles.
Errors
A method that can fail throws a plain Error: a method whose only outcome is success or failure returns void and throws on failure; a method producing a string or an object returns it and throws where Chilkat would have returned null. The error's message is "Class.method(...): reason", where the reason is the last informative line of the object's lastErrorText, which holds the full Chilkat log of the failed call. A ...Async twin rejects its promise with the same Error instead of throwing. Properties never throw, and methods that answer a question (has..., is..., ...) return a plain boolean.
try {
mht.someMethod(...)
} catch (e) {
console.log((e as Error).message) // Mht.someMethod(...): <reason>
console.log(mht.lastErrorText) // the full Chilkat log of the failed call
}
// The same call without blocking the JavaScript thread:
try {
await mht.someMethodAsync(...)
} catch (e) {
console.log((e as Error).message) // Mht.someMethodAsync: <reason>
}
Properties
AbortCurrent
abortCurrent: boolean
Set to true to request cancellation of the operation currently running on this object. Long-running network and file operations periodically check this property; a fast operation may complete before the request is observed.
A synchronous method can be cancelled from another thread by setting this property on the same object. Chilkat resets the property to false after an abort is processed, and a stale request is cleared when a later method begins.
BaseUrl
baseUrl: string
Specifies a web base URL used when relative references in a local HTML file or in-memory HTML string must be resolved in an HTTP/HTTPS context. For an HTTP/HTTPS source page, Chilkat derives the base from the fetched URL automatically.
<base href> element takes precedence over this property. If no usable <base> exists, BaseUrl is used; otherwise Chilkat falls back to the source page URL or the directory containing the local HTML file.BaseUrl when the document contains site-relative or root-relative references that should resolve against a web origin. The value should be an HTTP or HTTPS URL, not a filesystem directory.https://www.example.com/section/. Without it, the last path segment is treated as a filename and is removed before relative resolution.Relative url(...) and @import references inside a downloaded external stylesheet are resolved against that stylesheet's final URL. References in inline <style> blocks and style attributes are resolved against the page base. If no usable base exists, unresolved relative references remain relative and their resources are not captured.
ConnectTimeout
connectTimeout: number
Specifies the maximum number of seconds allowed for establishing a connection to an HTTP server. The default is 10 seconds.
ReadTimeout to control inactivity while receiving data.DebugHtmlAfter
debugHtmlAfter: string
Specifies a local file path where Chilkat saves the HTML after it has been processed for MHT or EML generation. Leave the property empty to disable this diagnostic output.
DebugHtmlBefore to inspect rewritten URLs, removed scripts, and other transformations applied before the MIME document is assembled. Do not enable diagnostic output to a sensitive or publicly accessible location.DebugHtmlBefore
debugHtmlBefore: string
Specifies a local file path where Chilkat saves the source HTML before it is transformed for MHT or EML generation. Leave the property empty to disable this diagnostic output.
DebugHtmlAfter to determine whether a problem originates in the input HTML or in the conversion and URL-rewriting process.DebugLogFilePath
debugLogFilePath: string
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
EmbedImages
embedImages: boolean
Controls whether images referenced by the HTML are downloaded or read from disk and embedded as related MIME parts in both MHT and EML output. The default is true.
EmbedImages | EmbedLocalOnly | Image behavior |
|---|---|---|
false | Either | No images are embedded. References are made absolute when sufficient base information is available. |
true | false | Local and HTTP/HTTPS images are embedded when they can be obtained. This is the default combination. |
true | true | Only local-file images are embedded. HTTP/HTTPS images remain external references. |
<img src> value. It does not use srcset or sizes to choose a candidate; those attributes are removed. Obvious spacer or 1×1 placeholder sources are detected so the real image reference can be used when available.EmbedLocalOnly
embedLocalOnly: boolean
When true, only images whose references resolve to the local filesystem are embedded. Images referenced through HTTP or HTTPS remain external. The default is false. This property has an effect only when EmbedImages is true and applies to both MHT and EML output.
FetchFromCache
fetchFromCache: boolean
When true, Chilkat attempts to satisfy page and resource requests from the configured disk cache before downloading them. Add one or more cache directories with AddCacheRoot. The default is false.
UpdateCache controls whether network responses are written to the cache. IgnoreMustRevalidate and IgnoreNoCache control whether certain HTTP cache directives are honored.HeartbeatMs
heartbeatMs: number
Specifies the interval, in milliseconds, between AbortCheck event callbacks during supported long-running operations. The default is 0, which disables these periodic callbacks.
AbortCheck callback occurs. Choose an interval that is responsive without generating excessive callback traffic.IgnoreMustRevalidate
ignoreMustRevalidate: boolean
Controls how cached responses containing Cache-Control: must-revalidate are handled. When false (the default), Chilkat revalidates such a cached response before reuse. When true, a still-fresh cached response may be used without revalidation. This property is relevant only when FetchFromCache is true.
must-revalidate can improve offline or high-latency operation, but it may also use content the origin server intended to be checked before reuse.IgnoreNoCache
ignoreNoCache: boolean
Controls whether HTTP response directives that prohibit or restrict caching are ignored. The default is false, which honors the server's caching instructions. When true, Chilkat may store responses that would otherwise be excluded from the disk cache.
LastErrorHtml
readonly lastErrorHtml: string
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
readonly lastErrorText: string
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
readonly lastErrorXml: string
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
lastMethodSuccess: boolean
Indicates the success or failure of the most recent method call: true means success, false means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.
NoScripts
noScripts: boolean
Controls script removal when creating MHT output. When true, script content is removed. When false (the default), inline scripts and supported external scripts may be preserved according to PreferMHTScripts.
fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.NtlmAuth
ntlmAuth: boolean
When true, Chilkat uses NTLM authentication when the origin HTTP server requests authentication. The default is false. Set WebSiteLogin, WebSitePassword, and, when required, WebSiteLoginDomain.
ProxyLogin and ProxyPassword. Use HTTPS whenever credentials or authenticated content are transmitted.NumCacheLevels
numCacheLevels: number
Specifies the number of directory levels used beneath each disk-cache root. The default is 0, which stores cached items directly in the root. A value of 1 distributes items among 256 subdirectories named 0 through 255. A value of 2 uses two such levels, for example 17/204. Chilkat creates the required subdirectories automatically.
NumCacheRoots
readonly numCacheRoots: number
Returns the number of disk-cache root directories currently configured through AddCacheRoot. Multiple roots allow cached items to be distributed across different directories or storage volumes.
GetCacheRoot to retrieve a configured root by index.PreferIpv6
preferIpv6: boolean
Controls address-family preference when a hostname resolves to both IPv4 and IPv6 addresses. The default is false, which prefers IPv4. Set to true to prefer IPv6.
PreferMHTScripts
preferMHTScripts: boolean
Controls which content is retained when HTML contains a script together with a <noscript> alternative. When true (the default), the script is preferred and the <noscript> content is discarded. When false, the script is removed and the <noscript> content is retained.
NoScripts takes precedence when script removal is required. EML generation always removes scripts.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.Proxy
proxy: string
Specifies an HTTP proxy as hostname:port, for example proxy.example.com:8080. Leave the property empty when no explicit HTTP proxy is required.
http:// or https:// scheme. If the proxy requires credentials, set ProxyLogin and ProxyPassword.ProxyLogin
proxyLogin: string
Specifies the username used to authenticate with the HTTP proxy configured by Proxy. Leave empty when the proxy does not require authentication.
ProxyPassword
proxyPassword: string
Specifies the password used to authenticate with the HTTP proxy configured by Proxy. Leave empty when the proxy does not require authentication.
ReadTimeout
readTimeout: number
Specifies the maximum number of seconds that an HTTP read may remain inactive while waiting for additional data. The default is 20 seconds. If data continues to arrive, a long download may run longer than this value.
RequireSslCertVerify
requireSslCertVerify: boolean
Controls verification of the TLS server certificate for HTTPS connections. When true, the connection is rejected if certificate verification fails, such as because the certificate is expired or its chain or signature cannot be validated. The default is false.
SocksHostname
socksHostname: string
Specifies the hostname or dotted-decimal IPv4 address of the SOCKS proxy. This property is used only when SocksVersion is 4 or 5.
SocksPassword
socksPassword: string
Specifies the password for SOCKS5 proxy authentication. SOCKS4 does not define password authentication, so this property is ignored when SocksVersion is 4.
SocksPort
socksPort: number
Specifies the TCP port of the SOCKS4 or SOCKS5 proxy. The default is 1080. This property is used only when SocksVersion is 4 or 5.
SocksUsername
socksUsername: string
Specifies the username sent to the SOCKS4 or SOCKS5 proxy. It is used only when SocksVersion is 4 or 5. For SOCKS5, set SocksPassword when password authentication is required.
SocksVersion
socksVersion: number
Selects whether requests are routed through a SOCKS proxy.
| Value | Behavior |
|---|---|
0 | Do not use a SOCKS proxy. This is the default. |
4 | Connect through a SOCKS4 proxy. |
5 | Connect through a SOCKS5 proxy. |
4 and 5, set SocksHostname and SocksPort. Configure username and password properties when the proxy requires them.UnpackDirect
unpackDirect: boolean
Controls whether MHT parts are extracted directly according to their relative Content-Location values. The default is false.
| Setting | Behavior |
|---|---|
false | Normal mode: Chilkat selects the primary HTML part, writes related resources beneath the parts subdirectory, rewrites HTML references, and applies path-containment and filename-collision handling. |
true | Direct mode: relative Content-Location paths are written beneath the unpack directory without the normal HTML-reference rewriting. The partsSubDir method argument is ignored. |
Content-Location beginning with http://, https://, or file:/, Chilkat logs the problem and does not write that part. Direct mode is intended for archives whose locations are already relative; use normal mode for web-captured MHT data.UnpackUseRelPaths
unpackUseRelPaths: boolean
Controls how extracted resources are referenced from the rewritten HTML produced by the normal unpacking mode. The default is true, which uses relative paths. Set to false to write absolute local paths.
UpdateCache
updateCache: boolean
Controls whether successful HTTP GET responses are written to the configured disk cache. The default is false. When true, add at least one cache root with AddCacheRoot.
FetchFromCache controls cache reads. Applications may enable either setting independently or enable both for normal read-through caching.UseCids
useCids: boolean
Controls how embedded resources are identified and referenced in generated MHT and EML MIME documents. The default is false.
| Setting | Resource-part headers | HTML reference |
|---|---|---|
false | A Content-Location containing the resolved URL or path; no Content-ID. | The resource is referenced by its URL or location. |
true | A generated, angle-bracketed Content-ID; no Content-Location. | The resource URL is rewritten as cid:<id>. |
Content-Location or Content-ID, not both. cid: references are common in HTML email; location-based references preserve the resolved resource URL or path.UseFilename
useFilename: boolean
Controls whether the generated Content-Disposition for an embedded resource includes a filename parameter. The default is true. Setting this property to true forces an inline disposition to be emitted even when UseInline is false.
UseInline | UseFilename | Generated Content-Disposition |
|---|---|---|
true | true | inline; filename="<name>" |
true | false | inline |
false | true | inline; filename="<name>" |
false | false | No Content-Disposition header. |
name="<name>" on its Content-Type, regardless of UseFilename and UseInline. The MIME filename is presentation metadata, not the source filesystem path.UseIEProxy
useIEProxy: boolean
When true, Chilkat uses the proxy configuration associated with Windows Internet Options / Internet Explorer. This setting is relevant on Windows systems.
Proxy when the application should specify a particular proxy directly rather than relying on the current user's Windows proxy settings.UseInline
useInline: boolean
Controls whether embedded resource parts receive an inline Content-Disposition when UseFilename does not independently require the header. The default is true.
UseInline | UseFilename | Generated Content-Disposition |
|---|---|---|
true | true | inline; filename="<name>" |
true | false | inline |
false | true | inline; filename="<name>" |
false | false | No Content-Disposition header. |
inline; these properties do not produce attachment. Every embedded resource always receives a name parameter on its Content-Type, independent of both settings.VerboseLogging
verboseLogging: boolean
If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
Version
readonly version: string
WebSiteLogin
webSiteLogin: string
Specifies the username used when the origin website requires HTTP authentication. It is optional for public pages. For NTLM authentication, also set NtlmAuth to true and provide a domain when required.
WebSiteLoginDomain
webSiteLoginDomain: string
Specifies the optional Windows domain used with NTLM website authentication. This property is relevant when NtlmAuth is true.
WebSitePassword
webSitePassword: string
Specifies the password used with WebSiteLogin when the origin website requires HTTP authentication.
Methods
AddCacheRoot
Adds dir as a persistent root directory for the disk cache. Call this method once for each cache location the application wants Chilkat to use. Multiple roots may be placed on different directories or storage volumes.
FetchFromCache and UpdateCache to enable cache reads and writes.RestoreDefaults does not clear them. Use a new Mht object when the cache-root list must be reset.AddCustomHeader
Adds an HTTP request header to the persistent custom-header collection used for the main page, redirect targets, and every HTTP/HTTPS dependent-resource request, including requests to third-party hosts. name is the field name without a trailing colon, and value is the field value.
| Field name | Behavior when added again |
|---|---|
User-Agent or Accept-Language | Replaces the existing value. |
| Any other permitted field | Appends another header line with the same name; it does not replace the earlier line. |
Authorization and Content-Length are rejected case-insensitively and are not added. Use the website-login properties for supported HTTP authentication rather than attempting to add Authorization here.Cookie, Host, and application-defined headers are reused for every destination contacted during the capture. Do not place a secret in a custom header unless it is safe to send to the primary host, every redirect target, and every third-party resource host.Custom headers persist until removed with RemoveCustomHeader, cleared with ClearCustomHeaders, or the object is discarded. RestoreDefaults does not clear them.
AddExternalStyleSheet
Adds the style-sheet URL in url to the persistent list of external CSS resources downloaded and embedded during conversion. This is normally unnecessary because Chilkat automatically discovers <link rel="stylesheet"> references present in the static HTML.
@import and url(...) references. Imported sheets are processed recursively, and relative references are resolved against the URL of the style sheet that contains them.RestoreDefaults clears the entire external-style-sheet list.ClearCustomHeaders
Removes all HTTP request headers previously added with AddCustomHeader. Automatically generated and built-in HTTP headers are not removed.
The custom-header collection otherwise persists across conversions and is not cleared by RestoreDefaults.
ExcludeImagesMatching
Adds pattern to the persistent list of exclusion patterns used while gathering embeddable resources. Despite the historical method name, the test is applied to embeddable resources generally, not only to images. Each candidate is tested against its fully resolved reference: an absolute URL for web content or the resolved local path for a local resource.
| Test | Matching rule |
|---|---|
| Wildcard / glob | Case-insensitive match against the entire resolved reference. * matches zero or more characters, and ? matches exactly one character. |
| Plain substring | Case-sensitive containment test anywhere within the resolved reference. |
*banner* performs a case-insensitive contains-style match; logo.png performs a case-sensitive substring test; */ads/* can match a path; *doubleclick* can match a host; and *.gif can match an extension. The scheme, host, path, filename, query string, and fragment participate when present.RestoreDefaults to clear the exclusion list, or use a new Mht object.GetAndSaveEML
Creates EML output from the HTTP/HTTPS page or local HTML file in urlOrHtmlFilepath and saves it to the destination path in emlPath. Style sheets and their CSS resources are captured. Images are embedded according to EmbedImages and EmbedLocalOnly. Scripts and framed documents are removed.
urlOrHtmlFilepath is classified: Chilkat treats urlOrHtmlFilepath as a web URL only when it begins, case-insensitively, with http: or https:. Every other value is treated as a local file path. file:// URLs are not supported; pass a plain filesystem path instead. Relative paths are resolved against the process current working directory, and the local file must already exist and be readable. A value such as www.example.com/page.html has no recognized scheme and is therefore treated as a local path.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.true on success and false on failure.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success. This resilience applies only to dependent resources; failure to fetch the primary URL or read the primary local HTML file fails the operation.false. Using the same local file as both source and destination is mechanically allowed because the source is read first, but the subsequent write destroys the original HTML file. On Windows, this method also rejects destination paths containing characters that are invalid in Windows filenames, such as ?, before generation begins.Mht.Date and X-Unsent: 1, removes scripts, frames, and HTML comments, and contains an HTML root with related resources. It does not create a plain-text alternative, does not generate Message-ID, and does not automatically make a fully addressed, ready-to-send message. Load it into Chilkat.Email or a mail client and set the required addressing and subject information before sending.Returns normally on success; throws an Error on failure.
GetAndSaveEMLAsync
Asynchronous form of GetAndSaveEML: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
GetAndSaveMHT
Creates MHT output from the HTTP/HTTPS page or local HTML file in urlOrHtmlFilepath and saves it to the destination path in mhtPath. Supported statically referenced resources are captured according to the current MHT properties.
urlOrHtmlFilepath is classified: Chilkat treats urlOrHtmlFilepath as a web URL only when it begins, case-insensitively, with http: or https:. Every other value is treated as a local file path. file:// URLs are not supported; pass a plain filesystem path instead. Relative paths are resolved against the process current working directory, and the local file must already exist and be readable. A value such as www.example.com/page.html has no recognized scheme and is therefore treated as a local path.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.NoScripts and PreferMHTScripts.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success. This resilience applies only to dependent resources; failure to fetch the primary URL or read the primary local HTML file fails the operation.false. Using the same local file as both source and destination is mechanically allowed because the source is read first, but the subsequent write destroys the original HTML file. On Windows, this method also rejects destination paths containing characters that are invalid in Windows filenames, such as ?, before generation begins.Mht.multipart/related; when none are embedded, it can collapse to a single text/html part. MHT output omits the Date and X-Unsent headers and can preserve scripts, frames, and comments according to the script settings.Returns normally on success; throws an Error on failure.
GetAndSaveMHTAsync
Asynchronous form of GetAndSaveMHT: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
GetAndZipEML
Creates EML output from the HTTP/HTTPS page or local HTML file in urlOrHtmlFilepath and stores it as the ZIP entry named by zipEntryFilename inside the archive file in zipFilename. The ZIP is created if it does not exist; otherwise the new entry is appended. Style sheets are captured, images follow EmbedImages and EmbedLocalOnly, and scripts and frames are removed.
urlOrHtmlFilepath is classified: Chilkat treats urlOrHtmlFilepath as a web URL only when it begins, case-insensitively, with http: or https:. Every other value is treated as a local file path. file:// URLs are not supported; pass a plain filesystem path instead. Relative paths are resolved against the process current working directory, and the local file must already exist and be readable. A value such as www.example.com/page.html has no recognized scheme and is therefore treated as a local path.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.urlOrHtmlFilepath is the source, zipEntryFilename is the entry name inside the ZIP, and zipFilename is the ZIP file path.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success. This resilience applies only to dependent resources; failure to fetch the primary URL or read the primary local HTML file fails the operation.Mht.zipEntryFilename already exists in a valid opened ZIP archive, the method returns false. It neither replaces the existing entry nor creates a duplicate.zipEntryFilename for entry subdirectories; explicit directory entries are unnecessary.? is rejected.Date and X-Unsent: 1, removes scripts, frames, and HTML comments, and contains an HTML root with related resources. It does not create a plain-text alternative, does not generate Message-ID, and does not automatically make a fully addressed, ready-to-send message. Load it into Chilkat.Email or a mail client and set the required addressing and subject information before sending.Returns normally on success; throws an Error on failure.
GetAndZipEMLAsync
Asynchronous form of GetAndZipEML: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
GetAndZipMHT
Creates MHT output from the HTTP/HTTPS page or local HTML file in urlOrHtmlFilepath and stores it as the ZIP entry named by zipEntryFilename inside the archive file in zipFilename. The ZIP is created if it does not exist; otherwise the new entry is appended. Supported statically referenced resources are captured according to the current properties.
urlOrHtmlFilepath is classified: Chilkat treats urlOrHtmlFilepath as a web URL only when it begins, case-insensitively, with http: or https:. Every other value is treated as a local file path. file:// URLs are not supported; pass a plain filesystem path instead. Relative paths are resolved against the process current working directory, and the local file must already exist and be readable. A value such as www.example.com/page.html has no recognized scheme and is therefore treated as a local path.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.urlOrHtmlFilepath is the source, zipEntryFilename is the entry name inside the ZIP, and zipFilename is the ZIP file path.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success. This resilience applies only to dependent resources; failure to fetch the primary URL or read the primary local HTML file fails the operation.Mht.zipEntryFilename already exists in a valid opened ZIP archive, the method returns false. It neither replaces the existing entry nor creates a duplicate.zipEntryFilename for entry subdirectories; explicit directory entries are unnecessary.? is rejected.multipart/related; when none are embedded, it can collapse to a single text/html part. MHT output omits the Date and X-Unsent headers and can preserve scripts, frames, and comments according to the script settings.Returns normally on success; throws an Error on failure.
GetAndZipMHTAsync
Asynchronous form of GetAndZipMHT: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
GetCacheRoot
Returns the cache-root directory at zero-based index index. Cache roots are added with AddCacheRoot, and their count is available from NumCacheRoots.
0 through NumCacheRoots - 1. The returned string is cleared when the call begins. If no cache root is configured or index is outside the valid range, LastMethodSuccess is false and the returned string is empty. On success, LastMethodSuccess is true and the returned string contains the root path. Check LastMethodSuccess, not whether the returned string is empty; use LastErrorText for the failure diagnostic.Throws an Error on failure (where the description says null is returned, the method throws instead).
GetEML
Creates an EML MIME message from the HTTP/HTTPS page or local HTML file in urlOrHtmlFilepath and returns the complete EML text in memory. Style sheets and their referenced CSS resources are captured. Images are embedded according to EmbedImages and EmbedLocalOnly. Scripts and framed documents are removed.
urlOrHtmlFilepath is classified: Chilkat treats urlOrHtmlFilepath as a web URL only when it begins, case-insensitively, with http: or https:. Every other value is treated as a local file path. file:// URLs are not supported; pass a plain filesystem path instead. Relative paths are resolved against the process current working directory, and the local file must already exist and be readable. A value such as www.example.com/page.html has no recognized scheme and is therefore treated as a local path.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.Mht.GetAndSaveEML avoids keeping the final EML text solely in the return value.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success. This resilience applies only to dependent resources; failure to fetch the primary URL or read the primary local HTML file fails the operation.LastMethodSuccess: The returned string is cleared when the call begins and may be empty or partially populated if the method fails. A nonempty string does not prove success, and an empty string should not be used as the failure test. Use LastMethodSuccess as the authoritative result; when it is false, inspect LastErrorText. A failed call never returns the previous call's string.Date and X-Unsent: 1, removes scripts, frames, and HTML comments, and contains an HTML root with related resources. It does not create a plain-text alternative, does not generate Message-ID, and does not automatically make a fully addressed, ready-to-send message. Load it into Chilkat.Email or a mail client and set the required addressing and subject information before sending.Throws an Error on failure (where the description says null is returned, the method throws instead).
GetEMLAsync
Asynchronous form of GetEML: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
GetMHT
Creates an MHT web archive from the HTTP/HTTPS page or local HTML file in urlOrHtmlFilepath and returns the complete MHT MIME text in memory. Supported statically referenced resources are captured according to the current properties.
urlOrHtmlFilepath is classified: Chilkat treats urlOrHtmlFilepath as a web URL only when it begins, case-insensitively, with http: or https:. Every other value is treated as a local file path. file:// URLs are not supported; pass a plain filesystem path instead. Relative paths are resolved against the process current working directory, and the local file must already exist and be readable. A value such as www.example.com/page.html has no recognized scheme and is therefore treated as a local path.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.Mht.GetAndSaveMHT writes the result directly to a file.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success. This resilience applies only to dependent resources; failure to fetch the primary URL or read the primary local HTML file fails the operation.LastMethodSuccess: The returned string is cleared when the call begins and may be empty or partially populated if the method fails. A nonempty string does not prove success, and an empty string should not be used as the failure test. Use LastMethodSuccess as the authoritative result; when it is false, inspect LastErrorText. A failed call never returns the previous call's string.multipart/related; when none are embedded, it can collapse to a single text/html part. MHT output omits the Date and X-Unsent headers and can preserve scripts, frames, and comments according to the script settings.Throws an Error on failure (where the description says null is returned, the method throws instead).
GetMHTAsync
Asynchronous form of GetMHT: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
HtmlToEML
Creates an EML MIME message from the in-memory HTML string in htmlText and returns the complete EML text. Style sheets and their CSS resources are captured. Images are embedded according to EmbedImages and EmbedLocalOnly. Scripts and framed documents are removed.
BaseUrl when the HTML has no usable <base href> and its relative resources should resolve against a web origin. An HTML <base> element takes precedence. Without a usable base, unresolved relative resources are not captured and their references remain relative.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success, although the resulting MIME document is not fully self-contained for that resource.LastMethodSuccess: The returned string is cleared when the call begins and may be empty or partially populated if the method fails. A nonempty string does not prove success, and an empty string should not be used as the failure test. Use LastMethodSuccess as the authoritative result; when it is false, inspect LastErrorText. A failed call never returns the previous call's string.Date and X-Unsent: 1, removes scripts, frames, and HTML comments, and contains an HTML root with related resources. It does not create a plain-text alternative, does not generate Message-ID, and does not automatically make a fully addressed, ready-to-send message. Load it into Chilkat.Email or a mail client and set the required addressing and subject information before sending.Throws an Error on failure (where the description says null is returned, the method throws instead).
HtmlToEMLAsync
Asynchronous form of HtmlToEML: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
HtmlToEMLFile
Creates EML output from the in-memory HTML string in html and saves it to the file path in emlFilename. Style sheets and their CSS resources are captured. Images are embedded according to EmbedImages and EmbedLocalOnly. Scripts and framed documents are removed.
BaseUrl when the HTML has no usable <base href> and its relative resources should resolve against a web origin. An HTML <base> element takes precedence. Without a usable base, unresolved relative resources are not captured and their references remain relative.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success, although the resulting MIME document is not fully self-contained for that resource.false.Date and X-Unsent: 1, removes scripts, frames, and HTML comments, and contains an HTML root with related resources. It does not create a plain-text alternative, does not generate Message-ID, and does not automatically make a fully addressed, ready-to-send message. Load it into Chilkat.Email or a mail client and set the required addressing and subject information before sending.Returns normally on success; throws an Error on failure.
HtmlToEMLFileAsync
Asynchronous form of HtmlToEMLFile: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
HtmlToMHT
Creates an MHT web archive from the in-memory HTML string in htmlText and returns the complete MHT MIME text. Supported statically referenced resources are captured according to the current properties.
BaseUrl when the HTML has no usable <base href> and its relative resources should resolve against a web origin. An HTML <base> element takes precedence. Without a usable base, unresolved relative resources are not captured and their references remain relative.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.NoScripts and PreferMHTScripts.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success, although the resulting MIME document is not fully self-contained for that resource.LastMethodSuccess: The returned string is cleared when the call begins and may be empty or partially populated if the method fails. A nonempty string does not prove success, and an empty string should not be used as the failure test. Use LastMethodSuccess as the authoritative result; when it is false, inspect LastErrorText. A failed call never returns the previous call's string.multipart/related; when none are embedded, it can collapse to a single text/html part. MHT output omits the Date and X-Unsent headers and can preserve scripts, frames, and comments according to the script settings.Throws an Error on failure (where the description says null is returned, the method throws instead).
HtmlToMHTAsync
Asynchronous form of HtmlToMHT: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
HtmlToMHTFile
Creates MHT output from the in-memory HTML string in html and saves it to the file path in mhtFilename. Supported statically referenced resources are captured according to the current properties.
BaseUrl when the HTML has no usable <base href> and its relative resources should resolve against a web origin. An HTML <base> element takes precedence. Without a usable base, unresolved relative resources are not captured and their references remain relative.fetch, XHR, lazy-loaded content, or framework-rendered DOM content—is not captured. MHT output can preserve scripts for execution when the saved archive is later opened; EML output removes scripts.NoScripts and PreferMHTScripts.LastErrorText or the diagnostic log, and continues. The overall conversion still reports success, although the resulting MIME document is not fully self-contained for that resource.false.multipart/related; when none are embedded, it can collapse to a single text/html part. MHT output omits the Date and X-Unsent headers and can preserve scripts, frames, and comments according to the script settings.Returns normally on success; throws an Error on failure.
HtmlToMHTFileAsync
Asynchronous form of HtmlToMHTFile: the same call on a native worker thread, so the JavaScript thread (and the UI) stays responsive. Takes the same arguments and resolves with the same result. While the returned Promise is pending, every other call on this object throws (the object is busy), except abort(), which cancels the call, and assigning the onPercentDone / onProgressInfo callbacks, which report its progress.
Note: the onPercentDone and onProgressInfo callbacks run on the JavaScript thread while the promise is pending, so they can update the UI directly. A rejection's message is "Class.methodAsync: reason"; the full log is in lastErrorText.
Returns a Promise that resolves with the synchronous method's result (undefined for a void method) and rejects with an Error where the synchronous method would throw.
RemoveCustomHeader
Removes custom HTTP request headers having the field name in name. Supply the name without a trailing colon. Header names are matched case-insensitively.
Use ClearCustomHeaders to remove every custom header at once.
RestoreDefaults
Restores a limited set of MHT/EML conversion settings to their defaults and clears two method-added collections.
| Reset by this method | Result |
|---|---|
PreferMHTScripts | Restored to true. |
EmbedImages | Restored to true. |
EmbedLocalOnly | Restored to false. |
NoScripts and related internal script-removal state | Restored to the normal script-enabled MHT behavior. |
External style sheets added by AddExternalStyleSheet | The entire list is cleared. |
Exclusion patterns added by ExcludeImagesMatching | The entire list is cleared. |
BaseUrl, UseCids, UseInline, UseFilename, credentials, proxy settings, or other HTTP-related properties. Remove custom headers with RemoveCustomHeader or ClearCustomHeaders. Cache roots can be cleared only by using a new Mht object.UnpackMHT
Extracts MHT data from mhtFilename. mhtFilename may be either a local MHT file path or the literal MHT MIME text; Chilkat distinguishes the two by detecting MIME headers in the supplied value. unpackDir specifies the unpack directory, htmlFilename specifies the main HTML filename, and partsSubDir specifies the related-parts subdirectory used in normal unpacking.
unpackDir is empty, the unpack directory defaults to . (the process current working directory). If partsSubDir is empty, the related-parts subdirectory defaults to html_parts. Chilkat creates the parts subdirectory beneath the unpack directory when needed. The main HTML file and extracted parts overwrite existing files having the same names. An empty MHT input or an empty htmlFilename HTML filename is an error and causes the method to return false.UnpackDirect to preserve relative Content-Location paths without rewriting HTML; in that mode partsSubDir is ignored. UnpackUseRelPaths controls relative versus absolute references in normal mode.multipart/related message containing a primary HTML body. If either is missing, the method returns false. When several HTML-like parts exist, the primary HTML part is selected and the others are treated as related resources... path segments, drops leading slashes, strips Windows drive prefixes, normalizes UNC-style paths to relative paths, and keeps the result beneath the unpack directory. Degenerate names such as . and .. become _; on Windows, * and ? are replaced with _. This is targeted sanitization, not a guarantee that every platform-specific illegal name is transformed.name_1.ext. Existing files left by an earlier run are overwritten.UnpackDirect is true, the method is intended for MHT data whose Content-Location values are already relative paths. A part whose location begins with http://, https://, or file:/ is logged and not written. Use normal mode for web-captured MHT data.Returns normally on success; throws an Error on failure.
UnpackMHTString
Extracts MHT data from mhtString. Despite the historical method name, mhtString may be either literal MHT MIME text or a local MHT file path; Chilkat distinguishes the two by detecting MIME headers in the supplied value. unpackDir specifies the unpack directory, htmlFilename specifies the main HTML filename, and partsSubDir specifies the related-parts subdirectory used in normal unpacking.
unpackDir is empty, the unpack directory defaults to . (the process current working directory). If partsSubDir is empty, the related-parts subdirectory defaults to html_parts. Chilkat creates the parts subdirectory beneath the unpack directory when needed. Existing files having the same names are overwritten. An empty MHT input or an empty htmlFilename HTML filename is an error and causes the method to return false.UnpackDirect is true, partsSubDir is ignored and relative Content-Location paths are used directly beneath the unpack directory. Otherwise, UnpackUseRelPaths controls relative versus absolute references in the rewritten HTML.multipart/related message containing a primary HTML body. If either is missing, the method returns false. When several HTML-like parts exist, the primary HTML part is selected and the others are treated as related resources... path segments, drops leading slashes, strips Windows drive prefixes, normalizes UNC-style paths to relative paths, and keeps the result beneath the unpack directory. Degenerate names such as . and .. become _; on Windows, * and ? are replaced with _. This is targeted sanitization, not a guarantee that every platform-specific illegal name is transformed.name_1.ext. Existing files left by an earlier run are overwritten.UnpackDirect is true, the method is intended for MHT data whose Content-Location values are already relative paths. A part whose location begins with http://, https://, or file:/ is logged and not written. Use normal mode for web-captured MHT data.Returns normally on success; throws an Error on failure.
Events
While a method runs, Mht reports progress through two optional callback properties. Assign a function to receive the event, or undefined to stop receiving it. The callbacks are delivered on the JavaScript thread, so they are useful with the ...Async methods: during a synchronous call the JavaScript thread is busy inside Chilkat, and the events can only arrive after it returns.
const mht = new Mht()
mht.onPercentDone = (pct) => setProgress(pct) // pct is 0..100
mht.onProgressInfo = (name, value) => console.log(`${name}: ${value}`)
mht.heartbeatMs = 250 // let abort() take effect within a quarter second
const pending = mht.someMethodAsync(...)
cancelButton.onPress = () => mht.abort() // the promise then rejects
await pendingPercentDone fires when an operation's completion percentage is known; ProgressInfo delivers named progress values (what is reported depends on the class and method). There is no AbortCheck callback: to cancel a pending ...Async call, call abort() on the object. Chilkat notices the request at its next progress check, which happens at least every heartbeatMs milliseconds on the classes that have that property (0, the default, disables the heartbeat, so set it for a responsive cancel), and the promise rejects with Chilkat's abort error. abort() is harmless when nothing is pending.
PercentDone
onPercentDone?: (pctDone: number) => void
This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The pctDone argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have pctDone equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).
The PercentDone callback also acts as an AbortCheck event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.
To abort the operation, set the abort output argument to true. This will cause the method to terminate and return a failure status or corresponding failure value.
Example:
mht.onPercentDone = (pct) => {
// pct ranges from 0 to 100.
setProgress(pct) // runs on the JavaScript thread: React state may be updated directly
}
await mht.someMethodAsync(...)
// To stop an operation from within the callback, call mht.abort()ProgressInfo
onProgressInfo?: (name: string, value: string) => void
This event callback provides tag name/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.
Note: Some Chilkat methods don't fire any ProgressInfo events.
Example:
mht.onProgressInfo = (name, value) => console.log(`${name}: ${value}`)
await mht.someMethodAsync(...)