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.
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:
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)
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.
Deleng Repository Documentation kanggo ndeleng rincian.
Sampeyan bisa nindakake kompresi dokumen kanggo format file liyane: