Kompres PDF ing Go SDK

Ngurangi ukuran PDF nggunakake Go

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

Ndeleng potongan kode

Kompres PDF ing Go

Nggunakake Go 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 Go

Kaya sing wis kasebut, SDK Go kita ngidini sampeyan nyuda ukuran PDF kanthi program. Lan saiki sampeyan bisa nyoba fungsi sing kuat lan ngevaluasi cara ngompres PDF 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.pdf")
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("pdf"),
    Optionals: convertDocumentOptions,
}
_, _ = wordsApi.ConvertDocument(ctx, convertDocument)
Kode roto
  
Nyalin kode Go menyang clipboard

Carane ngompres PDF 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 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 Go kanggo nggunakake kompresi PDF.

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