Skip to content

Commit

Permalink
add guide for PDF form filling
Browse files Browse the repository at this point in the history
  • Loading branch information
mickhansen committed Mar 14, 2024
1 parent 7dc521c commit ef27b92
Show file tree
Hide file tree
Showing 13 changed files with 461 additions and 11 deletions.
26 changes: 26 additions & 0 deletions graphql-signatures-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,15 @@ export type OidcJwtSignatureEvidenceProvider = SignatureEvidenceProvider & Singl
name: Scalars['String']['output'];
};

export type PadesDocumentFormInput = {
enabled: Scalars['Boolean']['input'];
};

export type PadesDocumentInput = {
blob: Scalars['Blob']['input'];
/** Will add a unique identifier for the document to the specified margin of each page. Useful when printing signed documents. */
displayDocumentID?: InputMaybe<DocumentIdLocation | '%future added value'>;
form?: InputMaybe<PadesDocumentFormInput>;
/** Will not be displayed to signatories, can be used as a reference to your own system. */
reference?: InputMaybe<Scalars['String']['input']>;
storageMode: DocumentStorageMode | '%future added value';
Expand All @@ -613,6 +618,7 @@ export type PageInfo = {
export type PdfDocument = Document & {
__typename?: 'PdfDocument';
blob?: Maybe<Scalars['Blob']['output']>;
form?: Maybe<PdfDocumentForm>;
id: Scalars['ID']['output'];
originalBlob?: Maybe<Scalars['Blob']['output']>;
reference?: Maybe<Scalars['String']['output']>;
Expand All @@ -621,6 +627,11 @@ export type PdfDocument = Document & {
title: Scalars['String']['output'];
};

export type PdfDocumentForm = {
__typename?: 'PdfDocumentForm';
enabled: Scalars['Boolean']['output'];
};

export type PdfSealPosition = {
page: Scalars['Int']['input'];
x: Scalars['Float']['input'];
Expand Down Expand Up @@ -719,6 +730,20 @@ export type SignCriiptoVerifyInput = {
jwt: Scalars['String']['input'];
};

export type SignDocumentFormFieldInput = {
field: Scalars['String']['input'];
value: Scalars['String']['input'];
};

export type SignDocumentFormInput = {
fields: Array<SignDocumentFormFieldInput>;
};

export type SignDocumentInput = {
form?: InputMaybe<SignDocumentFormInput>;
id: Scalars['ID']['input'];
};

export type SignDrawableInput = {
image: Scalars['Blob']['input'];
name?: InputMaybe<Scalars['String']['input']>;
Expand All @@ -727,6 +752,7 @@ export type SignDrawableInput = {
export type SignInput = {
allOf?: InputMaybe<SignAllOfInput>;
criiptoVerify?: InputMaybe<SignCriiptoVerifyInput>;
documents?: InputMaybe<Array<SignDocumentInput>>;
drawable?: InputMaybe<SignDrawableInput>;
/** EvidenceProvider id */
id: Scalars['ID']['input'];
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"@criipto/jwt-viewer": "^1.2.0",
"@criipto/signatures": "^1.4.0",
"@criipto/signatures": "^1.5.0",
"@criipto/ui-operations-status": "^1.1.1",
"@fontsource/roboto-mono": "^4.5.8",
"@fortawesome/fontawesome-svg-core": "^1.3.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/MdxProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const H2 = (props: {children: string}) => (
</h2>
);

export const H3 = (props: {children: string}) => (
<h3 {...props} className="group flex whitespace-pre-wrap -ml-4 pl-4 text-gray-ash-900 text-medium text-display-sm">
export const H3 = (props: {children: string, className?: string}) => (
<h3 {...props} className={`group flex whitespace-pre-wrap -ml-4 pl-4 text-gray-ash-900 text-medium text-display-sm ${props.className ?? ''}`}>
<a id={textToId(props.children)} className="relative top-[-150px] lg:top-[-90px]" />
<a
href={`#${textToId(props.children)}`}
Expand Down
1 change: 1 addition & 0 deletions src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const SIGNATURES_CATEGORIES = [
"Getting Started",
"GraphQL",
"Integrations",
"Guides",
"Webhooks"
];

Expand Down
29 changes: 29 additions & 0 deletions src/examples/createSignatureOrder/pdfFormFilling.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Criipto.Signatures;
using Criipto.Signatures.Models;

using (var client = new CriiptoSignaturesClient("{YOUR_CRIIPTO_CLIENT_ID}", "{YOUR_CRIIPTO_CLIENT_SECRET}")) {
// Setup document input
var documents = new List<DocumentInput>{
new DocumentInput {
pdf = new PadesDocumentInput {
title = "PDF Form Sample",
blob = new Byte[64], // Should be the bytes of a PDF file
storageMode = DocumentStorageMode.Temporary,
form = new PadesDocumentFormInput {
enabled = true
}
}
}
};

// Setup signature order input
var createSignatureOrderInput = new CreateSignatureOrderInput
{
title = "PDF Form Sample",
documents = documents,

};

// Create signature order
var signatureOrder = await client.CreateSignatureOrder(createSignatureOrderInput);
}
24 changes: 24 additions & 0 deletions src/examples/createSignatureOrder/pdfFormFilling.graphql.ts

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/examples/createSignatureOrder/pdfFormFilling.node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import CriiptoSignatures from "@criipto/signatures";

const client = new CriiptoSignatures("{YOUR_CRIIPTO_CLIENT_ID}", "{YOUR_CRIIPTO_CLIENT_SECRET}");

const signatureOrder = await client.createSignatureOrder({
title: "PDF Form Sample",
documents: [
{
pdf: {
title: "PDF Form Sample",
blob: Buffer.from("..."), // Should be the buffer of a PDF file with form fields
storageMode: 'Temporary',
form: {
enabled: true
}
}
}
],
});

console.log(signatureOrder.id);
19 changes: 19 additions & 0 deletions src/examples/createSignatureOrder/pdfFormFilling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import csharp from '!!raw-loader!./pdfFormFilling.cs';
import nodejs from '!!raw-loader!./pdfFormFilling.node.ts';
import { Example } from '../misc';
import { query, variables } from './pdfFormFilling.graphql';

const example : Example[] = [
{
query,
variables
},
{
csharp
},
{
nodejs
}
];

export default example;
2 changes: 1 addition & 1 deletion src/examples/examples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Criipto.Signatures" Version="1.10.0" />
<PackageReference Include="Criipto.Signatures" Version="1.11.0" />
</ItemGroup>
</Project>
Loading

0 comments on commit ef27b92

Please sign in to comment.