directus-extension-pdf-filled-viewer-endpoint

0.1.3 • Public • Published

Banner

PDF Filled Viewer

This endpoint allows you to view a filled PDF file in Directus.

Usage

  1. Install the extension using a package manager or from the Marketplace:
npm install directus-extension-pdf-filled-viewer-endpoint
  1. Import this collection.

  2. Update the settings by adding your form filling logic:

return async function (props) {
  const { settings, query, form, fields, createItemsService, logFields, updateFilename, sendResponse } = props;
  const { collection, id } = query;

  if (!collection || !id) {
    sendResponse(404, 'Missing query params: collection or id');
    return;
  }

  try {
    const itemsService = await createItemsService(collection);
    const item = await itemsService.readOne(id);

    form.getCheckBox('<field>').check();
    form.getTextField('<field>').setText('...');
  } catch (e) {
    console.error(e);
  }
}
  1. Add this as the Preview URL:

Format:

<PUBLIC_URL>/pdf-filled-viewer/<filename_disk>

Example:

http://localhost:8055/pdf-filled-viewer/33461458-ed8b-4917-9f74-318ef4731ddf.pdf?collection=items&id=1

Package Sidebar

Install

npm i directus-extension-pdf-filled-viewer-endpoint

Weekly Downloads

10

Version

0.1.3

License

none

Unpacked Size

1.15 MB

Total Files

3

Last publish

Collaborators

  • nerkarso