文書を固定ページ形式で保存する
Contents
[
Hide
]
ページレイアウトが作成され、オブジェクトのジオメトリとページ上の位置が計算された後、文書はAspose.Wordsでサポートされている固定ページ形式で保存できます。
文書を固定ページ形式で保存する場合は、これらすべての形式に共通のレンダリングオプションを使用できます。 彼らは制御することができます:
- 出力ドキュメントに含まれるページの数と範囲(PageIndex, PageCount).
- ページごとの文書保存の進行状況(PageSavingCallback)。
- 数値のレンダリングに使用される文字のセット(NumeralFormat)。
- メタファイルプレーヤー(MetafileRenderingOptions)。 詳細については、以下を参照してください。 Windowsメタファイルの処理 記事。
- 選択した保存形式(JpegQuality)に応じて、JPEG画像を再圧縮するための品質レートの値が若干異なる場合があります。
- Aspose.Words出力(OptimizeOutput)におけるベクターグラフィックスの最適化。
- Tiff、Png、Bmp、Jpeg、Emf形式に保存するときのグラフィックオプション(UseAntiAliasing, UseHighQualityRendering).
- ドキュメントをグレースケール(ColorMode)で保存します。
- DrawingML図形とフォールバック図形のレンダリングを切り替える(DmlRenderingMode)。
- DMLエフェクトレンダリングモードの切り替え(DmlEffectsRenderingMode)。
次の例は、Save
メソッドとレンダリングオプションを使用してドキュメントをJPEG形式に保存する方法を示しています:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
// Open the document. | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"Rendering.doc"); | |
// Save as a JPEG image file with default options | |
System::String outputPathDefault = outputDataDir + u"Rendering.JpegDefaultOptions.jpg"; | |
doc->Save(outputPathDefault); | |
// Save document to stream as a JPEG with default options | |
System::SharedPtr<MemoryStream> docStream = new MemoryStream(); | |
doc->Save(docStream, SaveFormat::Jpeg); | |
// Rewind the stream position back to the beginning, ready for use | |
docStream->Seek(0, SeekOrigin::Begin); | |
// Save document to a JPEG image with specified options. | |
// Render the third page only and set the JPEG quality to 80% | |
// In this case we need to pass the desired SaveFormat to the ImageSaveOptions constructor | |
// to signal what type of image to save as. | |
System::SharedPtr<ImageSaveOptions> options = System::MakeObject<ImageSaveOptions>(SaveFormat::Tiff); | |
auto pageRange = System::MakeObject<PageRange>(0, 1); | |
options->set_PageSet(System::MakeObject<PageSet>(System::MakeArray<System::SharedPtr<PageRange>>({ pageRange }))); | |
options->set_JpegQuality(80); | |
System::String outputPath = outputDataDir + u"Rendering.JpegCustomOptions.jpg"; | |
doc->Save(outputPath, options); |