Genom att använda REST API i C++ kan utvecklare komprimera dokument i DOC, DOCX, RTF, PDF och andra format. Med den givna lösningen blir utdata en fil av hög kvalitet efter komprimering.
Med hjälp av vårt kraftfulla C++ API kan utvecklare komprimera filer för att optimera innehåll och utdatafilstorlek. Att minska filstorleken sker genom att rensa bort oanvända data och resurser. Du kan också komprimera bilder för att göra utdatafilens storlek ännu mindre.
Resultatet av innehållsoptimering och komprimering kan sparas i det ursprungliga filformatet eller vilket som helst tillgängligt sparaformat – DOCX, DOC, RTF, PDF, HTML och många andra.
Som nämnts låter vår C++ SDK dig att programmatiskt minska storleken på ett dokument i alla format som stöds. Du kan till exempel minska filstorleken för PDF, DOCX, DOC, RTF, ODT, EPUB, HTML och andra format. Och nu kan du prova vår kraftfulla funktionalitet och utvärdera hur du komprimerar ett dokument i C++ med följande exempel:
using namespace aspose::words::cloud;
auto config = std::make_shared<ApiConfiguration>(L"####-####-####-####-####",
L"##################");
auto wordsApi = std::make_shared<WordsApi>(config);
auto requestDocument = std::shared_ptr<std::istream>(
new std::ifstream(std::filesystem::path(L"Input.docx"), std::istream::binary));
auto requestCompressOptions = std::make_shared<aspose::words::cloud::models::CompressOptions>();
requestCompressOptions->setImagesQuality(std::make_shared<int32_t>(75));
requestCompressOptions->setImagesReduceSizeFactor(std::make_shared<int32_t>(1));
std::shared_ptr<requests::CompressDocumentOnlineRequest> compressDocumentRequest(
new requests::CompressDocumentOnlineRequest(
requestDocument, requestCompressOptions
)
);
auto compressDocument = wordsApi->compressDocumentOnline(compressDocumentRequest);
auto requestDocument = std::shared_ptr<std::istream>(
compressDocument->document->values.begin, std::istream::binary));
std::shared_ptr<requests::ConvertDocumentRequest> convertDocument(
new requests::ConvertDocumentRequest(
requestDocument, std::make_shared<std::wstring>(L"docx")
)
);
wordsApi->convertDocument(convertDocument);
Clone Aspose.Words Cloud SDK for C++ källkod från GitHub. Du kan hitta detaljerad information om att bygga och konfigurera SDK:n i avsnittet "How to use the SDK".
För att snabbt få nödvändiga säkerhetsuppgifter och få tillgång till vårt REST API, följ dessa Instructions i dokumentationen.
Se Repository Documentation för att se detaljerna.