Code: Select all
#import "PDFCreactiveX.DLL"
#define COMPANY "xxx"
#define LICENSE "yyy"
using namespace ACPDFCREACTIVEX;
class CAmyuni
{
	CAmyuni();
	virtual ~CAmyuni();
	bool Open();
	bool Save();
	bool Write();
	IPDFCreactiveXPtr m_pPDF;
}Code: Select all
CAmyuni::CAmyuni(void) :
	m_pPDF(NULL)
{
	// CoInitialize is called from somewhere else 
	// Create the PDFCreactiveX COM Object
	HRESULT hr = m_pPDF.CreateInstance(__uuidof(PDFCreactiveX));
	if (SUCCEEDED(hr))
	{	
		// Set the license key
		hr = m_pPDF->SetLicenseKey(_bstr_t(COMPANY), _bstr_t(LICENSE));
	}	
}Code: Select all
bool CAmyuni::Open()
{
	if (m_pPDF)
	{
		// Open the pdf file which contains fields
		long lResult = m_pPDF->Open(szPDF, szPassword);
		if (lResult)
		{
			// Use design mode for any kind of editing
			m_pPDF->ReportState = acReportStateDesign;
                }
        }   
}Code: Select all
bool CAmyuni::Write()
{
	try
	{
		// Set the current page
		m_pPDF->CurrentPage = 1; 
			
		// FieldName which exists in the PDF but I get an exception
		IacObjectPtr pObject = m_pPDF->GetObjectByName(_bstr_t("FieldName"));
		if (pObject)
		{
		}
	}
	catch(_com_error& e)
	{
		// I am getting an "Unspecified error"
		OutputDebugString(e.ErrorMessage());			
	}
}