THotPDF.OptimizeLoadedStreams Method
Ghi lại các họ luồng đã nạp đã chọn thành Flate chỉ khi phần thay thế nhỏ hơn theo ngưỡng được yêu cầu
Khai báo
function OptimizeLoadedStreams(
FilterFamilies: THPDFLoadedStreamFilterFamilies;
MinimumSavingsBytes: Int64;
out AInfo: THPDFLoadedStreamOptimizationInfo): Integer; overload;
function OptimizeLoadedStreams(
FilterFamilies: THPDFLoadedStreamFilterFamilies;
MinimumSavingsBytes: Int64;
RecompressionMode: THPDFFlateRecompressionMode;
out AInfo: THPDFLoadedStreamOptimizationInfo): Integer; overload;
Unit
HPDFDoc
Tham số
| Tên | Mục đích |
|---|---|
FilterFamilies | Chọn các ứng viên unfiltered, Flate, LZW, ASCII85, ASCIIHex, và RunLength |
MinimumSavingsBytes | Số byte giảm tối thiểu dương yêu cầu trước khi một ứng viên thay thế luồng nguồn của nó |
RecompressionMode | Chọn đường dẫn single-pass chuẩn hoặc lựa chọn Flate high-ratio tất định bốn chiến lược |
AInfo | Nhận các tổng byte scanned, candidate, rewritten, unsupported, failed, before, after, và saved |
Giá trị trả về
Trả về số payload luồng đã được thay thế trong object graph đã nạp
Ghi chú sử dụng
CompressionLevelchọn tốc độ và tỷ lệ zlib, trong khiclNonelàm cho lần chạy thành no-opfrmHighRatiothử các chiến lược nén tối đa default, filtered, run-length, và Huffman-only và giữ lại luồng tương thích chuẩn nhỏ nhất- Các ứng viên đã giải mã và đã nén tràn sang các tệp tạm do sở hữu sau
LoadedStreamMemoryThreshold, giữ cho bộ nhớ tài liệu lớn có giới hạn - Payload và từ điển gốc vẫn không thay đổi sau khi giải mã thất bại hoặc tiết kiệm không đủ
- Các luồng có
/DecodeParmsbị bỏ qua để semantics predictor và LZW không-mặc-định không thể bị thay đổi vô tình - Các chuỗi multi-filter đủ điều kiện chỉ khi mọi họ được chọn và được hỗ trợ
- Gọi
SaveLoadedDocumentsau lần chạy để lưu các payload đã áp dụng
Kiểu và chẩn đoán
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;
end;
FilterStatistics ghi lại số luồng tiền-tối-ưu-hóa, byte đã mã hóa, và attribution giai đoạn theo-họ mà không ép buộc một lần giải mã bổ sung
Ví dụ
Families := [lsffUnfiltered, lsffFlate, lsffLZW];
Count := PDF.OptimizeLoadedStreams(Families, 16, frmHighRatio, Info);
if Count > 0 then
PDF.SaveLoadedDocument('optimized.pdf');