initialize
Initializes the PDF engine and the underlying WebAssembly library.
Signature
initialize(): PdfTask<boolean>;
Description
This method must be called once before any other engine methods can be used. It sets up the PDFium environment within the WebAssembly module, preparing it for document processing.
Attempting to call other methods like openDocumentUrl
before initialize
has completed will result in an error.
Parameters
This method takes no parameters.
Returns
PdfTask<boolean>
A Task
that resolves with true
once the engine has been successfully initialized and is ready for use.
See Concepts: Tasks for more on how to handle asynchronous operations.
Example
// Assuming 'engine' is a newly created WebWorkerEngine or PdfiumEngine instance
async function setupPdfProcessor() {
try {
const success = await engine.initialize().toPromise();
if (success) {
console.log('PDF engine is ready!');
// You can now safely call other engine methods.
}
} catch (error) {
console.error('Failed to initialize PDF engine:', error);
}
}
setupPdfProcessor();
See Also
Last updated on August 14, 2025
Need Help?
Join our community for support, discussions, and to contribute to EmbedPDF's development.