PDFium Component Docs

Active Egenskap

Denna API-post behåller identifierare, signaturer, kodblock och PDF-termer i ursprunglig form.
Komponent: TPdf  ·  Enhet: PDFium
Opens or closes the selected PDF document.

Syntax

property Active: Boolean; // default False

Beskrivning

Setting Active to True opens and loads the PDF document specified by FileName, using Password if the document is encrypted. When set to False, the document is closed and all associated PDFium resources (pages, fonts, form handles, text pages) are freed.

You can also call LoadDocument directly instead of toggling this property. Assigning FileName while Active is already True laddar automatiskt om dokumentet från den nya sökvägen, vilket är det rekommenderade sättet att växla mellan PDF-filer i en enda TPdf-instans.

Om filen inte kan öppnas (fel sökväg, fel lösenord, skadad PDF eller ett XFA-only-formulär som inte stöds) kastas en EPdfError undantag. Omslut tilldelningen i ett try/except-block för smidig felhantering och granska E.Message for the PDFium error description.

Anmärkningar

Exempel

Pdf1.FileName := 'C:\docs\report.pdf';
Pdf1.Password := ''; // leave empty if not encrypted
try
  Pdf1.Active := True;
  ShowMessage('Pages: ' + IntToStr(Pdf1.PageCount));
except
  on E: EPdfError do
    ShowMessage('Cannot open: ' + E.Message);
end;

Se även

FileName, Password, LoadDocument, PageCount, LoadLibrary, CreateDocument