Creating Objects With the CreateObject Method

The CreateObject method creates a new object on the current page of the PDF document with specified type and reference (See CreateObject) for the Syntax and Parameters of this method). The current page is the one being currently displayed or activated using the CurrentPage property of the ActiveX control.

If an object with the same reference already exists in the document, the PDF control automatically generates a reference for the new object depending on the type of object.

 

Example in C++:

The sample below shows how to create an image on the current page.

 

 

m_pdf->ReportState = acReportStateDesign;

_variant_t varAttribute;

//create picture object

m_pdf->CreateObject(acObjectTypePicture, _bstr_t( "PictureObject" ) );

varAttribute.SetString("C:\\test.jpg");

m_pdf->put_ObjectAttribute( _bstr_t( "PictureObject" ),

_bstr_t("FileName"), varAttribute );

varAttribute.vt = VT_I4;

varAttribute.lVal = RGB( 0, 255, 0 );

m_pdf->put_ObjectAttribute( _bstr_t( "PictureObject" ),

_bstr_t("BorderColor"), varAttribute );

varAttribute.lVal = 3;

m_pdf->put_ObjectAttribute( _bstr_t( "PictureObject" ),

_bstr_t("BorderWidth"), varAttribute );

varAttribute.lVal = 856;

m_pdf->put_ObjectAttribute( _bstr_t( "PictureObject" ),

_bstr_t("Left"), varAttribute );

varAttribute.lVal = 5050;

m_pdf->put_ObjectAttribute( _bstr_t( "PictureObject" ),

_bstr_t("Top"), varAttribute );

varAttribute.lVal = m_pdf->PageWidth;

varAttribute.lVal = 6000;

m_pdf->put_ObjectAttribute( _bstr_t( "PictureObject" ),

_bstr_t("Right"), varAttribute );

varAttribute.lVal = 10000;

m_pdf->put_ObjectAttribute( _bstr_t( "PictureObject" ),

_bstr_t("Bottom"), varAttribute );

m_pdf->Refresh();