Open, OpenEx, and DocOpen

The Open, OpenEx, and DocOpen methods open a PDF, Postscript, XPS, or image format like TIFF, PNG or JPEG, files for processing. The OpenEx version can be used with password protected documents and will fail if the password is invalid.

 

Syntax

ActiveX:

System.Boolean Open(System.String FileName)
System.Boolean OpenEx(BSTR FileName, System.String Password)

DLL:

int DocOpen(EXTDOCHANDLE* pedhDocument, LPCSTR szFileName, LPCSTR szPassword)

 

Parameters

FileName, szFileName

Full path of the PDF file to open.

Password, szPassword

Owner or user password associated with the document.

pedhDocument

Hold a reference to the document handle when the call is done.

 

Return Value

The return value is True if the file was opened. If the Open or OpenEx method fails, an exception is raised and there is no return value.

 

Remarks

Some operations are restricted when the document is opened using the user password as opposed to the owner password.

 

Member of CDIntfEx.Document.

Example

Public Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "DOCX Converter Developer Evaluation"

    Const strActivationCode As String = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

 

    ' Declare a new cdintfex document if it does not exist in the form.

    Dim pdfDoc As New CDIntfEx.Document

 

    ' Open the document

    pdfDoc.Open("c:\temp\test.pdf")

 

    ' The SetLicenseKey method should be called after creating an object of type 

    ' CDIntfEx.Document to activate the advanced methods that require the object 

    ' activation code to work properly

    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode)

 

    ' Export to DocX

    pdfDoc.ExportToDocX("c:\temp\Result.docx")

 

    ' Destroy pdfDoc object

    pdfDoc = Nothing    

End Sub

public void AutoBookmarks()

{

    // Constants for Activation codes

    const string strLicenseTo = "DOCX Converter Developer Evaluation";

    const string strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";

 

    // Declare a new cdintfex document if it does not exist in the form.

    CDIntfEx.Document pdfDoc = new CDIntfEx.Document();

 

    // Open the document

    pdfDoc.Open(@"c:\temp\test.pdf");

 

    // The SetLicenseKey method should be called after creating an object of type 

    // CDIntfEx.Document to activate the advanced methods that require the object 

    // activation code to work properly

    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode);

 

    // Export to DocX

    pdfDoc.ExportToDocX(@"c:\temp\Result.docx");

 

    // Destroy pdfDoc object

    pdfDoc = null;     

}

// PDF Converter Cpp.cpp : Defines the entry point for the console application.

// 

 

#include <Windows.h>

#include <string>

#include <iostream>

#include "CdIntf.h"

#pragma comment(lib, "CDIntf.lib")

 

using namespace std;

 

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  "DOCX Converter Developer Evaluation"

    #define strActivationCode "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

 

    // Declare a new cdintfex document if it does not exist in the form.

    EXTDOCHANDLE pdfDoc;

 

    // Open the document

    LPBYTE passWord = NULL;

    DocOpenA(&pdfDoc, "c:\\temp\\test.pdf", passWord);

 

    // The SetLicenseKey method should be called after creating an object of type 

    // CDIntfEx.Document to activate the advanced methods that require the object 

    // activation code to work properly

    SetLicenseKeyA(strLicenseTo, strActivationCode);

 

    // Export to DocX

    DocConvertToDOCXA(pdfDoc, "c:\\temp\\Appended.docx", "c:\\temp\\docxsettings.xml",1);

 

    // Destroy pdfDoc object

    pdfDoc = NULL;    

 

    return 0;

}

package Example;

 

import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;

import com.jacob.com.Variant;

 

public class Sample {

    public static void main(String[] args)

    {

        // Constants for Activation codes

        String strLicenseTo  = "DOCX Converter Developer Evaluation";

        String strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";

 

        // Declare a new cdintfex document if it does not exist in the form.

        ActiveXComponent pdfDoc = new ActiveXComponent("CDIntfEx.Document.6.5"); 

 

        // Open the document

        Dispatch.call(pdfDoc, "Open", "c:\\temp\\test.pdf");

 

        // The SetLicenseKey method should be called after creating an object of type 

        // CDIntfEx.Document to activate the advanced methods that require the object 

        // activation code to work properly

        Dispatch.call(pdfDoc, "SetLicenseKey", strLicenseTo, strActivationCode);

 

        // Export to DocX

        Dispatch.call(pdfDoc, "ExportToDocX", "c:\\temp\\Result.docx");

 

        // Destroy pdfDoc object

        pdfDoc = null;

    }

}

# Constants for Activation codes

$strLicenseTo  =  "DOCX Converter Developer Evaluation"

$strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

 

#Declare a new cdintfex document if it does not exist in the form.

$pdfDoc = New-Object -ComObject CDIntfEx.Document.6.5

 

#Open the document

[System.__ComObject].InvokeMember('Open', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,"c:\temp\test.pdf")

 

#The SetLicenseKey method should be called after creating an object of type 

#CDIntfEx.Document to activate the advanced methods that require the object 

#activation code to work properly

[System.__ComObject].InvokeMember('SetLicenseKey', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc, @($strLicenseTo, $strActivationCode))

 

#Export to DocX

[System.__ComObject].InvokeMember('ExportToDocX', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,"c:\temp\Result.docx")

 

#Destroy pdfDoc object

$pdfDoc = $null

' Constants for Activation codes

Const strLicenseTo = "DOCX Converter Developer Evaluation"

Const strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

 

' Declare a new Document object

Dim pdfDoc

Set pdfDoc = CreateObject("CDIntfEx.Document.6.5")

 

' Open the document

pdfDoc.Open "c:\temp\test.pdf"

 

' The SetLicenseKey method should be called after creating an object of type 

' CDIntfEx.Document to activate the advanced methods that require the object 

' activation code to work properly

pdfDoc.SetLicenseKey strLicenseTo, strActivationCode

 

' Export to DocX

pdfDoc.ExportToDocX "c:\temp\Result.docx"

 

' Destroy pdfDoc object

Set pdfDoc = Nothing