Using Aspose.Pdf via COM from Unmanged C++


#1

I'm writing a "Microsoft Visual C++ .NET" unmanaged C++ application and want to use Aspose.Pdf via the COM interface. Do you have any sample code showing how to do this?

To test it out, I was playing around with the COM object using VBScript without much success. Here is my "port" of the Hello World sample from VB to BLOCKED SCRIPT

dim pdf1
set pdf1 = CreateObject("Aspose.Pdf.Pdf")
dim sec1
set sec1 = pdf1.Sections.Add()
dim text1
set text1 = CreateObject("Aspose.Pdf.Pdf.Text")
sec1.Paragraphs.Add(text1)
pdf1.Save("c:\tmp\HelloWorld.pdf")

Windows Script Host reports an error on the line "pdf1.Sections.Add()" stating "Invalid procedure call or argument: 'Sections.Add'. And I don't believe the "set text1" line will work either, but didn't know how to create an Aspose.Pdf Text object.

Again, my goal is to get this to work in C++ via COM, but I was just testing in VBScript before writing any C++ code. C++ samples would be very helpful. Thank you.

Joe A.


#2

Dear Joe,

Thank you for considering Aspose.

Please refer to Using Aspose.Pdf for COM Applications. You should create the Section object with CreateObject and then add it to the Pdf document’s Sections collection.
As you can see, Aspose.Pdf does not support early binding in COM application. There is no type libary provided with the component. So get it work in C++ via COM is not convenient.


#3

Thank you Tommy, I now have it working in my VBScript test case. But do you have any C++ sample code I can look at to get me started using the COM object? I will take anything that you have.

Also, are there any known problems (other than the binding issue) using the COM object approach?

Thanks,
Joe A.


#4

Hi Joe,

I wish I can help you. But in fact I am not familiar with COM. And I have no C++ example currently. I have to study this issue from scratch like you. But Aspose.Pdf is a standard .NET component, so you can look at information about using .NET component in COM application at other place.