Nutrient Web SDK

v0.0.0-dev

Function convertToPDF

Converts a file to a PDF.

Returns a Promise resolving to an ArrayBuffer of a PDF, or rejecting with a NutrientViewer.Error.

The resulting ArrayBuffer can be directly loaded with NutrientViewer.load().

It requires a configuration object. If the configuration is invalid, the promise will be rejected with a NutrientViewer.Error.

Function
Type Signature
convertToPDF(
    configuration: StandaloneConfiguration,
    conformance?:
        | "pdfa-1a"
        | "pdfa-1b"
        | "pdfa-2a"
        | "pdfa-2u"
        | "pdfa-2b"
        | "pdfa-3a"
        | "pdfa-3u"
        | "pdfa-3b"
        | "pdfa-4"
        | "pdfa-4e"
        | "pdfa-4f"
        | null,
    officeConversionSettings?: OfficeConversionSettings,
): Promise<ArrayBuffer>
  • Type Declaration

    Parameters

    configurationStandaloneConfiguration

    A configuration Object

    conformance"pdfa-1a"
    | "pdfa-1b"
    | "pdfa-2a"
    | "pdfa-2u"
    | "pdfa-2b"
    | "pdfa-3a"
    | "pdfa-3u"
    | "pdfa-3b"
    | "pdfa-4"
    | "pdfa-4e"
    | "pdfa-4f"
    | null
    Optional

    A conformance level of the output PDF

    officeConversionSettingsOfficeConversionSettings
    Optional

    Settings specific to office conversion

    Returns

    Promise that resolves to an ArrayBuffer of a file converted to PDF

    Example

    NutrientViewer.convertToPDF({
    document: "/sales-report.docx",
    licenseKey: "YOUR_LICENSE_KEY",
    }).then((arrayBuffer) => {
    console.log("Successfully converted document", arrayBuffer);
    }).catch((error) => {
    console.error(error.message);
    })

    @public