PDFium Delphi Component Docs

SetDeterministicTime method

Component: TPdf  ·  Unit: PDFium
Pins the clock PDFium stamps into generated documents so output stays byte-reproducible

Syntax

class procedure SetDeterministicTime(FixedEpoch: Int64);

FixedEpochInt64. Time PDFium should report, as seconds since the Unix epoch

Description

PDFium reads the system clock when it writes creation and modification dates and other time-derived values. Two runs of the same code therefore produce two different files, which breaks byte-comparison in tests and reproducible builds

Fixing the clock makes the output depend only on the input. This is a class method, so it applies to every TPdf instance in the process, and it stays in effect until RestoreActualTime is called

It takes effect only when the loaded PDFium module exports the time hook; on a module without it the call is accepted but the clock is not overridden

Example

TPdf.SetDeterministicTime(1700000000);
try
  Pdf.SaveAs('reproducible.pdf');
finally
  TPdf.RestoreActualTime;
end;

See Also

RestoreActualTime, SaveAsReproducible, CreationDate, ModifiedDate