Windows
ComPDFKit PDF SDK
Guides

Open a Document

 

Open a Local File

 

// Get the path of a PDF
string filePath ="";
var dlg = new OpenFileDialog();
dlg.Filter = "PDF Files (*.pdf)|*.pdf";
if (dlg.ShowDialog() == true)
{
    filePath = dlg.FileName;
}
else
{
    return;
}

// Initialize a CPDFDocument object with the path to the PDF file
CPDFDocument document = CPDFDocument.InitWithFilePath(filePath);
if(document==null)
{
    return;
}

if(document.ErrorType != CPDFDocumentError.CPDFDocumentErrorSuccess
  && document.ErrorType != CPDFDocumentError.CPDFDocumentPasswordError)
{
    return;
}

 

Create a New File

 

CPDFDocument document = CPDFDocument.CreateDocument();