Bayyana Takardun Kalma

Ƙara Comments zuwa Takardun Kalma ta amfani da C# .NET

Bayanin daftarin aiki muhimmin bangare ne na haɗin gwiwa da sadarwa a masana’antu da yawa. Yana ba masu amfani damar ba da ra’ayi, shawarwari, da sharhi kan takaddun da za a iya rabawa cikin sauƙi tare da wasu. Ko da yake, Microsoft Word yana ba da kayan aikin tantancewa da yawa, kamar sharhi, canje-canjen waƙa, da ƙara bayanin kula, don taimakawa masu amfani su ba da ra’ayi da haɗin kai akan takarda. Koyaya, a cikin wannan gidan yanar gizon, zamu bincika yadda ake bayanin Takardun Kalma ta amfani da NET Cloud SDK, yana sauƙaƙa ga masu amfani don sadarwa da hada kai akan takardu.

API ɗin REST don Ƙara Kalaman Kalma

Yin amfani da Aspose.Words Cloud SDK don .NET, zaka iya ƙara sharhi, amsoshi, da bayanai cikin sauƙi zuwa takaddar Kalma ta hanyar yin amfani da harshen C#. SDK yana ba da cikakkiyar saiti na APIs na REST don sarrafa daftarin aiki na Kalma kuma yana goyan bayan duk manyan tsarin daftarin aiki, gami da DOC, DOCX, [RTF] ://docs.fileformat.com/word-processing/rtf/), da ƙari. Yanzu tare da taimakon wannan SDK, zaku iya haɓaka aikinku da tsarin haɗin gwiwa ta sauƙaƙe da ingantaccen ƙara bayanai, sharhi, da sauran abubuwan bita a cikin takaddun Kalma.

Domin amfani da SDK, bincika ‘Aspose.Words-Cloud’ a cikin manajan fakitin NuGet kuma danna maɓallin Ƙara Kunshin don ƙara bayanin SDK a cikin aikin NET.

Lura: don samun dama ga REST API, kuna buƙatar yin rajista da samun takaddun shaidar ku. Da fatan za a duba jagorar Quick Start don bayani mai alaƙa.

Ƙara Bayanin Takardun Kalma ta amfani da C#

Da fatan za a gwada amfani da snippet na lamba mai zuwa don ƙara Bayanin daftarin aiki ta amfani da NET Cloud SDK.

// Don cikakkun misalai da fayilolin bayanai, da fatan za a je zuwa 
https://github.com/aspose-words-cloud/aspose-words-cloud-dotnet

// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "7f098199230fc5f2175d494d48f2077c";
string clientID = "ee170169-ca49-49a4-87b7-0e2ff815ea6e";

// ƙirƙiri abin daidaitawa ta amfani da ClinetID da bayanan Sirrin Abokin ciniki
var config = new Aspose.Words.Cloud.Sdk.Configuration { ClientId = clientID, ClientSecret = clientSecret };
// fara misali WordsApi
var wordsApi = new WordsApi(config);

string firstDocument = "input-sample-1.docx";
// karanta abun ciki na farkon daftarin aiki Kalma daga tuƙi na gida
var firstFile = System.IO.File.OpenRead(firstDocument);
try
{
    var requestCommentRangeStartNode = new NodeLink()
    {
        NodeId = "0.6.5.3"
    };
    var requestCommentRangeStart = new DocumentPosition()
    {
        Node = requestCommentRangeStartNode,
        Offset = 0
    };
    var requestCommentRangeEndNode = new NodeLink()
    {
        NodeId = "0.6.5.3"
    };
    var requestCommentRangeEnd = new DocumentPosition()
    {
        Node = requestCommentRangeEndNode,
        Offset = 0
    };
    var requestComment = new CommentInsert()
    {
        RangeStart = requestCommentRangeStart,
        RangeEnd = requestCommentRangeEnd,
        Initial = "NS",
        Author = "Nayyer Shahbaz",
        Text = "Second Revisions..."
    };

    var insertRequest = new InsertCommentOnlineRequest(firstFile, requestComment, destFileName: "Commented.docx");
    var response = wordsApi.InsertCommentOnline(insertRequest);
    
    if (response != null && response.Equals("OK"))
    {
        Console.WriteLine("Word Document Annotation added successfully!");
    }
}
catch(Exception ex)
{
    // kowane Keɓancewar tsarin bayanin Takardu a cikin lokaci
    Console.Write(ex);
}
samfotin bayanin daftarin kalma

Hoto:- Samfoti na bayanin rubutun Kalma ta amfani da REST API.

// create configuration object using ClientID and Client Secret details
var config = new Configuration { ClientId = clientID, ClientSecret = clientSecret };
// initialize WordsApi instance
var wordsApi = new WordsApi(config);

Ƙirƙiri wani abu na WordsApi yayin amfani da keɓaɓɓen bayanan abokin ciniki.

var firstFile = System.IO.File.OpenRead(firstDocument);

Karanta abun ciki na shigar da daftarin aiki Word daga faifan gida.

var requestCommentRangeStartNode = new NodeLink()
{
    NodeId = "0.6.5.3"
};

Ƙirƙiri wani abu na NodeLink yana ma’anar NodeId don Annotation. Maimaita wannan tsari don maganganun CommentRangeStartNode da SharhiRangeEndNode.

var requestComment = new CommentInsert()
{
    RangeStart = requestCommentRangeStart,
    RangeEnd = requestCommentRangeEnd,
    Initial = "NS",
    Author = "Nayyer Shahbaz",
    Text = "Second Revisions..."
};

Ƙirƙiri misali na SharhiInsert inda muka ƙididdige cikakkun bayanai kamar baƙaƙe, sunan Mawallafi da, abun ciki na sharhi/ annotation.

var insertRequest = new InsertCommentOnlineRequest(firstFile, requestComment, destFileName: "Commented.docx");

Yanzu ƙirƙiri wani abu na InsertCommentOnlineRequest inda muka wuce abun ciki na shigar da takaddar Kalma, SharhiInsert abu da sunan sakamakon daftarin Kalma.

 var response = wordsApi.InsertCommentOnline(insertRequest);

A ƙarshe, kira hanyar InsertCommentOnline(…) don saka sharhi a cikin takaddar Kalma a ƙayyadadden kumburi.

Fayilolin samfurin da aka yi amfani da su a cikin misalin da ke sama za a iya sauke su daga input-sample-1.docx da Commented.docx.

Ƙara Sharhi zuwa Takardun Kalma ta amfani da Umarnin CURL

Mun fahimci cewa ƙara bayani ko sharhi zuwa takaddun Kalma ta amfani da umarnin cURL na iya zama da fa’ida sosai, saboda yana ba da hanyar shirye-shirye don ƙara bayanai a cikin girma ko ba ku damar haɗa ayyukan cikin ayyukan da kuke ciki. Tare da taimakon Aspose.Words Cloud API da umarnin cURL, ƙara sharhi zuwa daftarin aiki za a iya cika ta hanyar jerin kiran API. Wannan ya ƙunshi aika buƙatun zuwa Aspose.Words Cloud API tare da sigogi masu dacewa, kamar fayil ɗin takarda, wuri, rubutu, da bayanan marubuci, don ƙirƙirar sharhi.

Mataki na farko shine samun ‘accessToken’ ta hanyar aika buƙatun POST tare da bayanan SID na App da Maɓallin App. Da fatan za a aiwatar da umarni mai zuwa:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=ee170169-ca49-49a4-87b7-0e2ff815ea6e&client_secret=7f098199230fc5f2175d494d48f2077c" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Da zarar mun sami damar shiga Token, da fatan za a aiwatar da umarni mai zuwa don shigar da annotation zuwa takaddar Kalma.

curl -v "https://api.aspose.cloud/v4.0/words/{inputWordFile}/comments?destFileName={resultantFile}&revisionAuthor=Nayyer%20Shahbaz" \
-X POST \
-H  "accept: application/json" \
-H  "Authorization: Bearer {accessToken}" \
-H  "Content-Type: application/json" \
-d "{  \"RangeStart\": {    \"Node\": {      \"link\": {        \"Href\":\"http://api.aspose.cloud/v4.0/words/input-sample-1.docx/sections/0/body/paragraphs/5/runs/2\",        \"Rel\": \"self\"      },      \"NodeId\": \"0.6.5.3\",\"Text\": \"dictum\",    },    \"Offset\": 0  },  \"RangeEnd\": {    \"Node\": {      \"link\": {        \"Href\": \"http://api.aspose.cloud/v4.0/words/input-sample-1.docx/sections/0/body/paragraphs/5/runs/2\",        \"Rel\": \"self\",      },      \"NodeId\": \"0.6.5.3\",\"Text\": \"dictum\",    },    \"Offset\": 0  },  \"Author\": \"Nayyer Shahbaz\",  \"Initial\": \"NS\",  \"DateTime\": \"2023-04-28T12:52:50.108Z\",  \"Text\": \"Second Revisions ....\"}"

Sauya {inputWordFile} tare da sunan shigar da daftarin aiki Kalma (wanda akwai shi a cikin ma’ajiyar gajimare), {accessToken} tare da alamar samun damar JWT da aka samar a sama da {resultantFile} tare da sunan sakamakon daftarin aiki na Kalma mai ɗauke da sabon Annotation .

Kammalawa

A ƙarshe, ƙara bayanai da sharhi zuwa takaddun Word na iya zama fasali mai amfani don gyara haɗin gwiwa da bita. Tare da taimakon Aspose.Words Cloud da umarnin cURL ko Aspose.Words Cloud SDK don NET, ana iya cika wannan aikin da kyau da inganci. Ko kun fi son yin amfani da bayani na tushen girgije ko SDK, Aspose.Words yana ba da kayan aiki mai ƙarfi da aminci don bayyana takaddun Kalma. Muna fatan wannan koyawa ya taimaka wajen jagorantar ku ta hanyar aiwatarwa kuma ya samar muku da duk mahimman bayanai don farawa.

Hanyoyin haɗi masu amfani

Labarai masu alaka

Muna ba da shawarar yin amfani da shafukan yanar gizo masu zuwa: