TdxPDFDocument Class
A PDF document container.
Declaration
TdxPDFDocument = class(
TObject
)
Remarks
The TdxPDFDocument
class implements an API for core document management functionality, such as load and save operations with support for encryption as well as digital signatures, content search and export, etc. The PDF Viewer control relies on a TdxPDFDocument
class instance to load, store, and manage documents.
Main API Members
The list below outlines key members of the TdxPDFDocument
class that allow you to load, parse, modify, and save PDF documents.
- Load a PDF document from a file or stream into the container and perform specific actions when a load operation succeeds (LoadFromFile, LoadFromStream, and OnLoaded).
- Specify the number of allowed attempts to load an encrypted PDF document (PasswordAttemptsLimit).
- Edit document metadata (Information).
- Identify the number of pages in the loaded document (PageCount).
- Specify a user or owner password in code when the container loads an encrypted document (OnGetPassword).
- Obtain information on specific document pages and export page content (PageInfo).
- Search text and track the current search position (FindText and OnSearchProgress).
- Access and manage file attachments (FileAttachments).
- Merge multiple PDF documents (Append).
- Apply batch document changes (BeginUpdate and EndUpdate).
- Track document changes (OnChanged).
- Access and rotate individual document pages (Pages).
- Encrypt the loaded document and enable password protection (SecurityOptions).
- Configure a digital signature (SignatureOptions).
- Access a form with interactive fields (Form).
- Identify user permissions in an encrypted document (AllowContentExtraction, AllowPrinting, and SecurityOptions.Permissions).
- Save the loaded document to a file or stream (SaveToFile and SaveToStream).
- Track document save progress (OnSaveProgress).
- Unload the loaded document (Clear).
- Respond to a successful document close operation (OnUnloaded).
Code Example: Delete the First Two Document Pages
The following code example loads a PDF document, deletes the first two pages in it, and saves the resulting document to a different file:
var
ADocument: TdxPDFDocument;
begin
ADocument := TdxPDFDocument.Create;
try
ADocument.LoadFromFile('Data\Demo.pdf');
ADocument.BeginUpdate;
try
ADocument.Pages.Delete(0);
ADocument.Pages.Delete(1);
finally
ADocument.EndUpdate;
end;
ADocument.SaveToFile('Data\Result.pdf');
finally
ADocument.Free;
end;
Direct TdxPDFDocument Class References
A PDF Viewer control’s Document property references a TdxPDFDocument
object.
Inheritance
TObject
TdxPDFDocument
See Also