Kwatanta Takardun Kalma

Yi Kwatanta Rubutu a cikin Takardun Kalma akan layi

Ayyukan kwatanta fayilolin rubutu ya zama ruwan dare sosai yayin haɗa canje-canje cikin takaddun haɗin kai. Don haka yayin bita da tsarin haɗawa, ana yin aikin kwatanta rubutu kuma galibi muna amfani da kayan aiki don kwatanta rubutu akan layi. Don haka a cikin wannan labarin, za mu tattauna matakai kan yadda ake kwatanta takaddun kalmomi da kwatanta fayilolin rubutu ta amfani da Java SDK.

Kwatanta Rubutu API

Aspose.Words Cloud SDK don Java yana ba da ɗimbin fasalulluka waɗanda ke ba ku damar ƙirƙira, gyara da sarrafa takaddun Kalma a cikin aikace-aikacen Java. Yanzu don amfani da SDK, da fatan za a ƙara cikakkun bayanai masu zuwa zuwa pom.xml na aikin ginin maven.

<repositories>
    <repository>
        <id>AsposeJavaAPI</id>
        <name>Aspose Java API</name>
        <url>https://repository.aspose.cloud/repo/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-words-cloud</artifactId>
        <version>22.5.0</version>
    </dependency>
</dependencies>

Da zarar an shigar da SDK, da fatan za a yi rajistar asusu kyauta akan Aspose.Cloud dashboard ta amfani da GitHub ko asusun Google ko kawai Yi rajista kuma sami Shaidar Abokin Ciniki na ku.

Kwatanta Takardun Kalma a Java

A cikin wannan sashe, za mu tattauna cikakkun bayanai game da yadda ake kwatanta takaddun kalmomi ta amfani da snippets code na Java.

  • Mataki na farko shine ƙirƙirar misali na WordsApi ta amfani da takaddun shaidar abokin ciniki
  • Abu na biyu, loda shigarwar da gyare-gyaren takaddun Kalma zuwa ma’ajin gajimare yayin wuce abin UploadFileRequest don loda fayil(…) hanyar WordsApi
  • Na uku, ƙirƙirar abu CompareData kuma wuce daftarin aiki na biyu azaman hujja zuwa hanyar saitaComparingWithDocument(…)
  • Yanzu ƙirƙiri wani abu na ajin CompareDocumentRequest inda muke shigar da fayil ɗin Kalma, Kwatanta abu, da takaddar kalmar sakamako azaman muhawara.
  • A ƙarshe, kwatanta fayilolin rubutu ta amfani da hanyar compareDocument(…) kuma adana abin fitarwa a cikin ma’ajiyar girgije
For more examples, please visit https://github.com/aspose-words-cloud/aspose-words-cloud-java

try
    {
    // idan baseUrl ba shi da amfani, WordsApi yana amfani da tsoho https://api.aspose.cloud
    WordsApi wordsApi = new WordsApi(clientId, clientSecret, null);

    String firstDocument = "input-sample.docx";
    String secondDocument = "input-sample-updated.docx";
    String resultantFile = "Comparison.docx";

    // karanta farko daftarin aiki na Word daga gida drive
    File file = new File("c://Downloads/"+firstDocument);
    // karanta daftarin kalma na biyu daga faifan gida
    File file2 = new File("c://Downloads/"+secondDocument);

    // ƙirƙirar buƙatar loda fayil
    UploadFileRequest uploadRequest = new UploadFileRequest(Files.readAllBytes(file.toPath()), firstDocument, null);
    // ƙirƙirar buƙatun loda fayil na 2
    UploadFileRequest uploadRequest2 = new UploadFileRequest(Files.readAllBytes(file2.toPath()), secondDocument, null);

    // loda fayil zuwa ma'ajiyar girgije
    wordsApi.uploadFile(uploadRequest);        
    // loda fayil zuwa ma'ajiyar girgije
    wordsApi.uploadFile(uploadRequest2);

    // Ƙirƙiri misali na ajin CompareData
    CompareData compareData = new CompareData();
    
    // sunan da za a yi amfani da shi azaman marubucin gano bambance-bambance
    compareData.setAuthor("Nayyer");
    // saka daftarin aiki kwatanta da
    compareData.setComparingWithDocument(secondDocument);
    compareData.setDateTime(OffsetDateTime.now());
    
    // ƙirƙiri misalin Buƙatun ta hanyar samar da tushe, daftarin aiki don kwatantawa da sunan fayil sakamakon sakamako
    CompareDocumentRequest request = new CompareDocumentRequest(firstDocument, compareData, null, null, null, null, null,resultantFile,null);
    
    // fara kwatanta daftarin aiki
    DocumentResponse result = wordsApi.compareDocument(request);
    
    // buga sakon nasara
    System.out.println("Sucessfull completion of Compare Word Document !");
		
}catch(Exception ex)
{
    System.out.println(ex);
}
Kwatanta samfoti na Takardun Kalma

Preview na Kwatanta aikin Takardun Kalma

Za a iya sauke samfurin fayilolin da aka yi amfani da su a cikin misalin da ke sama daga mahaɗin da ke biyowa

Kwatanta rubutu ta amfani da Umarnin CURL

Hakanan zamu iya samun damar Aspose.Words Cloud ta umarnin cURL da kwatanta fayilolin rubutu. Don haka a matsayin buƙatun farko, da fatan za a aiwatar da umarni mai zuwa don ƙirƙirar alamar samun damar JWT dangane da ID na Abokin ciniki da bayanan Sirrin Abokin ciniki.

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=a41d01ef-dfd5-4e02-ad29-bd85fe41e3e4&client_secret=d87269aade6a46cdc295b711e26809af" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Da zarar mun sami JWT Token, da fatan za a aiwatar da umarni mai zuwa don kwatanta rubutu akan layi kuma adana fayil ɗin sakamako a cikin ma’ajiyar girgije.

curl -v -X PUT "https://api.aspose.cloud/v4.0/words/input-sample.docx/compareDocument?destFileName=Comparison.docx" \
-H  "accept: application/json" \
-H  "Authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{\"ComparingWithDocument\":\"input-sample-updated.docx\",\"Author\":\"Nayyer Shahbaz\",\"DateTime\":\"2022-07-21T07:54:06.768Z\",\"CompareOptions\":{\"IgnoreCaseChanges\":true,\"IgnoreTables\":true,\"IgnoreFields\":true,\"IgnoreFootnotes\":true,\"IgnoreComments\":true,\"IgnoreTextboxes\":true,\"IgnoreFormatting\":true,\"IgnoreHeadersAndFooters\":true,\"Target\":\"Current\",\"AcceptAllRevisionsBeforeComparison\":true},\"ResultDocumentFormat\":\"docx\"}"

Kammalawa

Wannan labarin ya bayyana matakan kwatanta takardu ta amfani da Java da kuma umarnin CURL. Kuna iya la’akari da bincika iyawar API ta hanyar swagger interface. Bugu da ƙari, ana iya sauke cikakken lambar tushen SDK daga GitHub. Idan kuna da ƙarin tambayoyi ko kuna fuskantar kowace matsala, da fatan za a ziyarci [ dandalin tallafi na kyauta 6.

Labarai masu alaka

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