Comhad a Uaslódáil mar Theimpléad
Treoir seo a threoróidh tú tríd an bpróiseas iomlán chun teimpléad a chruthú agus PDF, íomhá, nó comhad Word a uaslódáil mar do theimpléad doiciméid i Legalesign.
Cad a Mhúinfidh Tú
Ag deireadh na treorach seo, beidh a fhios agat conas:
- Teimpléad nua a chruthú i do ghrúpa Legalesign
- Faigh an t-aitheantas teimpléid agus URL uaslódála ón bhfreagra athraithe
- Uaslódáil do chomhad foinse chuig an teimpléad
- Fíoraigh gur rabhthas rathúil san uaslódáil
Riachtanais
Sula dtosaíonn tú, déan cinnte go bhfuil:
- Cuntas Legalesign le rochtain API agat
- Do chreidiúnais fíordheimhnithe (féach ar ár treoir fíordheimhnithe)
- PDF, íomhá, nó comhad Word ullmhaithe le uaslódáil (uasmhéid 50MB)
- Aitheantas do ghrúpa (an spás oibre ina dteastaíonn uait an teimpléad a chruthú)
An Próiseas Iomlán
Céim 1: Cruthaigh Teimpléad
Ar dtús, cruthaigh teimpléad folamh i Legalesign. Cuireann sé seo ar ais an dá aitheantas teimpléid agus URL uaslódála réamhshíniú don uaslódáil PDF. Chun é seo a dhéanamh, beidh ort athrú GraphQL a rith, má tá tú nua dó seo féach an Réamhrá do GraphQL.
Cad is Teimpléad ann?
Is struchtúr doiciméad inathúsáidte é teimpléad i Legalesign. Nuair a uaslódálann tú PDF chuig teimpléad, is féidir leat:
- Réimsí sínithe agus réimsí foirme a chur leis
- É a sheoladh chuig roinnt faighteoirí
- É a athúsáid do shíntóirí éagsúla
Athrú GraphQL
mutation CreateTemplate($input: templateCreateInput!) {
createTemplate(input: $input) {
id
uploadUrl
}
}
Athróga Ionchuir
{
"input": {
"groupId": "grpYourGroupAPIId",
"title": "Employment Contract Template"
}
}
Míniú ar Paraiméadair
- groupId: Aitheantas bonn 64 do do ghrúpa/spás oibre (is féidir leat é seo a fháil ón URL i Console https://console.legalesign.com/)
- title: Ainm tuairisciúil do do theimpléad (is féidir leat é seo a athrú níos déanaí)
- uploadOptions (iachtanach): Roghanna próiseála a chuirear i bhfeidhm nuair a uaslódáiltear an PDF:
pdfFieldsImport: true— allmhaireachaigh réimsí foirme PDF fite sa teimpléad mar réimsí teimpléidprocessTags: true— próiseáil lipéid téacs Legalesign sa doiciméad ar uaslódáil
Céim 2: Bain an Aitheantas Teimpléid agus URL Uaslódála
Tugann an t-athrú ar ais réad templateCreateOutput. Sábháil an réimse id agus an sreangán uploadUrl.
Freagra samplach:
{
"data": {
"createTemplate": {
"id": "dHBsYjQ5YTg5NWQtYWRhMy0xMWYwLWIxZGMtMDY5NzZlZmU0MzIx",
"uploadUrl": "https://s3.amazonaws.com/bucket/path?signature=..."
}
}
}
Is sreangán códaithe Base64 é an t-aitheantas teimpléid. Sábháil an dá luach ón bhfreagra. Tá an uploadUrl gearrbhreise agus ba chóir é a úsáid go pras.
Céim 3: Uaslódáil Do PDF
Úsáid an uploadUrl a cuireadh ar ais chun do chomhad PDF a uaslódáil go díreach chuig S3. Beidh sé seo éagsúil ag brath ar do stac forbartha. I sampla javascript againn, d’úsáid muid fetch ach is féidir leat leabharlanna eile a úsáid lena n-áirítear aws-amplify.
Samplaí Oibre Iomlán
- 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);
});
Níl aon spleáchais bhreise de dhíth — cuimsíonn Node.js 18+ fetch go dúchasach.
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}");
}
}
Cad a Tharlaíonn Tar éis Uaslódáil?
Nuair a uaslódáiltear do PDF, déanann Legalesign go huathoibríoch:
- Scanáil víris - Cinntíonn sé go bhfuil an comhad sábháilte
- Fíorú nó athrú comhad - Seiceálann sé an bhfuil PDFanna bailí, nó athraíonn sé comhaid a thacaítear leo mar doiciméid Word agus íomhánna go PDF
- Eisíonn sonraí leathanaigh - Faigheann sé líon na leathanach agus a btoisí
- Próiseálann an comhad - Optamaíonn sé é le haghaidh féachana agus sínithe
- Stóráil go sábháilte - Bogann sé é chuig stóráil bhunaitheach
De ghnáth tógann an próiseas seo cúpla soicind. Nuair a bhíonn sé críochnaithe, tá do theimpléad réidh le húsáid!
Rianú Dul Chun Cinn Uaslódála
Chun aiseolas fíor-ama a fháil ar phróiseáil uaslódála (scanáil, fíorú, críochnú), bain úsáid as síntiúis. Féach Rianú Dul Chun Cinn Uaslódála le Síntiúis.
Mar rogha eile, déan polladh ar an réimse fileUploaded den teimpléad go dtí go gcuirtear true ar ais:
query CheckUploadStatus($id: ID!) {
template(id: $id) {
id
fileUploaded
}
}
Ag Cuir Síntí agus Réimsí leis
Má theastaíonn uait rannpháirtithe agus suíomh na réimsí a uathoibriú, is féidir leat an comhad foinse a ullmhú roimh uaslódáil ar chúpla bealach éagsúla:
- Lipéid téacs — Cuir lipéid téacs Legalesign isteach sa doiciméad foinse ionas gur féidir rannpháirtithe, réimsí sínithe, agus réimsí foirme a chruthú go huathoibríoch le linn próiseála. Pasáil
uploadOptions: { processTags: true }san athrúcreateTemplatechun é seo a chumasú. Féach míniú REST API sa tús tapa agus an tagairt don cheann deiridh Athraigh lipéid téacs. - Réimsí PDF fite — Má tá réimsí foirme fite cheana féin i do PDF, pasáil
uploadOptions: { pdfFieldsImport: true }san athrúcreateTemplatechun iad a allmhaireachadh mar réimsí teimpléid go huathoibríoch.
Céimeanna Ina Dhiaidh Sin
Anois go bhfuil teimpléad agat le PDF, is féidir leat:
- Cuir réimsí sínithe leis - Bain úsáid as an athrú
createTemplateElementchun réimsí a chur leis - Cruthaigh róil - Sainmhínigh cé a dhéanfaidh an doiciméad a shíniú
- Seol le haghaidh sínithe - Bain úsáid as an athrú
sendchun é a sheoladh chuig faighteoirí
Fadhbanna Coitianta agus Réitigh
Earráid "Níl cead"
Déan cinnte go bhfuil do aitheantas ghrúpa ceart agus go bhfuil tú fíordheimhnithe leis an gcuntas ceart.
Earráid "Tá an comhad ró-mhór"
Comhdaigh do PDF — 50MB an uasmhéid.
D'éag an URL Uaslódála
Úsáid an uploadUrl a cuireadh ar ais ag createTemplate go pras. Mura bhfuil sé bailí roimh an uaslódáil, iarr URL úr leis an leithcheal upload ag úsáid an aitheantais teimpléid sábháilte.
Earráid "PDF Neamhbhailí"
Oscail an PDF in léitheoir PDF chun a fhíorú go bhfuil sé bailí, ansin onnmhairigh nó sábháil arís é.