Luchdaich suas Faidhle mar Shamhla
Tha am fearainn seo a’ sealltainn dhut tron phròiseas làn-chuid a bhith a’ cruthachadh teamplaid agus a’ luchdachadh suas faidhle PDF, ìomhaigh, no Word airson cleachdadh mar do teamplaid sgrìobhainn ann an Legalesign.
Dè a Dh’ionnsaicheas Tu
Aig deireadh an stiùiridh seo, bidh fios agad mar a:
- Cruthaich teamplaid ùr anns an buidheann Legalesign agad
- Faigh an ID teamplaid agus URL luchdachaidh suas bhon fhreagairt mutation
- Luchdaich suas am faidhle stòr agad chun an teamplaid
- Dèan cinnteach gu bheil an luchdachadh suas soirbheachail
Feumalachdan Ro-Thòiseachaidh
Mus tòisich thu, dèan cinnteach gu bheil agad:
- Cunntas Legalesign le cothrom API
- Na teisteanasan eòlach agad (faic an stiùireadh teisteanais againn)
- PDF, ìomhaigh, no faidhle Word deiseil airson luchdachadh suas (as àirde 50MB)
- Do ID buidhne (an àite-obrach far a bheil thu airson an teamplaid a chruthachadh)
Am Pròiseas Làn-chuid
Ceum 1: Cruthaich Teamplaid
An toiseach, cruthaich teamplaid falamh ann an Legalesign. Bidh seo a’ toirt air ais an dà chuid an ID teamplaid agus URL luchdachaidh suas air a shoidhnigeadh ro-làimh airson luchdachadh suas PDF. Gus seo a dhèanamh feumaidh tu ruith mutation GraphQL, ma chan eil thu air seo a dhèanamh roimhe faic an Ro-ràdh gu GraphQL.
Dè th' ann an Teamplaid?
Tha teamplaid na structar sgrìobhainn ath-chleachdadh ann an Legalesign. Aon uair ‘s gu bheil thu air PDF a luchdachadh suas gu teamplaid, faodaidh tu:
- Raointean soidhnidh agus raointean foirme a chur ris
- A chuir gu luchd-faighinn ioma-fhillte
- A chleachdadh a-rithist airson diofar luchd-soidhnidh
Mutation GraphQL
mutation CreateTemplate($input: templateCreateInput!) {
createTemplate(input: $input) {
id
uploadUrl
}
}
Caibideilean Steach
{
"input": {
"groupId": "grpYourGroupAPIId",
"title": "Employment Contract Template"
}
}
Paramadairean air an Mìneachadh
- groupId: ID bun-64 den bhuidheann/àite-obrach agad (faodaidh tu seo fhaighinn bhon URL ann am Console https://console.legalesign.com/)
- title: Ainm tuairisgeulach airson do teamplaid (faodaidh tu seo atharrachadh nas fhaide air adhart)
- uploadOptions (roghnach): Roghainnean pròiseasachaidh air an cur an sàs nuair a thèid am PDF a luchdachadh suas:
pdfFieldsImport: true— toirt a-steach raointean foirme PDF innleanaichte mar raointean teamplaidprocessTags: true— pròiseas do shluaigh teacsa Legalesign san sgrìobhainn nuair a thèid a luchdachadh suas
Ceum 2: Tarraing a-mach ID Teamplaid agus URL Luchdaich Suas
Bidh an mutation a’ toirt air ais nì templateCreateOutput. Sàbhail an raon id agus an sreang uploadUrl.
Freagairt eisimpleireach:
{
"data": {
"createTemplate": {
"id": "dHBsYjQ5YTg5NWQtYWRhMy0xMWYwLWIxZGMtMDY5NzZlZmU0MzIx",
"uploadUrl": "https://s3.amazonaws.com/bucket/path?signature=..."
}
}
}
Tha ID an teamplaid na shreath a thèid a chódaich ann am Base64. Sàbhail an dà luach bhon fhreagairt. Tha an uploadUrl geàrr-ùine agus bu chòir a chleachdadh gu luath.
Ceum 3: Luchdaich Suas Do PDF
Cleachd an uploadUrl a chaidh a thoirt air ais gus do faidhle PDF a luchdachadh suas gu dìreach gu S3. Bidh seo eadar-dhealaichte
a rèir do stac leasachaidh. Anns an eisimpleir javascript againn tha sinn air fetch a chleachdadh ach
faodaidh tu leabharlannan eile a chleachdadh nam measg aws-amplify.
Eisimpleirean Obrach Làn-chuid
- JavaScript
- Python
- C#
import fs from 'fs';
const AUTH_TOKEN = '<token-from-authentication-guide>';
const uploadPdfTemplate = async (groupId, title, pdfFilePath) => {
const graphqlEndpoint = 'https://graphql.uk.legalesign.com/graphql';
// Step 1: Create the template
console.log('Creating template...');
const createResponse = await fetch(graphqlEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${AUTH_TOKEN}`
},
body: JSON.stringify({
query: `
mutation CreateTemplate($input: templateCreateInput!) {
createTemplate(input: $input) {
id
uploadUrl
}
}
`,
variables: {
input: {
groupId: groupId,
title: title
}
}
})
});
const createResult = await createResponse.json();
const templateId = createResult.data.createTemplate.id;
const uploadUrl = createResult.data.createTemplate.uploadUrl;
console.log('Template created with ID:', templateId);
// Step 2: Upload the PDF
console.log('Uploading PDF...');
const fileData = fs.readFileSync(pdfFilePath);
const uploadResponse = await fetch(uploadUrl, {
method: 'PUT',
body: fileData,
headers: {
'Content-Type': 'application/pdf'
}
});
if (!uploadResponse.ok) {
throw new Error(`Upload failed: ${uploadResponse.statusText}`);
}
console.log('PDF uploaded successfully!');
return {
success: true,
templateId: templateId,
title: title
};
};
// Usage example
uploadPdfTemplate(
'grpYourGroupId',
'Employment Contract',
'./contract.pdf'
).then(result => {
console.log('Complete!', result);
}).catch(error => {
console.error('Error:', error);
});
Chan eil eisimeileachd dheth a bharrachd riatanach — tha Node.js 18+ a’ toirt a-steach fetch gu dùthchasach.
import requests
from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport
def upload_pdf_template(graphql_endpoint, auth_token, group_id, title, pdf_file_path):
transport = RequestsHTTPTransport(
url=graphql_endpoint,
headers={'Authorization': auth_token}
)
client = Client(transport=transport, fetch_schema_from_transport=True)
# Step 1: Create the template
print('Creating template...')
create_mutation = gql('''
mutation CreateTemplate($input: templateCreateInput!) {
createTemplate(input: $input) {
id
uploadUrl
}
}
''')
create_result = client.execute(
create_mutation,
variable_values={
'input': {
'groupId': group_id,
'title': title
}
}
)
template_id = create_result['createTemplate']['id']
upload_url = create_result['createTemplate']['uploadUrl']
print(f'Template created with ID: {template_id}')
# Step 2: Upload the PDF
print('Uploading PDF...')
with open(pdf_file_path, 'rb') as f:
file_data = f.read()
response = requests.put(
upload_url,
data=file_data,
headers={'Content-Type': 'application/pdf'}
)
if response.status_code != 200:
raise Exception(f'Upload failed: {response.status_code}')
print('PDF uploaded successfully!')
return {
'success': True,
'templateId': template_id,
'title': title
}
if __name__ == '__main__':
result = upload_pdf_template(
'https://graphql.uk.legalesign.com/graphql',
'Bearer YOUR_TOKEN',
'grpYourGroupId',
'Employment Contract',
'./contract.pdf'
)
print('Complete!', result)
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using GraphQL;
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;
using Newtonsoft.Json.Linq;
public class PdfTemplateUploader
{
private readonly GraphQLHttpClient graphQLClient;
public PdfTemplateUploader(string graphqlEndpoint, string authToken)
{
graphQLClient = new GraphQLHttpClient(graphqlEndpoint, new NewtonsoftJsonSerializer());
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", authToken);
}
public async Task<UploadResult> UploadPdfTemplate(
string groupId,
string title,
string pdfFilePath)
{
// Step 1: Create the template
Console.WriteLine("Creating template...");
var createMutation = new GraphQLRequest
{
Query = @"
mutation CreateTemplate($input: templateCreateInput!) {
createTemplate(input: $input) {
id
uploadUrl
}
}
",
Variables = new
{
input = new
{
groupId = groupId,
title = title
}
}
};
var createResponse = await graphQLClient.SendMutationAsync<dynamic>(createMutation);
string templateId = createResponse.Data.createTemplate.id;
string uploadUrl = createResponse.Data.createTemplate.uploadUrl;
Console.WriteLine($"Template created with ID: {templateId}");
// Step 2: Upload the PDF
Console.WriteLine("Uploading PDF...");
using var httpClient = new HttpClient();
var fileBytes = await File.ReadAllBytesAsync(pdfFilePath);
var content = new ByteArrayContent(fileBytes);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
var putResponse = await httpClient.PutAsync(uploadUrl, content);
if (!putResponse.IsSuccessStatusCode)
{
throw new Exception($"Upload failed: {putResponse.StatusCode}");
}
Console.WriteLine("PDF uploaded successfully!");
return new UploadResult
{
Success = true,
TemplateId = templateId,
Title = title
};
}
}
public class UploadResult
{
public bool Success { get; set; }
public string TemplateId { get; set; }
public string Title { get; set; }
}
class Program
{
static async Task Main(string[] args)
{
var uploader = new PdfTemplateUploader(
"https://graphql.uk.legalesign.com/graphql",
"Bearer YOUR_TOKEN"
);
var result = await uploader.UploadPdfTemplate(
"grpYourGroupId",
"Employment Contract",
"./contract.pdf"
);
Console.WriteLine($"Complete! Template ID: {result.TemplateId}");
}
}
Dè a Dh'fheumas Tachairt An Àm Luchdaich Suas?
Aon uair 's gu bheil do PDF air a luchdachadh suas, tha Legalesign gu fèin-ghluasadach a’:
- A’ sgrùdadh airson bhìorasan - A’ dèanamh cinnteach gu bheil am faidhle sàbhailte
- A’ dearbhadh no a’ cruth-atharrachadh am faidhle - A’ dèanamh cinnteach gu bheil PDFs dligheach, no a’ cruth-atharrachadh faidhlichean taic mar sgrìobhainnean Word agus ìomhaighean gu PDF
- A’ tarraing a-mach fiosrachadh duilleig - A’ faighinn cunntas air àireamh agus meudan nan duilleagan
- A’ pròiseasadh am faidhle - A’ dèanamh mion-atharrachadh airson sealladh agus soidhnigeadh
- A’ stòradh gu tèarainte - A’ gluasad gu stòradh maireannach
Bidh an t-siostam seo mar as trice a’ gabhail beagan dhiog. Aon uair ‘s gu bheil e deiseil, tha do teamplaid deiseil airson a chleachdadh!
Sgrùdadh Adhartas Luchdaich Suas
Gus fios air ais fìor-ùine fhaighinn air pròiseas luchdachaidh suas (scanadh, dearbhadh, crìoch) cleachd fo-sgrìobhaidhean. Faic Sgrùdadh Adhartas Luchdaich Suas le Fo-sgrìobhaidhean.
Mar roghainn eile, cuir fios gu raon fileUploaded an teamplaid gus faighinn true:
query CheckUploadStatus($id: ID!) {
template(id: $id) {
id
fileUploaded
}
}
A’ Cuir Ris Soidhnichean agus Raointean
Ma tha thu airson luchd-pàirtichean agus suidheachadh raointean fèin-ghluasadach a dhèanamh, faodaidh tu am faidhle stòr ullachadh mus luchdaich thu suas le cuid de dhòighean eadar-dhealaichte:
- Tagaichean teacsa — Cuir tagaichean teacsa Legalesign a-steach don sgrìobhainn stòr gus am bi luchd-pàirtichean, raointean soidhnidh, agus raointean foirme air an cruthachadh gu fèin-ghluasadach aig àm pròiseasachaidh. Cuir seachad
uploadOptions: { processTags: true }anns an mutationcreateTemplateairson seo a chumas. Faic an mìneachadh REST API anns an stiùireadh tòiseachaidh agus an iomradh air an ceangal gluasad tagaichean teacsa. - Raointean PDF innleanaichte — Ma tha raointean foirme innleanaichte anns a’ PDF agad mu thràth, cuir seachad
uploadOptions: { pdfFieldsImport: true }anns an mutationcreateTemplategus an toirt a-steach mar raointean teamplaid gu fèin-ghluasadach.
An Ath Cheum
A-nis gu bheil teamplaid agad le PDF, faodaidh tu:
- Cuir ris raointean soidhnidh - Cleachd an mutation
createTemplateElementgus raointean a chur ris - Cruthaich dreuchdan - Mìnich cò a bhios a’ soidhnigeadh an sgrìobhainn
- Cuir a-steach airson soidhnigeadh - Cleachd an mutation
sendgus a chuir gu luchd-faighinn
Cùisean Cumanta agus Fuasglaidhean
Mearachd "Chan eil cead"
Dèan cinnteach gu bheil do ID buidhne ceart agus gu bheil thu air a dhearbhadh leis an cunntas ceart.
Mearachd "Faidhle ro mhòr"
Buar am PDF agad — ‘s e 50MB an t-ìre as àirde.
URL Luchdaich Suas air a thoirmeasg
Cleachd an uploadUrl a chaidh a thoirt air ais bhon createTemplate gu luath. Ma thoirmeas e mus luchdaich thu suas, iarr URL ùr leis an cheist upload a’ cleachdadh an ID teamplaid a chaidh a shàbhaladh.
Mearachd "PDF neo-dhlegeth"
Fosgail am PDF ann an leughadair PDF gus dèanamh cinnteach gu bheil e dligheach, an uairsin ath-export no ath-shàbhaladh e.