Load Convert DOC Word Document to PDF and Get Total Number of Pages using Aspose.Words for C++

Hi,

I updated to 20.1 today. But I got some errors when testinging files.
All this code and file worked fine with 19.x.
And the test file is taking from examples.
Any help?

Thanks.

void testWordsConvert() {
System::String fileName2 = System::String(u"…\Words\Template.doc");
auto doc = MakeObjectAspose::Words::Document(fileName2);
printf(“pageCount: %d\n”, doc->get_PageCount());
}

Template.zip (74.7 KB)

@kngstr

We have logged this problem in our issue tracking system as WORDSCPP-931. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@tahir.manzoor
Thanks. I’ll be waiting.

@kngstr,

The issues you have found earlier (filed as WORDSCPP-931) have been fixed in this Aspose.Words for C++ 20.2 update.

@awais.hafeez
OK. Thanks.

@awais.hafeez

I tested the new version.
The problem is still existed.

But, I found the real reason: Slides for C++.

I loaded all dlls of Total for C++.
If dlls of words is loaded before dlls of slides, the error will reproduce.
To be clearly, these are steps:

  1. Load dlls of words.
  2. Load dlls of slides.
  3. Run test code from this topic, you will get the error.

@kngstr,

We are checking this scenario and will get back to you soon.

@kngstr,

I am afraid, we are unable to reproduce this issue on our end. We first installed the latest version of Aspose.Words for C++ 20.2 and after that we installed Aspose.Slides for C++ 20.2 via NuGet in the same Visual Studio 2017 C++ Console App on our end. The following C++ code returns 5 as number of pages on our end and it converts DOC to PDF correctly.

#include <iostream>
#include <system/smart_ptr.h> // For System::MakeObject<T>()
#include <system/io/memory_stream.h>
#include <system/object_ext.h>
#include <system/io/file.h>
#include <Aspose.Words.Cpp/Licensing/License.h>
#include <Aspose.Words.Cpp/Model/Document/Document.h>
#include <Aspose.Words.Cpp/Model/Document/DocumentBuilder.h>

using namespace Aspose::Words;

int main()
{
	auto license = System::MakeObject<License>();
	System::SharedPtr<System::IO::Stream> stream = System::IO::File::OpenRead(u"E:\\Temp\\Aspose.Total.Product.Family.lic");
	license->SetLicense(stream);

	System::SharedPtr<Document> doc = System::MakeObject<Document>(u"E:\\Temp\\Template\\Template.doc");

	printf("pageCount: %d\n", doc->get_PageCount());

	doc->Save(uR"(E:\temp\Template\awcpp-20.2.pdf)");
}

@awais.hafeez

  1. I downloaded files from down.aspose.com
  2. I’m using dynamic loading(because loading dlls is too slow)

Can you test dynamic loading?
Thanks.

@kngstr,

Can you please explain a bit, what do you mean by dynamic loading? Please provide complete steps that we can follow in Visual Studio to be able to observe the same problem on our end. Thanks for your cooperation.

@awais.hafeez

Something like project in this issue:

Sorry for my poor english.

@kngstr,

We have logged this problem in our issue tracking system. Your ticket number is WORDSCPP-939. We will further look into the details of this problem and will keep you updated on the status of the linked issue. We apologize for your inconvenience.

@awais.hafeez

WORDSCPP-931 ---- Status : Closed

Closed? Any news?
Thanks.

@kngstr,

We have good news for you i.e. WORDSCPP-939 has now been resolved. The fix of this issue will be included in the 20.3 (next version) of Aspose.Words for C++. We will inform you via this thread as soon as the next version containing the fix of your issue will be released.

@awais.hafeez
Thanks.

@kngstr,

It is to update you that the issue you have found earlier (filed as WORDSCPP-939) has been fixed in this Aspose.Words for C++ 20.3 update. So, please upgrade to the latest version of Aspose.Words for C++ API. Hope, this helps.

A post was split to a new topic: Convert DOC Word Document to PDF using C++ Code of Aspose.Words API

@awais.hafeez

Thanks.

It still didn’t work if I loaded after Slides .

@kngstr,

Can you please provide an example visual studio project demonstrating the problem where you are dynamically loading and using Aspose libraries? Thanks for your cooperation.

@awais.hafeez

Using LoadLibrary and GetProcAddress to load the library, not the way in your source code