import { useEffect, useState } from 'react';
import { Viewer, DocumentGate, isPluginError } from '@embedpdf/react/runtime';
import type { OpenInput } from '@embedpdf/react/runtime';
import { metadataPlugin, useMetadata, useMetadataState } from '@embedpdf/react/metadata';
import { cloudEngine } from '@cloudpdf/engine';
import './custom-fields.css';
const engine = cloudEngine();
const plugins = [metadataPlugin()];
const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' };
// Your own fields, kept in the document: add one, change one, remove one.
function CustomFields() {
const metadata = useMetadata();
const { custom } = useMetadataState();
const [name, setName] = useState('');
const [value, setValue] = useState('');
const [error, setError] = useState {error}
{error &&
{Object.entries(custom ?? {}).map(([key, text]) => (
Name
Value
))}
{key}
{text}