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.

Fri Dec 06, 2024 7:56 am

"I use Python 3.8.10 on linux system to execute the following code normally, but when I use 'pyinstaller --onefile --hidden-import=spire.doc.common.Color add_watermark.py' to generate an executable file, an error message appears:
'Traceback (most recent call last):
File "add_watermark.py", line 249, in <module>
main()
File "add_watermark.py", line 193, in main
color = Color.get_LightGray()
File "spire/doc/common/Color.py", line 923, in get_LightGray
AttributeError: 'NoneType' object has no attribute 'Color_get_LightGray''.
I used a lot of methods to solve the problem,but none of them work out.How should I troubleshoot this issue?" My code is (omit irrelevant code):

from spire.doc import TextWatermark, Document, PictureWatermark, TextWatermark, Color, WatermarkLayout, FileFormat
xxxxxx

def add_text_watermark_to_docx(input_file, text, font, size, color, angle):
document = Document()
document.LoadFromFile(input_file)

txtWatermark = TextWatermark()
txtWatermark.Text = text
txtWatermark.FontName = font
txtWatermark.FontSize = size
txtWatermark.Color = color
if angle > 0:
txtWatermark.Layout = WatermarkLayout.Diagonal
else:
txtWatermark.Layout = WatermarkLayout.Horizontal

document.Watermark = txtWatermark
document.SaveToFile(input_file, FileFormat.Wps)
document.Close()

def main():
xxxxxxxxxx
color = Color.get_LightGray()
add_text_watermark_to_docx(args.input_file, watermark_text, font, size, color, angle)
xxxxxxxxxx

suo_yongyong
 
Posts: 2
Joined: Fri Dec 06, 2024 7:36 am

Mon Dec 09, 2024 6:56 am

Hi,

Thanks for your inquiry.
The reason for this issue is that you did not specify these two files (libSkiaSharp.dll & Spire.Doc.Base.dll) as well during packaging, please find the two dlls in your installation directory and correct their paths in the following command.
Code: Select all
pyinstaller --add-binary ./libSkiaSharp.dll:./spire/doc/lib --add-binary ./Spire.Doc.Base.dll:./spire/doc/lib add_watermark.py


Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1329
Joined: Tue Sep 27, 2016 1:06 am

Tue Dec 10, 2024 3:13 am

Hello Nina,

I have fixed the issue use the command "pyinstaller --onefile --add-binary /usr/local/lib/python3.8/dist-packages/spire/doc/lib/libSkiaSharp.so --add-binary /usr/local/lib/python3.8/dist-packages/spire/doc/lib/Spire.Doc.Base.so add_watermark.py" according your direction.
Tanks very much.

Regards
Realsyy

suo_yongyong
 
Posts: 2
Joined: Fri Dec 06, 2024 7:36 am

Wed Dec 11, 2024 1:45 am

Dear Realsyy,

Glad to hear that your issue has been resolved.
If you have further questions, please do not hesitate to contact us. We are here to assist you.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1329
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.Doc