現在、DOCX ファイルを入力として受け付けていません。ただし、出力として DOCX ファイルを生成することはできます。近い将来、DOCX が完全にサポートされることを楽しみにしています。
C++ ライブラリはスタンドアロンソリューションであり、サードパーティのソフトウェアをインストールする必要はありません。
品質を損なうことなく DOCX ファイルを小さくします。 C++ ライブラリは、DOCX コンテンツを最適化するための統合APIを開発者に提供します。 DOCX の最適化は、DOCX ファイル内の画像を圧縮することと、未使用のデータを削除することによって行われます。
'Aspose.Words for C++' 使用すると、電子書籍の可逆圧縮とコンテンツの最適化が簡単になります。次の例は、 C++ の DOCX ファイルのコンテンツを最適化する方法を示しています。
dotnet add package Aspose.Words.Cpp
コピー
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())
{
// 画像圧縮用のライブラリを選択するのは開発者次第です。
auto image = System::Drawing::Image::Fromstream(shape->get_ImageData()->ToStream());
// ...
// 画像を圧縮して形状に戻します。
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
doc->Save(u"Output.epub");
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())
{
// 画像圧縮用のライブラリを選択するのは開発者次第です。
auto image =
System::Drawing::Image::FromStream(shape->get_ImageData()->ToStream());
// ...
// 画像を圧縮して形状に戻します。
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->set_CacheBackgroundGraphics(true);
doc->Save(u"Output.epub", 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())
{
// 画像圧縮用のライブラリを選択するのは開発者次第です。
auto image = System::Drawing::Image::Fromstream(shape->get_ImageData()->ToStream());
// ...
// 画像を圧縮して形状に戻します。
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
doc->Save(u"Output.epub");
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())
{
// 画像圧縮用のライブラリを選択するのは開発者次第です。
auto image =
System::Drawing::Image::FromStream(shape->get_ImageData()->ToStream());
// ...
// 画像を圧縮して、形状に戻します。
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_CompressionLevel(CompressionLevel::Maximum);
doc->Save(u"Output.epub", 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.epub", saveOptions);
Aspose.Words for C++ を開発者環境にインストールするための3つのオプションがあります。ニーズに合ったものを選択し、ステップバイステップの手順に従ってください。
このC++ライブラリを使用して、 Microsoft Windows 、Linux、およびmacOSオペレーティングシステムでソフトウェアを開発できます。
LinuxまたはmacOS用のソフトウェアを開発する場合は、製品ドキュメント fontconfig および mesa-glu オープンソースパッケージ)に関する情報を確認してください。