THotPDF.OptimizeLoadedStreams メソッド

置換が要求されたしきい値だけ小さい場合にのみ、選択された読み込み済みストリームファミリーを Flate として再書き込みします

宣言

function OptimizeLoadedStreams(
  FilterFamilies: THPDFLoadedStreamFilterFamilies;
  MinimumSavingsBytes: Int64;
  out AInfo: THPDFLoadedStreamOptimizationInfo): Integer;

ユニット

HPDFDoc

パラメータ

名前目的
FilterFamilies無フィルタ・Flate・LZW・ASCII85・ASCIIHex・RunLength の候補を選択します
MinimumSavingsBytes候補がソースストリームを置き換える前に必要な、正の最小バイト削減量
RecompressionMode標準のシングルパス経路、または高圧縮率の zlib + Zopfli 選定経路を選択します
AInfoストリームの合計値に加えて、zlib のトライアルと Zopfli の試行・完了・選択・予算・バイト削減量・経過時間のテレメトリを受け取ります

戻り値

読み込まれたオブジェクトグラフで置き換えられたストリームペイロードの数を返します

使用上の注意

型と診断

THPDFLoadedStreamFilterFamily = (lsffUnfiltered, lsffFlate, lsffLZW,
  lsffASCII85, lsffASCIIHex, lsffRunLength);
THPDFLoadedStreamFilterFamilies = set of THPDFLoadedStreamFilterFamily;

THPDFLoadedStreamOptimizationInfo = record
  ScannedStreamCount: Integer;
  CandidateStreamCount: Integer;
  RewrittenStreamCount: Integer;
  UnsupportedStreamCount: Integer;
  DecodeFailureCount: Integer;
  BytesBefore: Int64;
  BytesAfter: Int64;
  BytesSaved: Int64;
  FilterStatistics: THPDFLoadedStreamFilterStatistics;
  RecompressionMode: THPDFFlateRecompressionMode;
  CompressionTrialCount: Integer;
  ZopfliAttemptCount: Integer;
  ZopfliCompletedCount: Integer;
  ZopfliSelectedCount: Integer;
  ZopfliBudgetExceededCount: Integer;
  ZopfliInputBytes: Int64;
  ZopfliBytesSavedOverBaseline: Int64;
  ZopfliElapsedMilliseconds: Int64;
end;

FilterStatistics は、最適化前のストリーム数・エンコード済みバイト数・ファミリーごとのステージ帰属を、追加のデコードパスを強制せずに記録します

例

Families := [lsffUnfiltered, lsffFlate, lsffLZW];
Count := PDF.OptimizeLoadedStreams(Families, 16, Info);
if Count > 0 then
  PDF.SaveLoadedDocument('optimized.pdf');

関連 API