THotPDF.DecodeBudgetBytes Property

ตั้งค่าจำนวน byte รวมสูงสุดที่ยอมรับจากขั้นตอนการถอดรหัสทั้งหมดในโซ่ตัวกรอง stream PDF หนึ่งโซ่

การประกาศ

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

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

ค่าเริ่มต้น

268435456 byte หรือ 256 MiB

การบัญชีรวม

ตัวกรอง generic แต่ละตัวเขียนผ่าน stream ที่มีขอบเขตก่อนที่ข้อมูลจะไปถึง backing memory stream ของมัน

การวินิจฉัย

GetLastDecodeBudgetInfo คืนขีดจำกัดโซ่ล่าสุด, byte ที่ถอดรหัสแล้วที่ยอมรับ, ขั้นตอนที่ใหญ่ที่สุด, จำนวนตัวกรอง, สถานะขีดจำกัด และตัวกรองที่เกินขีดจำกัด

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

เมธอดคืนค่า False จนกว่าตัวกรองอย่างน้อยหนึ่งตัวจะถูกถอดรหัสโดย instance ของเอกสาร

พฤติกรรมเมื่อล้มเหลว

การถอดรหัสระดับต่ำจะ raise EHPDFDecodeBudgetError เมื่อขั้นตอนเกินงบประมาณรวม; เมธอดอ่านระดับสูงที่รายงานความล้มเหลวผ่าน False หรือ nil อยู่แล้วจะรักษาสัญญานั้นไว้ ขณะที่ GetLastDecodeBudgetInfo เปิดเผยเหตุผล

ตั้งค่า DecodeBudgetBytes เป็นศูนย์เฉพาะสำหรับอินพุตที่น่าเชื่อถือซึ่งต้องการการขยายต่อโซ่แบบไม่จำกัด; ค่าลบจะ raise ERangeError

ตัวอย่าง 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);

ตัวอย่าง 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 ที่เกี่ยวข้อง