THotPDF.DecodeBudgetBytes Property

Đặt số byte tổng hợp tối đa được chấp nhận từ tất cả các giai đoạn giải mã trong một chuỗi filter luồng PDF

Các khai báo

// Delphi
	property DecodeBudgetBytes: Int64;
	function GetLastDecodeBudgetInfo(
	  out AInfo: THPDFDecodeBudgetInfo): Boolean;

// C++Builder
__property __int64 DecodeBudgetBytes;
bool __fastcall GetLastDecodeBudgetInfo(
  THPDFDecodeBudgetInfo &AInfo);

Mặc định

268435456 byte, hoặc 256 MiB

Kế toán tổng hợp

Mỗi filter chung ghi qua một luồng có giới hạn trước khi dữ liệu đến luồng bộ nhớ hỗ trợ của nó

Chẩn đoán

GetLastDecodeBudgetInfo trả về giới hạn chuỗi mới nhất, byte đã giải mã được chấp nhận, giai đoạn lớn nhất, số filter, trạng thái giới hạn, và filter đã vượt giới hạn

THPDFDecodeBudgetInfo = record
  LimitBytes: Int64;
  DecodedBytes: Int64;
  PeakStageBytes: Int64;
  FilterCount: Integer;
  Exceeded: Boolean;
  ExceededFilter: AnsiString;
end;

Phương thức trả về False cho đến khi ít nhất một filter đã được giải mã bởi instance tài liệu

Hành vi khi thất bại

Giải mã cấp thấp raise EHPDFDecodeBudgetError khi một giai đoạn vượt ngân sách tổng hợp; các phương thức đọc cấp cao đã báo cáo thất bại qua False hoặc nil bảo toàn hợp đồng đó trong khi GetLastDecodeBudgetInfo tiết lộ lý do

Chỉ đặt DecodeBudgetBytes thành zero cho đầu vào đáng tin yêu cầu phần mở rộng theo chuỗi không giới hạn; các giá trị âm raise ERangeError

Ví dụ Delphi

PDF.DecodeBudgetBytes := 64 * 1024 * 1024;
if not PDF.ExtractEmbeddedFileBytes('payload.bin', Bytes) then
  if PDF.GetLastDecodeBudgetInfo(Info) and Info.Exceeded then
    Writeln('Decode limit reached in ', Info.ExceededFilter);

Ví dụ C++Builder

pdf->DecodeBudgetBytes = 64LL * 1024 * 1024;
if (!pdf->ExtractEmbeddedFileBytes("payload.bin", bytes)) {
    THPDFDecodeBudgetInfo info;
    if (pdf->GetLastDecodeBudgetInfo(info) && info.Exceeded)
        ShowMessage("Decode limit reached in " + info.ExceededFilter);
}

API liên quan