
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
libreoffice-file-converter
Advanced tools
Simple NodeJS wrapper for libreoffice CLI for converting office documents to different formats
Simple NodeJS wrapper for libreoffice CLI for converting office documents to different formats.
Please install libreoffice in /Applications (Mac), with your favorite package manager (Linux), or with the msi (Windows).
LibreOfficeFileConverter
constructor accepts optional configuration object.
options.binaryPaths
Array of paths to LibreOffice binary executables.
options.childProcessOptions
child_process.ExecFileOptions
object. Can be used to configure such things as timeout, etc.
options.debug
Enables debug output for LibreOffice command execution.
options.tmpOptions
tmp.DirOptions
object. Can be used to configure behavior of tmp
package, which is used to create temporary folders for LibreOffice data.
LibreOfficeFileConverter.convert
Converts provided file, Buffer
or Readable
stream to the request format.
input
Input type: buffer
| file
| stream
.
Defines corresponding field for input: buffer
| inputPath
| stream
.
output
Output type: buffer
| file
| stream
.
Requires outputPath
field to be present when set to file
.
Defines return type: Promise<Buffer>
| Promise<void>
| Promise<Readable>
.
format
Conversion format.
inputFilter
LibreOffice input filter, see docs.
outputFilter
LibreOffice output filter, see docs.
filter
LibreOffice output filter, see docs.
Deprecated, use outputFilter
instead.
options
Overrides for LibreOfficeFileConverter instance options.
From Buffer
to Buffer
.
import { readFile } from 'fs/promises';
import { join } from 'path';
import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
const inputPath = join(__dirname, './resources/example.doc');
const run = async () => {
const libreOfficeFileConverter = new LibreOfficeFileConverter({
childProcessOptions: {
timeout: 60 * 1000,
},
});
const inputBuffer = await readFile(inputPath);
const outputBuffer = await libreOfficeFileConverter.convert({
buffer: inputBuffer,
format: 'pdf',
input: 'buffer',
output: 'buffer'
})
};
run();
From Buffer
to file.
import { readFile } from 'fs/promises';
import { join } from 'path';
import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
const inputPath = join(__dirname, './resources/example.doc');
const outputPath = join(__dirname, './resources/output/result.pdf');
const run = async () => {
const libreOfficeFileConverter = new LibreOfficeFileConverter({
childProcessOptions: {
timeout: 60 * 1000,
},
});
const inputBuffer = await readFile(inputPath);
await libreOfficeFileConverter.convert({
buffer: inputBuffer,
format: 'pdf',
input: 'buffer',
output: 'fille',
outputPath,
})
};
run();
From Buffer
to Readable
stream.
import { readFile } from 'fs/promises';
import { join } from 'path';
import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
const inputPath = join(__dirname, './resources/example.doc');
const run = async () => {
const libreOfficeFileConverter = new LibreOfficeFileConverter({
childProcessOptions: {
timeout: 60 * 1000,
},
});
const inputBuffer = await readFile(inputPath);
const outputStream = await libreOfficeFileConverter.convert({
buffer: inputBuffer,
format: 'pdf',
input: 'buffer',
output: 'stream',
})
};
run();
From file to Buffer
.
import { readFile } from 'fs/promises';
import { join } from 'path';
import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
const inputPath = join(__dirname, './resources/example.doc');
const run = async () => {
const libreOfficeFileConverter = new LibreOfficeFileConverter({
childProcessOptions: {
timeout: 60 * 1000,
},
});
const outputBuffer = await libreOfficeFileConverter.convert({
format: 'pdf',
input: 'file',
inputPath,
output: 'buffer',
})
};
run();
From file to file.
import { readFile } from 'fs/promises';
import { join } from 'path';
import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
const inputPath = join(__dirname, './resources/example.doc');
const outputPath = join(__dirname, './resources/output/result.pdf');
const run = async () => {
const libreOfficeFileConverter = new LibreOfficeFileConverter({
childProcessOptions: {
timeout: 60 * 1000,
},
});
await libreOfficeFileConverter.convert({
format: 'pdf',
input: 'file',
inputPath,
output: 'file',
outputPath,
})
};
run();
From file to Readable
stream.
import { readFile } from 'fs/promises';
import { join } from 'path';
import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
const inputPath = join(__dirname, './resources/example.doc');
const run = async () => {
const libreOfficeFileConverter = new LibreOfficeFileConverter({
childProcessOptions: {
timeout: 60 * 1000,
},
});
const outputStream = await libreOfficeFileConverter.convert({
format: 'pdf',
input: 'file',
inputPath,
output: 'stream',
})
};
run();
From Readable
stream to Buffer
.
import { createReadStream } from 'fs';
import { join } from 'path';
import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
const inputPath = join(__dirname, './resources/example.doc');
const run = async () => {
const libreOfficeFileConverter = new LibreOfficeFileConverter({
childProcessOptions: {
timeout: 60 * 1000,
},
});
const inputStream = createReadStream(inputPath);
const outputBuffer = await libreOfficeFileConverter.convert({
format: 'pdf',
input: 'stream',
output: 'buffer',
stream: inputStream,
})
};
run();
From Readable
stream to file.
import { createReadStream } from 'fs';
import { join } from 'path';
import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
const inputPath = join(__dirname, './resources/example.doc');
const outputPath = join(__dirname, './resources/output/result.pdf');
const run = async () => {
const libreOfficeFileConverter = new LibreOfficeFileConverter({
childProcessOptions: {
timeout: 60 * 1000,
},
});
const inputStream = createReadStream(inputPath);
await libreOfficeFileConverter.convert({
format: 'pdf',
input: 'stream',
output: 'file',
outputPath,
stream: inputStream,
})
};
run();
From Readable
stream to Readable
stream.
import { createReadStream } from 'fs';
import { join } from 'path';
import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
const inputPath = join(__dirname, './resources/example.doc');
const run = async () => {
const libreOfficeFileConverter = new LibreOfficeFileConverter({
childProcessOptions: {
timeout: 60 * 1000,
},
});
const inputStream = createReadStream(inputPath);
const outputStream = await libreOfficeFileConverter.convert({
format: 'pdf',
input: 'stream',
output: 'stream',
stream: inputStream,
})
};
run();
FAQs
Simple NodeJS wrapper for libreoffice CLI for converting office documents to different formats
The npm package libreoffice-file-converter receives a total of 600 weekly downloads. As such, libreoffice-file-converter popularity was classified as not popular.
We found that libreoffice-file-converter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.