THotPDF.DecodeBudgetBytes 속성
하나의 PDF 스트림 필터 체인에서 모든 디코딩 단계가 수락하는 최대 집계 바이트 수를 설정합니다
선언
// Delphi
property DecodeBudgetBytes: Int64;
function GetLastDecodeBudgetInfo(
out AInfo: THPDFDecodeBudgetInfo): Boolean;
// C++Builder
__property __int64 DecodeBudgetBytes;
bool __fastcall GetLastDecodeBudgetInfo(
THPDFDecodeBudgetInfo &AInfo);
기본값
268435456바이트, 즉 256 MiB
집계 계정
각 일반 필터는 데이터가 백업 메모리 스트림에 도달하기 전에 제한된 스트림을 통해 씁니다
[/ASCII85Decode /FlateDecode]와 같은 체인은 하나의 공유 예산에서 ASCII85 출력과 Flate 출력을 소비합니다- 지원하는 일반 필터로는
FlateDecode,LZWDecode,ASCIIHexDecode,ASCII85Decode,RunLengthDecode가 있으며, PDF 약어 형태도 포함됩니다 - 이미지 예측기 출력은 선행하는 일반 이미지 필터와 동일한 예산을 공유합니다
- 예산은 디코딩에 의해 생성된 확장을 측정하므로 원본 인코딩된 입력은 청구되지 않습니다
- 모든 독립 스트림 체인은 새 체인별 예산으로 시작하는 반면
DocumentDecodeBudgetBytes는 별도의 문서 전체 상한을 제공합니다
진단
GetLastDecodeBudgetInfo는 최신 체인 한도, 수락된 디코딩 바이트, 가장 큰 단계, 필터 수, 한도 상태 및 한도를 초과한 필터를 반환합니다
THPDFDecodeBudgetInfo = record
LimitBytes: Int64;
DecodedBytes: Int64;
PeakStageBytes: Int64;
FilterCount: Integer;
Exceeded: Boolean;
ExceededFilter: AnsiString;
end;
문서 인스턴스에서 필터가 하나 이상 디코딩되기 전까지는 이 메서드가 False를 반환합니다
실패 동작
저수준 디코딩에서 어느 단계가 누적 예산을 초과하면 EHPDFDecodeBudgetError가 발생합니다. 이미 False 또는 nil로 실패를 보고하는 상위 수준 읽기 메서드는 그 규약을 그대로 유지하며, 이유는 GetLastDecodeBudgetInfo로 확인할 수 있습니다
체인당 확장 크기 제한이 없어야 하는 신뢰할 수 있는 입력에 대해서만 DecodeBudgetBytes를 0으로 설정하십시오. 음수 값은 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);
}