"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