Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Sat Mar 30, 2024 6:55 pm

hi
I'm using vscode to devlope my univesity project
i want to create a report in python and im using spire.doc 12.2.0
i want to try add licence but it occurs error when i want to create document

my code is in below:

Code: Select all
import math
from spire.doc import *
from spire.doc.common import *

License.SetLicenseKey("license.elic.xml")

# Create an object of the Document class
doccument = Document()


error whrn i add licence
Code: Select all
Traceback (most recent call last):
  File "g:\Temporary\temperory code\vda\VDA-v3\first release\v3.1\replace_code", line 9, in <module>
    doccument = Document()
          ^^^^^^^^^^
  File "g:\Temporary\temperory code\vda\VDA-v3\.venvVDA\Lib\site-packages\plum\function.py", line 642, in __call__
    return self.f(self.instance, *args, **kw_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "g:\Temporary\temperory code\vda\VDA-v3\.venvVDA\Lib\site-packages\plum\function.py", line 592, in __call__
    return _convert(method(*args, **kw_args), return_type)
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "g:\Temporary\temperory code\vda\VDA-v3\.venvVDA\Lib\site-packages\spire\doc\Document.py", line 351, in __init__
    intPtr = CallCFunction(GetDllLibDoc().Document_CreateDocument,)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "g:\Temporary\temperory code\vda\VDA-v3\.venvVDA\Lib\site-packages\spire\doc\common\__init__.py", line 109, in CallCFunction
    raise SpireException(info)
spire.doc.common.SpireException: Format_BadBase64Char:   at System.Convert.FromBase64CharPtr(Char*, Int32) + 0xd8
   at System.Convert.FromBase64String(String) + 0x30
   at sprmoe.spra(String, Boolean) + 0x48
   at sprmoe.sprc(String) + 0xe
   at sprmoe.spre(String) + 0x15
   at sprmn3.spra(Type) + 0x3a
   at sprmn3.sprb(Type) + 0x93
   at sprmn3.GetLicense(LicenseContext, Type, Object, Boolean) + 0x3b
   at System.ComponentModel.LicenseManager.ValidateInternalRecursive(LicenseContext, Type, Object, Boolean, License&, String&) + 0x124
   at Spire.Doc.Document.sprf() + 0x5e
   at Spire.Doc.Document.sprad() + 0x17
   at Spire.Doc.AOT.NLDocument.Document_CreateDocument(IntPtr) + 0x49
Exception ignored in: <function SpireObject.__del__ at 0x000001D3D47853A0>
Traceback (most recent call last):
  File "g:\Temporary\temperory code\vda\VDA-v3\.venvVDA\Lib\site-packages\spire\doc\common\SpireObject.py", line 31, in __del__   
    CallCFunction(dlllib.Spire_FreeHandle,self.Ptr)
                                          ^^^^^^^^
  File "g:\Temporary\temperory code\vda\VDA-v3\.venvVDA\Lib\site-packages\spire\doc\common\SpireObject.py", line 27, in Ptr       
    return self._ptr
           ^^^^^^^^^
AttributeError: 'Document' object has no attribute '_ptr'


Image
Image
Image

XxLonely
 
Posts: 19
Joined: Sat Mar 30, 2024 5:11 pm

Mon Apr 01, 2024 3:09 am

Hi,

Thanks for your inquiry.
According the code you provided, the exception caused by not using correctly of the SetLicenseKey methond.
The parameter of SetLicenseKey methond is not the path of the License file, but the long string of “key” in License file, as shown in the following screenshot:
1.png


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 994
Joined: Tue Mar 08, 2022 2:02 am

Mon Apr 01, 2024 9:13 am

thx a lot

XxLonely
 
Posts: 19
Joined: Sat Mar 30, 2024 5:11 pm

Mon Apr 01, 2024 9:46 am

You're welcome!

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 994
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Doc

cron