Mbandhingake Word file utawa PDF nggunakake C++ SDK

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

Gunakake pamriksa prabédan C++ 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 C++

Solusi C++ 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 C++ lan fungsi perbandingan nggunakake conto kasebut.

Bandhingake PDF ing C++

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 C++ diff checker API.

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

Bandhingake rong Word dokumen nggunakake C++

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 C++, kaya PDF. Sampeyan bisa nindakake iki ing conto ing ngisor iki.

Bandhingake rong dokumen

Kanggo ndeleng kepiye cara mbandhingake dokumen C++, 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
using namespace aspose::words::cloud;

auto config =
    std::make_shared<ApiConfiguration>(L"####-####-####-####-####", L"##################");
auto wordsApi = std::make_shared<WordsApi>(config);

std::wstring fileName1 = L"Input1.docx";
std::wstring fileName2 = L"Input2.docx";
std::wstring fileResult = L"Output.docx";

//  Upload dokumen menyang panyimpenan maya.
auto firstDocumentContent =
    std::shared_ptr<std::istream>(
	new std::ifstream(std::filesystem::path(fileName1), std::istream::binary));
std::shared_ptr<requests::UploadFileRequest> uploadFirstFileRequest(
    new requests::UploadFileRequest(
        firstDocumentContent, std::make_shared<std::wstring>(fileName1)
    )
);
wordsApi->uploadFile(uploadFirstFileRequest);

auto secondDocumentContent =
    std::shared_ptr<std::istream>(
	new std::ifstream(std::filesystem::path(fileName2), std::istream::binary));
std::shared_ptr<requests::UploadFileRequest> uploadSecondFileRequest(
    new requests::UploadFileRequest(
        secondDocumentContent, std::make_shared<std::wstring>(fileName2)
    )
);
wordsApi->uploadFile(uploadSecondFileRequest);

//  Mbandhingake dokumen ing awan.
auto compareDataOptions = std::make_shared<aspose::words::cloud::models::CompareData>();
compareDataOptions->setAuthor(std::make_shared<std::wstring>(L"author"));
compareDataOptions->setFileReference(
   std::make_shared<aspose::words::cloud::models::FileReference>(
      std::make_shared<std::wstring>(fileName2));
std::shared_ptr<requests::CompareDocumentRequest> compareDocumentRequest(
    new requests::CompareDocumentRequest(
        std::make_shared<std::wstring>(fileName1),
		compareDataOptions, std::make_shared<std::wstring>(fileResult)
    )
);
wordsApi->compareDocument(compareDocumentRequest);

//  Download dokumen asil saka panyimpenan maya.
std::shared_ptr<requests::DownloadFileRequest> downloadFileRequest(
    new requests::DownloadFileRequest(
        std::make_shared<std::wstring>(fileResult)
    )
);
auto downloadFileResult = wordsApi->downloadFile(downloadFileRequest);
{
    char buffer[1024];
    std::ofstream fileWriter(fileResult, std::ofstream::binary);
    const auto& fileData = *downloadFileResult->begin();
    while(fileData.second->read(buffer, sizeof(buffer))) {
        fileWriter.write(buffer, sizeof(buffer));
    }
    fileWriter.write(buffer, fileData.second->gcount());
    fileWriter.close();
}
Kode roto
  
Nyalin kode C++ menyang clipboard

Cara Mbandhingake rong versi file

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

C++ perpustakaan kanggo nggunakake mbandhingake

Klone Aspose.Words Cloud SDK for C++ kode sumber saka GitHub. Sampeyan bisa nemokake informasi rinci babagan mbangun lan ngonfigurasi SDK ing bagean "How to use the SDK".

Kanggo entuk kredensial keamanan sing dibutuhake lan ngakses REST API kanthi cepet, tindakake Instructions iki ing dokumentasi.

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.