directus-extension-pdf-filled-viewer-endpoint
v0.1.3
Published
View a filled PDF file from an endpoint
Downloads
1
Maintainers
Readme
PDF Filled Viewer
This endpoint allows you to view a filled PDF file in Directus.
Usage
- Install the extension using a package manager or from the Marketplace:
npm install directus-extension-pdf-filled-viewer-endpoint
Import this collection.
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);
}
}
- 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