# Convert PDFs and images to PDF/A using JavaScript

Nutrient Web SDK enables you to convert PDFs, Office documents, and images to PDF/A client-side, without the need for server-side processing. For more information on the supported source file formats, see the [list of supported file types](https://www.nutrient.io/guides/web/about/file-type-support.md).

[Try for Free](https://www.nutrient.io/sdk/web/getting-started.md)

[Launch Demo](https://www.nutrient.io/demo/convert-to-pdfa)

Nutrient Web SDK supports converting source files into all PDF/A versions and conformance levels:

- PDF/A-1a, PDF/A-1b

- PDF/A-2a, PDF/A-2u, PDF/A-2b

- PDF/A-3a, PDF/A-3u, PDF/A-3b

- PDF/A-4, PDF/A-4e, PDF/A-4f

For more information on the long-term preservation of documents, check out our demo video below, or have a look at our [complete guide to PDF/A](https://www.nutrient.io/blog/what-is-pdf-a/).

## Converting documents to PDF/A

To convert a PDF, an Office file, or an image to PDF/A, follow the steps below.

1. [Load the source file](https://www.nutrient.io/guides/web/open-a-document.md).

2. Use the `exportPDF` method to convert the source file to PDF/A. This method takes an object as its parameter, which configures the conversion. For conversion to PDF/A, add an `outputFormat` key to the configuration object that you pass to the `exportPDF` method. The value of this key is an object. Within this object, the value of the `conformance` key is a member of the `Conformance` enumeration that specifies the conformance level of the output PDF document. If you set this value to `true`, the output is a document with conformance level PDF/A-2b.

3. Save the output document. The `exportPDF` method returns a `Promise` that resolves to an `ArrayBuffer` that contains the output PDF/A document. You can use the resulting `ArrayBuffer` to download or persist the output PDF/A in storage. For more information on downloading or persisting the exported `ArrayBuffer`, see the [guides on saving a document](https://www.nutrient.io/guides/web/save-a-document.md).

The example below loads a PDF document and exports it to a PDF with conformance level PDF/A-4f:

```js

NutrientViewer.load({
  container: "#pspdfkit",

  document: "source.pdf",
  licenseKey: "YOUR_LICENSE_KEY"
}).then((instance) => {
  instance.exportPDF({
    outputFormat: {
      conformance: NutrientViewer.Conformance.PDFA_4F
    }
  });
});

```

The example below loads a PDF document in headless mode, exports it to a PDF/A document with conformance level PDF/A-2b, and downloads it in the client’s browser:

```js

NutrientViewer.load({
  container: "#pspdfkit",

  document: "source.pdf",
  licenseKey: "YOUR_LICENSE_KEY",
  headless: true
}).then((instance) =>
    instance.exportPDF({
      outputFormat: true
    })
  ).then(function (buffer) {
    const blob = new Blob([buffer], { type: "application/pdf" });
    const objectUrl = window.URL.createObjectURL(blob);
    downloadPdf(objectUrl);
    window.URL.revokeObjectURL(objectUrl);
  });
function downloadPdf(blob) {
  const a = document.createElement("a");
  a.href = blob;
  a.style.display = "none";
  a.download = "output.pdf";
  a.setAttribute("download", "output.pdf");
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
}

```

When exporting a document, you have several options. Refer to our guides on [flattening annotations](https://www.nutrient.io/guides/web/annotations/flatten.md) and [incremental saving](https://www.nutrient.io/guides/web/features/document-processing.md) for more details.

Auto saving can be configured for different scenarios and use cases. You can find more information in our [auto save](https://www.nutrient.io/guides/web/features/saving.md) guide.
---

## Related pages

- [Convert images to PDFs using JavaScript](/guides/web/conversion/image-to-pdf.md)
- [Headless file conversion](/guides/web/conversion/headless.md)
- [Convert images to text using JavaScript](/guides/web/conversion/image-to-text.md)
- [Convert PDFs to images using JavaScript](/guides/web/conversion/pdf-to-image.md)
- [Convert scanned PDFs to searchable PDFs using JavaScript](/guides/web/conversion/scan-to-searchable-pdf.md)
- [Convert PDF to Office using JavaScript](/guides/web/conversion/pdf-to-office.md)
- [Convert Office to PDF using JavaScript](/guides/web/conversion/office-to-pdf.md)
- [Convert text to PDF using JavaScript](/guides/web/conversion/text-to-pdf.md)
- [JavaScript PDF conversion library](/guides/web/conversion.md)

