Sunting DOC ing Python SDK

Gunakake REST API kanggo nyunting DOC ing Python kanthi terprogram

Nalika pangembang ngowahi DOC dokumen nganggo perpustakaan Python iki, sing lagi diowahi yaiku Model Obyek Dokumen (DOM). Dadi, meh kabeh owah-owahan bisa ditindakake kanggo DOC dokumen sing diwakili minangka DOM. Kanthi Python SDK sing disedhiyakake, pangembang bisa kanthi gampang nyunting dokumen: ngowahi teks, nganyari tabel, nambah gambar lan liya-liyane. Cukup mbukak DOC, gawe owah-owahan sing dibutuhake kanthi program lan ekspor asil menyang format nyimpen sing padha utawa sing didhukung.

Ndeleng potongan kode

Sunting DOC ing Python nggunakake REST API

Pustaka Python kita menehi pangembang kemampuan kanggo ngowahi DOC dokumen kanthi langsung kanthi nyunting Document Object Model (DOM), tegese ora ana piranti lunak tambahan sing kudu diinstal.

Sunting teks ing DOC file nggunakake Python

Kasus sing paling populer kanggo nyunting DOC file yaiku nyunting teks. Kanthi solusi piranti lunak sing diwenehake, sampeyan bisa nambah, ngowahi utawa mbusak teks nggunakake Python ing dokumen kasebut.

Sunting tabel ing DOC file nggunakake Python

Pilihan editing DOC liyane sing populer yaiku nyunting tabel. Python SDK kita ngidini sampeyan nggarap tabel lan teks ing sel tabel.

Pangembang Python bisa nambah utawa mbusak sel tabel lan tabel, uga nambah, ngowahi lan mbusak teks ing njero.

Tambah gambar menyang DOC file nggunakake Python

Saliyane nyunting teks lan tabel ing DOC, ana pilihan umum liyane: nambahake gambar menyang dokumen ing Python. Pangembang Python uga bisa nambah gambar menyang DOC file nggunakake DOM.

Sunting DOC kanthi terprogram

Coba Python SDK sing kuat iki lan evaluasi sawetara opsi ing panyuntingan DOC dokumen. Nggunakake conto ing ngisor iki, muat DOC dokumen lan gawe sawetara owah-owahan: nambah teks, nambah tabel lan sel tabel kanthi teks utawa lebokake gambar menyang DOC dokumen:

Unggah dokumen sing pengin diowahi
Kode roto
Unggah gambar sing pengin dilebokake
Pilih format target saka dhaptar
import asposewordscloud

words_api = WordsApi(client_id = '####-####-####-####-####', 
   client_secret = '##################')

request_document = open('Input.doc', 'rb')
request_paragraph = asposewordscloud.ParagraphInsert(text='Morbi enim nunc faucibus a.')

insert_paragraph_request = asposewordscloud.models.requests.InsertParagraphOnlineRequest(
   document=request_document, paragraph=request_paragraph)
insert_paragraph = words_api.insert_paragraph_online(insert_paragraph_request)

convert_request = asposewordscloud.models.requests.ConvertDocumentRequest(
   document=list(insert_paragraph.document.values())[0], format='doc')
convert = words_api.convert_document(convert_request)
import asposewordscloud

words_api = WordsApi(client_id = '####-####-####-####-####', 
   client_secret = '##################')

request_document = open('Input.doc', 'rb')
request_table = asposewordscloud.TableInsert(columns_count=1, rows_count=2)

insert_table_request = asposewordscloud.models.requests.InsertTableOnlineRequest(
   document=request_document, table=request_table, node_path='')
insert_table = words_api.insert_table_online(insert_table_request)

convert_request = asposewordscloud.models.requests.ConvertDocumentRequest(
   document=list(insert_table.document.values())[0], format='doc')
convert = words_api.convert_document(convert_request)
import asposewordscloud

words_api = WordsApi(client_id = '####-####-####-####-####', 
   client_secret = '##################')

request_document = open('Input1.doc', 'rb')
request_drawing_object = asposewordscloud.DrawingObjectInsert(
   height=0, left=0, top=0, width=0, relative_horizontal_position='Margin', 
      relative_vertical_position='Margin', wrap_type='Inline')
request_image_file = open('Input2.doc', 'rb')

insert_drawing_object_request = 
   asposewordscloud.models.requests.InsertDrawingObjectOnlineRequest(
      document=request_document, drawing_object=request_drawing_object, 
         image_file=request_image_file, node_path='sections/0')
insert_drawing_object = words_api.insert_drawing_object_online(insert_drawing_object_request)

convert_request = asposewordscloud.models.requests.ConvertDocumentRequest(
   document=list(insert_drawing_object.document.values())[0], format='doc')
convert = words_api.convert_document(convert_request)
Kode roto
  
Nyalin kode Python menyang clipboard

Cara Ngowahi DOC ing Python

  1. Pasang 'Aspose.Words Cloud kanggo Python'
  2. Tambah referensi perpustakaan (ngimpor perpustakaan) menyang proyek Python sampeyan
  3. Muat DOC kanggo nyunting ing Python
  4. Lebokake isi ing wiwitan DOC
  5. Download dokumen asil saka panyimpenan maya

Pustaka Python kanggo nggunakake panyuntingan DOC.

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.

Requirements Sistem

Deleng Repository Documentation kanggo ndeleng rincian.

Format file liyane sing didhukung

Sampeyan bisa nindakake operasi suntingan kanggo format file liyane:

5%

Langganan kanggo Aspose Update Product

Entuk buletin saben wulan lan tawaran langsung dikirim menyang kothak layang.

© Aspose Pty Ltd 2001-2024. Kabeh hak dilindhungi undhang-undhang.