Gunakake pamriksa prabédan Ruby 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.
Solusi Ruby 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 Ruby lan fungsi perbandingan nggunakake conto kasebut.
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 Ruby diff checker API.
Kanthi solusi Ruby, sampeyan bakal bisa ndeleng owah-owahan cilik sing bisa gampang kantun ing perbandingan manual.
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 Ruby, kaya PDF. Sampeyan bisa nindakake iki ing conto ing ngisor iki.
Kanggo ndeleng kepiye cara mbandhingake dokumen Ruby, 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:
require 'aspose_words_cloud'
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = '####-####-####-####-####'
config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new
file_name1= 'Input1.docx'
file_name2= 'Input2.docx'
file_result= 'Output.docx'
# Unggah dokumen menyang panyimpenan maya.
first_document_content = File.open(file_name1)
upload_first_file_request =
UploadFileRequest.new(file_content: first_document_content, path: file_name1)
@words_api.upload_file(upload_first_file_request)
second_document_content = File.open(file_name2)
upload_second_file_request =
UploadFileRequest.new(file_content: second_document_content, path: file_name2)
@words_api.upload_file(upload_second_file_request)
# Bandhingake dokumen ing awan.
compare_data_options =
CompareData.new({:Author => 'author',
:FileReference => AsposeWordsCloud::FileReference.fromRemoteFilePath(file_name2)})
compare_document_request =
CompareDocumentRequest.new(
name: file_name1, compare_data: compare_data_options, dest_file_name: file_result)
@words_api.compare_document(compare_document_request)
# Download dokumen asil saka panyimpenan awan.
download_file_request = DownloadFileRequest.new(path: file_result)
download_file_result = @words_api.download_file(download_file_request)
File.open('compareResult.pdf', 'wb').write(download_file_result)
Instal Aspose.Words Cloud SDK for Ruby nggunakake layanan hosting RubyGems. gem install aspose_words_cloud kanggo nginstal paket kasebut. Minangka alternatif, sampeyan bisa kanthi manual kloning Aspose.Words Cloud SDK for Ruby saka GitHub lan nggunakake ing project. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.
Ruby 2.6 utawa luwih anyar
Deleng Repository Documentation kanggo ndeleng rincian.