Amyuni C++ implementation

If you are a C/C++/C# developer and have any questions about using our products from your application here is the place to post them.
Post Reply
romeo.macapobre
Posts: 2
Joined: Thu Jun 03 2010

Amyuni C++ implementation

Post by romeo.macapobre »

1. I created a class that wraps AMYUNI calls to serve my purposes.

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;
}
2. From the constructor I setup the license

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));
	}	
}
3. I open a PDF file which contains fields

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;
                }
        }   
}
4. I attempt to get a pointer to a field defined in the PDF file

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());			
	}
}
5. Any ideas?
Devteam
Posts: 119
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: Amyuni C++ implementation

Post by Devteam »

This might be an obvious question, but are you sure that you have a form field object named "FieldName" in your document? GetObjectByName doesn't seem to find such a field and is returning an error.
Amyuni Development Team

Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com
romeo.macapobre
Posts: 2
Joined: Thu Jun 03 2010

Re: Amyuni C++ implementation

Post by romeo.macapobre »

You were right. There was a typo in my code.
Mille mercis!
Post Reply