Array of all fonts used in document

If you are a Delphi developer and have any questions about using our products from Delphi here is the place to post them.
Post Reply
aghezzi
Posts: 2
Joined: Wed May 25 2005

Array of all fonts used in document

Post by aghezzi »

Hello,

I'm using a TPDFCreactiveX object (Delphi 6) and I'm trying to get the list of fonts used in the document.
I think I should use Document attribute "Fonts", wich returns an Array, but I don't understand how to do it.

var
aFonts: OleVariant;
i0, i1, i2: Variant;
begin

PDFCreactiveX1.Open('test.pdf', '');
aFonts := PDFCreactiveX1.ObjectAttribute['Document', 'Fonts'];
i0 := aFonts[0];
i1 := aFonts[1];
i2 := aFonts[2];

end;

Delphi 'tells' me that aFonts is a "variant array of Dispatch" type.
i0, i1 and i2 seems to be an address. How can I "use" them?

This is what I'm doing, can someone help me?
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

I unfortunately do not have a Delphi code snippet which illustrates this but I have however included a vc++ code snippet instead.

Hope this helps?

m_pdf.Open ("c:\\temp\\test.pdf", "");


//Get all font information
VARIANT arObjects = m_pdf.GetObjectAttribute("Document","Fonts");

SAFEARRAY* pObjects = V_ARRAY(&arObjects);

LONG lstart, lend;
SafeArrayGetLBound( pObjects, 1, &lstart );
SafeArrayGetUBound( pObjects, 1, &lend );


long rgIndices[1];
LPDISPATCH pObject = NULL;
rgIndices[0] = 0;

::SafeArrayLock(pObjects);
HRESULT iResult = ::SafeArrayGetElement(pObjects, rgIndices, ( void **) & pObject);
CacObject object( pObject );

TRY
{

//Retrieve FontName value
VARIANT text = object.GetAttribute( "FontName" );
if ( text.bstrVal )
AfxMessageBox( CString( text.bstrVal ) );


}
CATCH( COleDispatchException, e )
{
}
END_CATCH

::SafeArrayUnlock(pObjects);

Thanks
Post Reply