Kompres PDF ing Python SDK

Ngurangi ukuran PDF nggunakake Python

Nggunakake REST API ing Python, pangembang bisa ngompres PDF kanthi program. Kanthi solusi sing diwenehake, output bakal dadi file berkualitas tinggi sawise kompresi.

Ndeleng potongan kode

Kompres PDF ing Python

Nggunakake Python API sing kuat, pangembang bisa ngompres PDF dokumen kanggo ngoptimalake konten lan ukuran file output. Ngurangi ukuran PDF dumadi kanthi ngresiki data lan sumber daya sing ora digunakake. Sampeyan uga bisa ngompres gambar ing PDF supaya ukuran file output luwih cilik.

Asil optimasi lan kompresi isi bisa disimpen ing PDF asli utawa format nyimpen sing kasedhiya - DOCX, DOC, RTF, HTML lan liya-liyane. Contone, kompres PDF lan simpen output minangka Word.

Ngurangi ukuran PDF file ing Python

Kaya sing wis kasebut, SDK Python kita ngidini sampeyan nyuda ukuran PDF kanthi program. Lan saiki sampeyan bisa nyoba fungsi sing kuat lan ngevaluasi cara ngompres PDF ing Python kanthi conto ing ngisor iki:

Unggah file sing pengin dioptimalake / kompres
Kode roto
Pilih format target saka dhaptar
import asposewordscloud

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

request_document = open('Input.pdf', 'rb')
request_compress_options = asposewordscloud.CompressOptions(
   images_quality=75, images_reduce_size_factor=1)
compress_document_request = asposewordscloud.models.requests.CompressDocumentOnlineRequest(
   document=request_document, compress_options=request_compress_options)
compress_document = words_api.compress_document_online(compress_document_request)

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

Carane ngompres PDF ing Python

  1. Pasang Aspose.Words Cloud for Python
  2. Tambah referensi perpustakaan (ngimpor perpustakaan) menyang proyek Python sampeyan
  3. Konfigurasi API nggunakake tombol app
  4. Muat sumber PDF kanggo ngompres
  5. Kompres PDF, ngresiki informasi sing ora digunakake
  6. Pilih format file output
  7. Entuk asil kompresi PDF minangka file sing kapisah

Pustaka Python kanggo nggunakake kompresi PDF.

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 kompresi dokumen 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.