THotPDF.DecodeBudgetBytes Property

Imposta il numero aggregato massimo di byte accettati da tutti gli stadi di decodifica in una catena di filtri di un flusso PDF

Dichiarazioni

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

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

Predefinito

268435456 byte, ovvero 256 MiB

Contabilità aggregata

Ogni filtro generico scrive attraverso un flusso limitato prima che i dati raggiungano il suo flusso di memoria sottostante

Diagnostica

GetLastDecodeBudgetInfo restituisce il limite più recente della catena, i byte decodificati accettati, lo stadio più grande, il numero di filtri, lo stato del limite e il filtro che ha superato il limite

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

Il metodo restituisce False finché almeno un filtro non è stato decodificato dall'istanza del documento

Comportamento in caso di fallimento

La decodifica a basso livello solleva EHPDFDecodeBudgetError quando uno stadio supera il budget aggregato; i metodi di lettura ad alto livello che segnalano già il fallimento tramite False o nil preservano quel contratto mentre GetLastDecodeBudgetInfo espone il motivo

Impostare DecodeBudgetBytes a zero solo per input attendibili che richiedono un'espansione illimitata per catena; i valori negativi sollevano ERangeError

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

Esempio 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 correlate