THotPDF.DecodeBudgetBytes Property

Sets the maximum aggregate number of bytes accepted from all decoding stages in one PDF stream filter chain

Declarations

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

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

Default

268435456 bytes, or 256 MiB

Aggregate accounting

Each generic filter writes through a bounded stream before data reaches its backing memory stream

Diagnostics

GetLastDecodeBudgetInfo returns the latest chain limit, accepted decoded bytes, largest stage, filter count, limit status, and the filter that exceeded the limit

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

The method returns False until at least one filter has been decoded by the document instance

Failure behaviour

Low-level decoding raises EHPDFDecodeBudgetError when a stage exceeds the aggregate budget; high-level read methods that already report failure through False or nil preserve that contract whilst GetLastDecodeBudgetInfo exposes the reason

Set DecodeBudgetBytes to zero only for trusted inputs that require unlimited per-chain expansion; negative values raise ERangeError

Delphi example

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);

C++Builder example

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);
}

Related APIs