vcl-dxpdfdocument.md
A PDF document container.
TdxPDFDocument = class(
TObject
)
The TdxPDFDocument class implements a document container with an API for core content 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. You can use create a TdxPDFDocument class instance as a standalone document container for PDF document management without user interaction.
The list below outlines key members of the TdxPDFDocument class. These members allow you to load, parse, modify, and save PDF documents.
AllowContentExtraction | AllowPrinting
Return user action permissions in the current document if it is loaded with a user password.
Tip
You can use the SecurityOptions.Permissions property to obtain other user permissions for password-protected documents.
Provides access to document file attachments.
You can use this property to add, remove, or save file attachments.
FindTextSearches specified text occurrences in the current document.FormProvides access to the current document’s interactive form.InformationAllows you to read and edit document metadata.OnSearchProgressAllows you to track the current search position.PageCountReturns the number of pages in the current document.PageInfoAllows you to obtain information on individual document pages and copy their content.
AppendMerge two PDF documents.OnChangedAllows you to track document changes.PagesAllows you to add, insert, rearrange, rotate, and delete individual document pages.
LoadFromFile | LoadFromStreamAllow you to load a PDF document from a file or stream.OnGetPasswordAllows you to specify a user or owner password in code when the container loads a password-protected PDF document.OnLoadedNotifies the application of a successful document load operation.OnSaveProgressAllows you to track document save progress.PasswordAttemptsLimitSpecifies the number of allowed attempts to load an encrypted PDF document.SecurityOptions | SignatureOptionsAllow you to encrypt the current document, enable password protection, and add a digital signature before a save operation.SaveToFile | SaveToStreamAllow you to save the current document to a file or stream according to the current digital signature and user permission settings.
BeginUpdate | EndUpdateAllow you to avoid excessive notifications and improve performance during batch changes.ClearUnloads the current document.OnUnloadedAllows you to respond to a document unload operation.
The following code example loads a PDF document from the Demo.pdf file, deletes the first two pages of the loaded document, and saves the resulting document to a different file (Result.pdf):
uses
dxPDFDocument; // Declares the TdxPDFDocument class
// ...
var
ADocument: TdxPDFDocument;
begin
ADocument := TdxPDFDocument.Create;
try
ADocument.LoadFromFile('Data\Demo.pdf');
ADocument.BeginUpdate; // Initiates the following batch change
try
ADocument.Pages.Delete(0);
ADocument.Pages.Delete(0);
finally
ADocument.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
ADocument.SaveToFile('Data\Result.pdf');
finally
ADocument.Free; // Releases the created document container to avoid memory leaks
end;
#include "dxPDFDocument.hpp" // Declares the TdxPDFDocument class
// ...
TdxPDFDocument *ADocument = new TdxPDFDocument();
try
{
ADocument->LoadFromFile("Data\\Demo.pdf");
ADocument->BeginUpdate(); // Initiates the following batch change
try
{
ADocument->Pages->Delete(0);
ADocument->Pages->Delete(0);
}
__finally
{
ADocument->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
ADocument->SaveToFile("Data\\Result.pdf");
}
__finally
{
delete ADocument; // Releases the created document container to avoid memory leaks
}
The TdxPDFCustomViewer.Document property references a TdxPDFDocument object.
TObject TdxPDFDocument
See Also