Mbandhingake Word file utawa PDF nggunakake Go SDK

Pustaka Go sing kuat kanggo mbandhingake file ing PDF, Word, HTML, TXT, MD lan format liyane

Gunakake pamriksa prabédan Go file, mbandhingake rong dokumen lan deleng prabédan ing antarane dokumen kasebut kanthi jelas ing output. Sampeyan ora perlu maneh mbandhingake dokumen kanthi manual. Elinga uga yen asil perbandingan bisa diekspor menyang DOCX, PDF, DOC lan liya-liyane.

Ndeleng potongan kode

Mbandhingake rong file ing Go

Solusi Go kita dirancang kanggo menehi asil sing paling apik nalika nggunakake algoritma perbandingan sing rumit. Dadi, sampeyan ora perlu maneh kanthi manual nggoleki beda ing dokumen - bebas nggunakake API kita kanggo mbedakake rong file.

Mesin perbandingan kita nggoleki bedane ing tingkat karakter utawa kabeh tembung. Lan yen mung siji karakter diganti, kabeh tembung bakal disorot minangka diganti. Kabeh owah-owahan sing ditemokake bisa dideleng kanthi jelas ing output lan diekspor ing format sing trep.

Jinis perbandingan sing paling populer yaiku mbandhingake PDF file lan Word. Mula, kita bakal sinau alat diff Go lan fungsi perbandingan nggunakake conto kasebut.

Bandhingake PDF ing Go

Kadhangkala sampeyan kudu nggawe manawa PDF dokumen sampeyan durung diowahi lan mbandhingake karo versi asli. Utawa sampeyan wis ngerti yen PDF sampeyan pancene wis diganti, lan sampeyan kudu nggoleki ngendi lan carane. Banjur sampeyan bisa mbandhingake rong versi PDF file lan ndeleng bedane. Lan supaya ora nindakake kanthi manual, gunakake Go diff checker API.

Kanthi solusi Go, sampeyan bakal bisa ndeleng owah-owahan cilik sing bisa gampang kantun ing perbandingan manual.

Bandhingake rong Word dokumen nggunakake Go

Dokumen Word cukup gampang diganti, mula penting kanggo mbandhingake Word file kanggo mesthekake bagean utawa kabeh dokumen ora diganti.

Kanggo mbandhingake Word file, gunakake solusi Go, kaya PDF. Sampeyan bisa nindakake iki ing conto ing ngisor iki.

Bandhingake rong dokumen

Kanggo ndeleng kepiye cara mbandhingake dokumen Go, muat rong file sing pengin dibandhingake lan pilih format file ekspor.

Sawise mbandhingake rampung, dokumen kanthi diff bakal diundhuh kanthi otomatis ing format sing sampeyan pilih.

Penting yen dokumen sing dibandhingake kudu ora ana revisi sadurunge mbandhingake, mula kita kudu nampa kabeh revisi sadurunge mbandhingake diwiwiti. Aja kuwatir, kita wis ngurus ing conto kita:

Unggah file sing dibandhingake
Kode roto
Unggah file kapindho kanggo mbandhingake
Pilih format target saka dhaptar
import (
    "os"
    "github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)

config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)

fileName1:= "Input1.docx"
fileName2:= "Input2.docx"
fileResult:= "Output.docx"

//  Upload dokumen menyang panyimpenan maya.
firstDocumentContent, _ := os.Open(fileName1)
uploadFirstFileRequestOptions := map[string]interface{}{}
uploadFirstFileRequest := &models.UploadFileRequest{
    FileContent: firstDocumentContent,
    Path: ToStringPointer(fileName1),
    Optionals: uploadFirstFileRequestOptions,
}
_, _, _ = wordsApi.UploadFile(ctx, uploadFirstFileRequest)

secondDocumentContent, _ := os.Open(fileName2)
uploadSecondFileRequestOptions := map[string]interface{}{}
uploadSecondFileRequest := &models.UploadFileRequest{
    FileContent: secondDocumentContent,
    Path: ToStringPointer(fileName2),
    Optionals: uploadSecondFileRequestOptions,
}
_, _, _ = wordsApi.UploadFile(ctx, uploadSecondFileRequest)

//  Mbandhingake dokumen ing awan.
compareDataOptions := models.CompareData{
    Author: ToStringPointer("author"),
    FileReference: models.CreateRemoteFileReference(fileName2),
}
compareDocumentRequestOptions := map[string]interface{}{"destFileName": fileResult,}
compareDocumentRequest := &models.CompareDocumentRequest{
    Name: ToStringPointer(fileName1),
    CompareData: &compareDataOptions,
    Optionals: compareDocumentRequestOptions,
}
_, _, _ = wordsApi.CompareDocument(ctx, compareDocumentRequest)

//  Download dokumen asil saka panyimpenan maya.
downloadFileRequestOptions := map[string]interface{}{}
downloadFileRequest := &models.DownloadFileRequest{
    Path: ToStringPointer(fileResult),
    Optionals: downloadFileRequestOptions,
}
_, _ = wordsApi.DownloadFile(ctx, downloadFileRequest)
Kode roto
  
Nyalin kode Go menyang clipboard

Cara Mbandhingake rong versi file

  1. Pasang Aspose.Words Cloud for Go
  2. Tambah referensi perpustakaan (ngimpor perpustakaan) menyang proyek Go sampeyan
  3. Muat rong dokumen kanggo mbandhingake
  4. Nelpon metode CompareDocument() kanggo mbandhingake rong dokumen
  5. Download dokumen asil saka panyimpenan maya

Go perpustakaan kanggo nggunakake mbandhingake

Run go get -v github.com/aspose-words-cloud/aspose-words-cloud-go/2007/api kanggo nginstal Aspose.Words Cloud SDK for Go. Sampeyan bisa entuk akeh informasi migunani babagan cara instalasi liyane saka bagean "How to use SDK".

Klone Aspose.Words Cloud SDK for Go saka GitHub lan gunakake ing proyek sampeyan. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.

Requirements Sistem

Deleng Repository Documentation kanggo ndeleng rincian.

Format paling populer kanggo mbandhingake operasi

5%

Langganan kanggo Aspose Update Product

Entuk buletin saben wulan lan tawaran langsung dikirim menyang kothak layang.

© Aspose Pty Ltd 2001-2024. Kabeh hak dilindhungi undhang-undhang.