Iki minangka solusi profesional kanggo ngoptimalake lan ngompres DOCX ing C++. Gunakake C++ kanggo maksimalake kacepetan optimasi/komprèsi DOCX. Coba online gratis!
Nggawe file DOCX gedhe luwih cilik tanpa mundhut kualitas. Mbusak data sing ora perlu lan ora digunakake. Nyilikake ukuran file DOCX ing kode. Pustaka C++ nyedhiyakake pangembang API terpadu kanggo ngoptimalake isi DOCX.
Perpustakaan C++ minangka solusi mandiri lan ora mbutuhake piranti lunak pihak katelu sing diinstal.
Kompresi lossless lan optimasi isi jero digawe gampang karo 'Aspose.Words for C++'. Conto ing ngisor iki nuduhake carane ngoptimalake isi file DOCX ing C++:
dotnet add package Aspose.Words.Cpp
Nyalin
using namespace Aspose::Words;
auto doc = MakeObject<Document>(u"Input.docx");
doc->Cleanup();
auto nodes = doc->GetChildNodes(NodeType::Shape, true);
for (const auto& shape : System::IterateOver<Shape>(nodes))
{
if (shape->get_HasImage())
{
// Iku nganti pangembang kanggo milih perpustakaan kanggo komprèsi gambar.
auto image =
System::Drawing::Image::FromStream(shape->get_ImageData()->ToStream());
// ...
// Compress gambar lan nyetel maneh menyang wangun.
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_CompressionLevel(CompressionLevel::Maximum);
doc->Save(u"Output.docx", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>(u"Input.docx");
doc->Cleanup();
auto nodes = doc->GetChildNodes(NodeType::Shape, true);
for (const auto& shape : System::IterateOver<Shape>(nodes))
{
if (shape->get_HasImage())
{
// Iku nganti pangembang kanggo milih perpustakaan kanggo komprèsi gambar.
auto image =
System::Drawing::Image::FromStream(shape->get_ImageData()->ToStream());
// ...
// Compress gambar lan nyetel maneh menyang wangun.
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->set_CacheBackgroundGraphics(true);
doc->Save(u"Output.docx", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>(u"Input.docx");
doc->Cleanup();
auto nodes = doc->GetChildNodes(NodeType::Shape, true);
for (const auto& shape : System::IterateOver<Shape>(nodes))
{
if (shape->get_HasImage())
{
// Terserah pangembang kanggo milih perpustakaan kanggo kompresi gambar.
auto image = System::Drawing::Image::Fromstream(shape->get_ImageData()->ToStream());
// ...
// Kompres gambar lan setel maneh menyang wangun.
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
doc->Save(u"Output.docx");
using namespace Aspose::Words;
auto doc = MakeObject<Document>(u"Input.docx");
doc->Cleanup();
auto nodes = doc->GetChildNodes(NodeType::Shape, true);
for (const auto& shape : System::IterateOver<Shape>(nodes))
{
if (shape->get_HasImage())
{
// Iku nganti pangembang kanggo milih perpustakaan kanggo komprèsi gambar.
auto image =
System::Drawing::Image::FromStream(shape->get_ImageData()->ToStream());
// ...
// Compress gambar lan nyetel maneh menyang wangun.
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_CompressionLevel(CompressionLevel::Maximum);
doc->Save(u"Output.docx", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto shape = builder->InsertImage(u"Input.docx");
auto saveOptions = MakeObject<ImageSaveOptions>(SaveFormat::Docx);
shape->GetShapeRenderer()->Save(u"Output.docx", saveOptions);
Ana telung opsi kanggo nginstal Aspose.Words for C++ kanggo lingkungan pangembang. Pilih salah siji sing cocog karo kabutuhan sampeyan lan tindakake pandhuan langkah demi langkah:
Sampeyan bisa nggunakake perpustakaan C++ iki kanggo nggawe piranti lunak ing Microsoft Windows, Linux lan macOS:
Yen sampeyan nggawe piranti lunak kanggo Linux utawa macOS, priksa informasi babagan katergantungan perpustakaan tambahan (fontconfig lan paket sumber terbuka mesa-glu) ing Dokumentasi Produk.
Sampeyan bisa ngoptimalake file ing akeh format file liyane: