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.

Thu Sep 19, 2024 4:38 pm

Unhandled Exception: System.InvalidCastException: Arg_InvalidCastException
at System.Runtime.TypeCast.CheckCastClass(MethodTable*, Object) + 0x31
at SkiaSharp.SKAbstractManagedStream.ReadInternal(IntPtr s, Void* context, Void* buffer, IntPtr size) + 0xc4
at Spire.Presentation.Base!<BaseAddress>+0x126c20c
[2024-09-19 12:45:16,107] CRITICAL in app: Server stopped or crashed
[2024-09-19 12:45:16,107] CRITICAL in app: Server stopped or crashed


Hi, I'm getting error for the below code in python, I'm trying to convert a docx file into PDF, I've checked if the docx file is valid or not, the file is getting passed as valid and the data type is also correct. I'm not getting this error everytime, this error comes randomly irrespective of the input docx.

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

document = Document()

document.LoadFromFile("C:\\Users\\Administrator\\Desktop\\input.docx")

document.SaveToFile("output/ToPDF.pdf", FileFormat.PDF)
document.Close()


I'm using the same sample code but with extra exception handlings, but I'm not able to catch this particular error whatever I do, and most importantly this error causes the server to crash everytime.

krishbharani
 
Posts: 1
Joined: Thu Sep 19, 2024 4:17 pm

Fri Sep 20, 2024 8:18 am

Hello,

Thanks for your inquiry. I tested the same code using the latest commercial version(Spire.Doc for Python(12.7.1) and Spire.Presentation for Python(9.3.0)), but I was unable to reproduce the issue. If you are not using the latest version, please test it after updating as it includes more fixes and optimizations. Finally, if the issue persists, please provide us with your input Word document as well as your system information (E.g. Win10, 64 bit) and region setting (E.g. China, Chinese). Thank you in advance.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 306
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.Doc

cron