Use convertWithOptions when you need to provide specific configuration for the temporary directory, execution, or LibreOffice binary paths.
Parameters:
document (Buffer): The source document buffer.format (string): The target format.filter (string, optional): LibreOffice filter string.options (Object, optional): Configuration object containing:tmpOptions (Object): Options passed to the tmp library for creating temporary directories.asyncOptions (Object): Options for the internal retry logic (e.g., times, interval).execOptions (Object): Options passed to child_process.execFile.fileName (string): The name used for the temporary source file (defaults to 'source').sofficeAdditionalArgs (Array<string>): Additional command-line arguments to pass to the soffice binary.sofficeBinaryPaths (Array<string>): Custom paths to search for the soffice binary. If not provided, the library searches standard locations for macOS, Linux, and Windows.
callback (function): A callback function that receives (err, result). result is the Buffer of the converted document.
const { convertWithOptions } = require('libreoffice-convert');
const options = {
fileName: 'my-document.odt',
sofficeAdditionalArgs: ['--no-sandbox'],
asyncOptions: {
times: 5,
interval: 500
}
};
convertWithOptions(inputBuffer, 'pdf', '', options, (err, outputBuffer) => {
// handle result
});