Kompres PDF file utawa Word ing Go SDK

Ngurangi ukuran dokumen nggunakake Go

Nggunakake REST API ing Go, pangembang bisa ngompres dokumen ing DOC, DOCX, RTF, PDF, lan format liyane. Kanthi solusi sing diwenehake, output bakal dadi file berkualitas tinggi sawise kompresi.

Ndeleng potongan kode

Kompres dokumen ing Go

Nggunakake Go API sing kuat, pangembang bisa ngompres file kanggo ngoptimalake konten lan ukuran file output. Ngurangi ukuran file dumadi kanthi ngresiki data lan sumber daya sing ora digunakake. Sampeyan uga bisa compress gambar kanggo nggawe ukuran file output malah luwih cilik.

Asil optimasi lan kompresi isi bisa disimpen ing format file asli utawa format nyimpen sing kasedhiya - DOCX, DOC, RTF, PDF, HTML lan liya-liyane.

Ngurangi ukuran file ing Go

Kaya sing wis kasebut, SDK Go kita ngidini sampeyan nyuda ukuran dokumen kanthi program ing format apa wae sing didhukung. Contone, sampeyan bisa nyuda ukuran PDF file, DOCX, DOC, RTF, ODT, EPUB, HTML lan format liyane. Lan saiki sampeyan bisa nyoba fungsi sing kuat lan ngevaluasi cara ngompres dokumen ing Go kanthi conto ing ngisor iki:

Unggah file sing pengin dioptimalake / kompres
Kode roto
Pilih format target saka dhaptar
import (
    "os"
    "github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)

config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)

requestDocument, _ := os.Open("Input.docx")
requestCompressOptions := models.CompressOptions{
    ImagesQuality: ToInt32Pointer(int32(75)),
    ImagesReduceSizeFactor: ToInt32Pointer(int32(1)),
}
compressDocumentOnlineOptions := map[string]interface{}{}
compressDocumentRequest := &models.CompressDocumentOnlineRequest{
    Document: requestDocument,
    CompressOptions: &requestCompressOptions,
    Optionals: compressDocumentOnlineOptions,
}
compressDocument = wordsApi.CompressDocumentOnline(ctx, compressDocumentRequest)

convertDocumentOptions := map[string]interface{}{}
convertDocument := &models.ConvertDocumentRequest{
    Document: compressDocument.Document.Values[0],
    Format: ToStringPointer("docx"),
    Optionals: convertDocumentOptions,
}
_, _ = wordsApi.ConvertDocument(ctx, convertDocument)
Kode roto
  
Nyalin kode Go menyang clipboard

Carane ngompres dokumen ing Go

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

Pustaka Go kanggo nggunakake kompresi dokumen

Run go get -v github.com/aspose-words-cloud/aspose-words-cloud-go/2007/api kanggo nginstal Aspose.Words Cloud SDK for Go. Sampeyan bisa entuk akeh informasi migunani babagan cara instalasi liyane saka bagean "How to use SDK".

Klone Aspose.Words Cloud SDK for Go saka GitHub lan gunakake ing proyek sampeyan. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.

Requirements Sistem

Deleng Repository Documentation kanggo ndeleng rincian.

Format paling populer kanggo kompresi dokumen

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.