Tambah teks utawa gambar watermark menyang DOCX dokumen nggunakake Python. Muat DOCX dokumen lan lebokake tandha banyu sing dibutuhake. Banjur simpen asil ing format sing trep kayata DOCX, PDF, MD, HTML, TXT, DOC, RTF, EPUB, XPS lan liya-liyane, lan nuduhake dokumen sing diwenehi tandha banyu karo wong liya. Uga mbusak tandha banyu saka DOCX dokumen yen tandha banyu sadurunge ditambahake menyang dokumen, lan alasan kanggo nambah ora relevan maneh.
Kanthi API Python iki, pangembang bisa nambah tandha banyu menyang DOCX online. Mung nggawe watermark nggunakake teks utawa gambar banjur lebokake watermark menyang DOCX dokumen ing Python.
Cathetan: ora perlu nginstal aplikasi utawa perpustakaan pihak katelu. Mulane, solusi piranti lunak Python kita gampang banget digunakake.
SDK Python sing diwenehake uga mbiyantu mbusak tandha banyu saka DOCX. Mbusak tandha banyu ing DOCX tegese sampeyan bisa mbukak DOCX dokumen sing dipengini kanthi prangko teks utawa gambar, mbusak tandha banyu iki saka DOCX nggunakake Python, banjur simpen file output ing format sing trep - DOC, DOCX, PDF, JPEG, PNG, TIFF lan liya-liyane.
Kanggo ngevaluasi carane nambah utawa mbusak tandha banyu ing DOCX nganggo API Python, muat DOCX lan tandha banyu minangka gambar utawa teks. Banjur pilih format file ekspor sing trep - DOC, DOCX, PDF, HTML, RTF, XPS lan liya-liyane.
Gunakake conto ing ngisor iki kanggo ndeleng cara kerjane:
import asposewordscloud
words_api = WordsApi(
client_id = '####-####-####-####-####', client_secret = '##################')
request_document = open('Input1.docx', 'rb')
request_image_stream = open('Input2.jpg', 'rb')
request_watermark_data = asposewordscloud.WatermarkDataImage(
image=asposewordscloud.FileReference.fromLocalFileContent(request_image_stream))
insert_watermark_request = asposewordscloud.models.requests.InsertWatermarkOnlineRequest(
document=request_document, watermark_data=request_watermark_data)
insert_watermark_result = words_api.insert_watermark_online(insert_watermark_request)
convert_document_request = asposewordscloud.models.requests.ConvertDocumentRequest(
document=list(insert_watermark_result.document.values())[0], format='docx')
words_api.convert_document(convert_document_request)
import asposewordscloud
words_api = WordsApi(
client_id = '####-####-####-####-####', client_secret = '##################')
request_document = open('Input.docx', 'rb')
request_watermark_data = asposewordscloud.WatermarkDataText(
text='This is the watermark text',
layout='Diagonal')
insert_watermark_request = asposewordscloud.models.requests.InsertWatermarkOnlineRequest(
document=request_document, watermark_data=request_watermark_data)
insert_watermark_result = words_api.insert_watermark_online(insert_watermark_request)
convert_document_request = asposewordscloud.models.requests.ConvertDocumentRequest(
document=list(insert_watermark_result.document.values())[0], format='docx')
words_api.convert_document(convert_document_request)
import asposewordscloud
words_api = WordsApi(
client_id = '####-####-####-####-####', client_secret = '##################')
request_document = open('Input.docx', 'rb')
delete_watermark_online = asposewordscloud.models.requests.DeleteWatermarkOnlineRequest(
document=request_document)
deleted_watermark = words_api.delete_watermark_online(delete_watermark_online)
convert_document = asposewordscloud.models.requests.ConvertDocumentRequest(
document=list(deleted_watermark.document.values())[0], format='docx')
words_api.convert_document(convert_document)
Instal Aspose.Words Cloud SDK for Python nggunakake repositori PyPi. pip install aspose-words-cloud kanggo nginstal SDK, banjur impor paket kasebut liwat import asposewordscloud. Minangka alternatif, sampeyan bisa kanthi manual clone Aspose.Words Cloud SDK for Python saka GitHub lan nggunakake ing project. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.
Deleng Repository Documentation kanggo ndeleng rincian.
Sampeyan bisa nambah watermark menyang dokumen ing format liyane: