1.2.0 • Published 9 months ago

@cincel.digital/doc-convert-plugin v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

@cincel.digital/doc-convert-plugin

This package provides a plugin for converting various file types to PDF using LibreOffice on the server. It is designed to be used with the Hapi framework.

Installation

yarn add @cincel.digital/doc-convert-plugin

# or

npm i @cincel.digital/doc-convert-plugin

Usage

const Hapi = require("hapi")(async () => {
  const server = await new Hapi.Server({
    port: 8000,
  })

  await server.register({
    plugin: require("@cincel.digital/doc-convert-plugin"),
    // options: {},
  })
})()

Configuration

The plugin accepts the following options:

  • maxFileSize (optional): Maximum allowed file size in bytes. Default is 5MB.
  • endpointUrl (optional): The URL endpoint for the conversion. Default is "/convert-to-pdf".
  • dest (optional): The destination directory where uploaded files will be stored. Default is "uploads".
  • accept (optional): An object specifying the accepted file types for conversion. Default is a predefined set of file types including images, Microsoft Excel, Microsoft Word, and CSV.

API

The plugin provides a single endpoint for file conversion:

  • POST {endpointUrl}: Upload a file and convert it to PDF. The file should be sent as a multipart/form-data payload with the field name file. The response will be the converted PDF file.

Error Handling

The plugin may send the following errors in case of failure:

Error CodeStatusMessage
ERR_001415Unsupported Media Type
ERR_002500LibreOffice is not installed on the server.
ERR_003422The provided file does not conform to the expected format. Please ensure that the 'file' property is a valid Readable stream.
ERR_004400The PDF file cannot be used because it is encrypted.
ERR_005400The PDF file was not generated correctly.
1.2.1-dev.0

9 months ago

1.2.0

9 months ago

1.2.0-dev.5

9 months ago

1.2.0-dev.4

9 months ago

1.2.0-dev.3

10 months ago

1.2.0-dev.2

10 months ago

1.2.0-dev.1

10 months ago

1.2.0-dev.0

10 months ago