We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Using Aspose.Words from C++

I need to call Aspose.Words from unmanaged C++ but I’m not having any luck. I have some simple code like the following:

String ^mgdFilename = gcnew String(L"c:\\tmp\\Google.doc");
DocumentRenderer ^rDocRenderer = gcnew DocumentRenderer(mgdFilename);
PageNavigator ^rPageNavigator = gcnew PageNavigator(rDocRenderer);

I get a hang on the third line. Do you have a sample C++ project that demonstrates accessing some Aspose.Words calls successfully? I’d prefer to see something wortking with the DocumentRenderer but I’d take anything at this point. :wink:



This message was posted using Aspose.Live 2 Forum


Thanks for your inquiry. I will investigate this and provide you more information hopefully tomorrow.

Best regards.


I tried your code and it seems that it works fine on my side. Here is my code. Also I attached test project.

String ^mgdFilename = gcnew String("C:\\Temp\\out.doc");
//Create document renderer
DocumentRenderer ^rDocRenderer = gcnew DocumentRenderer(mgdFilename);
//Create PageNavigator
PageNavigator ^rPageNavigator = gcnew PageNavigator(rDocRenderer);
//Itterate through pages in document
for(int pageNumber=1; pageNumber<=rPageNavigator->PageCount; pageNumber++)
    //Get Current Page
    System::Drawing::Bitmap ^currentPage = rPageNavigator->CurrentPage;
    //Save current page
    String ^imgeFileName = gcnew String("C:\\Temp\\page\_"+pageNumber+".jpg");

I hope that this will help you.

Best regards.

Interesting. I’m still seeing problems, even when using your project. Are you using Words 4.4.2or 4.4.3?


I use Aspose.Words v4.4.3.0. Could you please tell me what problems you mean?

Best regards.

OK, I figured. I upgraded and still have the same issue. The issue is stepping
over the line creating the PageNavigator hangs for a long time and finally crashes
with a stack overflow (System.StackOverflowException). Here’s the end part of
the stack I see on your code:

mscorlib.dll!System.Security.CodeAccessSecurityEngine.Assert(System.Security.CodeAccessPermission cap = {System.Security.Permissions.SecurityPermission}, ref System.Threading.StackCrawlMark stackMark) + 0x3f bytes 
mscorlib.dll!System.Security.CodeAccessPermission.Assert() + 0x15 bytes 
System.Drawing.dll!System.Drawing.Font.SetFontFamily(System.Drawing.FontFamily family) + 0x43 bytes 
System.Drawing.dll!System.Drawing.Font.Font(string familyName, float emSize = 10.0, System.Drawing.FontStyle style = Regular) + 0x57 bytes 
Aspose.Words.dll!ӓ.௯.ⴲ() + 0xb9 bytes 
Aspose.Words.dll!ӓ.௯.௯(ӓ.Ӿ pgfx = {ӓ.Ӿ}, Aspose.Words.Font asposeFont = {Aspose.Words.Font}, string text = "[www.tech-archive.net/Archive/Office/microsoft.public.office.developer.automation/2006-05/msg00017.html](http://www.tech-archive.net/Archive/Office/microsoft.public.office.developer.automation/2006-05/msg00017.html) - 11k - ") + 0x3b bytes 
Aspose.Words.dll!ӓ.௯.ⴱ(int ڈ = 0) + 0x121 bytes 
Aspose.Words.dll!ӓ.௯.ӗ(float ޘ = 421.2) + 0xa5 bytes 
Aspose.Words.dll!ӓ.ⴘ.ⴝ(ӓ.௯ ⴜ = {ӓ.௯}) + 0x7c bytes 
Aspose.Words.dll!ӓ.ⴘ.ⴝ(ӓ.௯ ⴜ = {ӓ.௯}) + 0x58 bytes 

Sonething is weird here, thought I’m not sure what is the cause.

Could you please attach your document here? I will try to reproduce your problemand provide you more information.

Best regards.

Sure thing.


Thanks for additional information. I managed to reproduce the problem. I have logged this problem to our defect database as issue # 4283. Please expect a reply before the next hotfix (within 2-3 weeks). Note that Aspose.Words.Viewer is currently in beta.

Best regards.

OK, thanks!

We are happy to tell you that the new Rendering Engine has replaced the “old Viewer Beta”. The Rendering Engine can print, save as images or draw onto .NET Graphics object any document page.

Please see Aspose.Words documentation to learn more about new features.

Saving to image

In additional, new Rendering engine allows you to convert Word document to PDF directly (without using Aspose.Pdf).

Saving to Pdf

The latest version of Aspose.Words is available for download from downloads section or from NuGet