PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
ComPDFKit supports opening local PDF documents or creating new ones.
The steps to open a local PDF document using a file path are as follows:
CDFDocument object using the file path.This example shows how to open a local PDF document:
// Initialize a `CPDFDocument` object using the PDF file path.
CPDFDocument document = CPDFDocument.InitWithFilePath(myFilePath);
if(document.ErrorType != CPDFDocumentError.CPDFDocumentErrorSuccess
&& document.ErrorType != CPDFDocumentError.CPDFDocumentPasswordError)
{
return;
}
// For encrypted documents, it is necessary to use a password to decrypt them.
if(document.IsLocked)
{
document.UnlockWithPassword(password);
}This example shows how to create a new PDF document:
CPDFDocument document = CPDFDocument.CreateDocument();By default, a newly created document doesn't contain any pages. Please refer to the "Document Editing" functionality to learn how to create new pages and add existing pages to the document.
This is the explanation of opening document status:
| Status Code | Description |
|---|---|
| CPDFDocumentErrorSuccess | Document opened successfully. |
| CPDFDocumentUnknownError | Unknown error. |
| CPDFDocumentFileError | File not found or cannot be opened. |
| CPDFDocumentFormatError | Format Error: not a PDF or corrupted |
| CPDFDocumentPasswordError | Password required or incorrect password. |
| CPDFDocumentSecurityError | Unsupported security scheme. |
| CPDFDocumentPageError | Page not found or content error. |