Owahi Word file utawa PDF ing Python SDK

Gunakake REST API kanggo ngowahi file ing Python kanthi program

Nalika pangembang ngowahi dokumen nganggo solusi Python sing diwenehake, sing bener-bener diowahi yaiku Model Obyek Dokumen (DOM). Mangkono, meh kabeh owah-owahan bisa digawe kanggo document dituduhake minangka DOM. Kanthi Python SDK sing disedhiyakake, pangembang bisa kanthi gampang nyunting dokumen: ngowahi teks, nganyari tabel, nambah gambar lan liya-liyane. Cukup muat Word, PDF utawa file ing format muat sing didhukung, gawe owah-owahan sing dibutuhake kanthi program lan ekspor asil menyang format nyimpen sing didhukung.

Ndeleng potongan kode

Sunting dokumen ing Python nggunakake REST API

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

Penting kanggo ngerti yen nggunakake solusi Python iki, sampeyan bisa ngowahi dokumen ing format apa wae sing didhukung. Contone, sampeyan bisa mbukak file ing PDF, DOCX, DOC, RTF, ODT, EPUB, HTML lan format liyane, banjur ngowahi file iki lan disimpen ing format sing padha utawa ing format sing didhukung liyane.

Sunting teks ing Python

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

Sunting tabel ing Python

Pilihan panyuntingan dokumen populer liyane 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 dokumen nggunakake Python

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

Ngedit dokumen online

Coba Python SDK sing kuat iki lan evaluasi sawetara opsi ing panyuntingan dokumen. Nggunakake conto ing ngisor iki, muat dokumen sampeyan lan gawe sawetara owah-owahan: nambah teks, nambah tabel lan sel tabel kanthi teks utawa lebokake gambar menyang 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.docx', '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='docx')
convert = words_api.convert_document(convert_request)
import asposewordscloud

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

request_document = open('Input.docx', '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='docx')
convert = words_api.convert_document(convert_request)
import asposewordscloud

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

request_document = open('Input1.docx', '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.docx', '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='docx')
convert = words_api.convert_document(convert_request)
Kode roto
  
Nyalin kode Python menyang clipboard

Carane ngowahi file ing Python

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

Python perpustakaan kanggo nggunakake panyuntingan dokumen

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.

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.