A cikin lokacin da abun ciki na gani ke mulki mafi girma, buƙatar canza Takardun Kalma zuwa JPG jpeg/) Tsarin ya zama mafi mahimmanci fiye da kowane lokaci. Ko kuna ƙirƙira gabatarwa mai jan hankali, raba snippets na abubuwan rubutu akan kafofin watsa labarun, ko haɗa bayanan daftarin aiki a cikin ayyukan multimedia, ikon canza fayilolin Kalma ba tare da ɓata lokaci ba zuwa hotuna JPG masu yawa. A cikin wannan labarin, za mu tattauna cikakkun bayanai kan yadda ake canza kalmar zuwa JPG ta amfani da Python SDK.
- Canjin JPG zuwa REST API
- Canza Kalma zuwa JPG a Python
- Ajiye Kalma cikin Hoto ta amfani da Umurnin CURL
Canjawar JPG zuwa REST API
Yin amfani da Aspose.Words Cloud SDK don Python don yin jujjuyawar daga Kalma zuwa JPG yana gabatar da mafita mai ƙarfi da dacewa don sarrafa takardu. Wannan SDK yana ba masu haɓaka damar haɗa ayyukan jujjuya daftarin aiki ba tare da matsala ba cikin aikace-aikacen Python, suna ba da ƙaƙƙarfan tsarin kayan aikin don sauƙaƙe jujjuya takaddun Kalma zuwa hotuna JPG.
Bayan Kalma zuwa JPG jujjuya, wannan SDK yana ba da ɗimbin iyakoki. Kuna iya sarrafa da tsara takaddun Word da ƙarfi, cire rubutu, amfani da alamun ruwa, yin kwatancen daftarin aiki, har ma da samar da samfoti na takarda.
Ana samun SDK don saukewa a PIP da GitHub. Yi umarni mai zuwa akan tashar layin umarni don shigar da SDK
pip install aspose-words-cloud
Da zarar an gama shigarwa, kuna buƙatar ƙirƙirar asusu akan Aspose.Cloud dashboard. Idan kuna da asusun GitHub ko Google, kawai Yi rajista ko, danna maɓallin Ƙirƙiri sabon Asusu kuma samar da bayanan da ake buƙata. Yanzu shiga cikin dashboard ta amfani da takaddun shaida kuma fadada sashin aikace-aikacen daga dashboard kuma gungura ƙasa zuwa sashin Shaidar Abokin ciniki don ganin bayanan Abokin ciniki da bayanan Sirrin Abokin ciniki.
Aspose.Cloud dashboard yana ba da hanya guda ɗaya don sarrafa ma’ajiyar fayiloli daban-daban, don haka kuna iya haɗa Amazon S3, DropBox, Google Drive Storage, Google Cloud Storage, Windows Azure Storage, da FTP Storage. Za mu iya sarrafa waɗannan hanyoyin ta amfani da zaɓin Adanawa da ke cikin menu na hagu akan dashboard.
Canza Kalma zuwa JPG a Python
Load da Takardun Kalma daga Ma’ajiyar gajimare
A cikin wannan sashe, za mu tattauna matakai kan yadda za a loda ma’ajin daftarin aiki a cikin tsohuwar ajiyar girgije da canza fitarwa zuwa tsarin JPEG. Hakanan ana adana fayil ɗin sakamakon a cikin ma’aji guda. A cikin wannan misalin, muna buƙatar saita zaɓin Ma’ajiyar Ciki (zaɓin farko kamar yadda aka nuna a hoton da ke sama). Da fatan za a bi matakan da aka bayar a ƙasa don yin aikin juyawa.
- Da farko, ƙirƙiri misali na ajin WordsApi yayin wucewar ClientID da cikakkun bayanan sirri na Client a matsayin muhawara.
- Na biyu, loda fayil ɗin PDF zuwa ma’ajiyar gajimare ta amfani da hanyar UploadFileRequest(..)
- Abu na uku, ƙirƙiri wani abu na GetDocumentWithFormatRequest yayin ƙaddamar da shigar da sunan fayil ɗin Kalma, tsarin fitarwa da ake so, da sunan fayil sakamakon azaman gardama.
- A ƙarshe, kira hanyar getdocumentwithformat(..) na ajin WordsApi don aiwatar da aikin juyawa.
# Don ƙarin samfurori, da fatan za a ziyarci https://github.com/aspose-words-cloud/aspose-words-cloud-python
import asposewordscloud
import asposewordscloud.models.requests
from asposewordscloud import ApiClient, WordsApi
from asposewordscloud.rest import ApiException
def main():
try:
# ƙirƙirar misali na WordsApi
words_api = WordsApi("6185429e-17ce-468d-bb81-a51ac9d96c16","73a07e2fb010f559e482d854fe5a8f49")
# Sunan rubutun shigar da kalmar
inputFileName = 'source.doc'
resultantFile = 'Converted.jpeg'
# Loda tushen daftarin aiki na Kalma zuwa Cloud Storage
words_api.upload_file(asposewordscloud.models.requests.UploadFileRequest(open('C:\\Users\\Downloads\\'+inputFileName, 'rb'), "", None))
# Ƙirƙiri abu don jujjuya daftarin aiki
request = asposewordscloud.models.requests.GetDocumentWithFormatRequest(inputFileName, "JPG", None, None, None,
None, resultantFile, None)
# fara Kalma zuwa JPEG aikin jujjuyawar
result = words_api.get_document_with_format(request)
# buga sakon a cikin na'ura mai kwakwalwa (na zaɓi)
print('Conversion process completed successfully !')
except ApiException as e:
print("Exception while calling WordsApi: {0}".format(e))
main()
Takardun Kalma daga Google Drive
A cikin wannan sashe, za mu tattauna cikakkun bayanai na yadda ake haɗa asusun Google Drive tare da dashboard Aspose.Cloud sannan za a loda daftarin aiki daga Google Drive iri ɗaya. Bayan jujjuyawar, sakamakon JPEG shima za’a adana shi zuwa wannan drive ɗin.
Don haka mataki na farko shine haɗa asusun Google Drive tare da asusun Aspose.Cloud Dashboard ɗin ku.
- Danna zaɓin Adana daga menu na hagu akan dashboard.
- Danna Ƙirƙirar Sabon Ma’ajiyar Maɓalli a Dama-Ƙasa na shafin.
- Zaɓi zaɓin Google Drive Storage daga menu.
- Shigar da Sunan Adanawa watau GDrive.
- Shigar da ID na Abokin ciniki da bayanan Sirrin Abokin ciniki daga na’urar wasan bidiyo na Google API.
- Sa’an nan danna Ƙirƙirar Refresh Token button kuma ba da izini ga asusun Google inda aka ƙirƙiri aikin Cloud. Da zarar an ba da duk cikakkun bayanai, allon zai bayyana kamar yadda aka nuna a ƙasa.
Muna ba da shawarar ziyartar hanyar haɗin yanar gizo zuwa Ƙarin koyo game da haɗa masu samar da ajiya na ɓangare na uku.
Mu kawai muna hulɗa tare da Aspose.Cloud APIs ta amfani da Aikace-aikacen da aka ƙirƙira akan dashboard na Aspose.Cloud kuma a bayan baya, kowane aikace-aikacen yana da ma’ajiyar alaƙa da shi. Don haka yanzu muna buƙatar sabunta bayanan Adanawa don aikace-aikacen da ke akwai.
Aiwatar da lambar da aka raba a sama kuma zai canza daftarin aiki da ke cikin Google Drive zuwa tsarin JPEG kuma ya adana shi zuwa ma’adana iri ɗaya.
Takardun Kalma daga Ma’ajiyar Dropbox
Hakanan zamu iya saita ma’ajiyar mu ta Dropbox tare da aikace-aikacen gajimare kuma muna iya sauya fayilolin Kalma da aka adana cikin ma’ajin Dropbox cikin sauƙi zuwa tsarin JPEG.
- Danna zaɓin Adana daga menu na hagu akan dashboard Aspose.Cloud.
- Danna Ƙirƙiri Sabon Ma’ajiyar Maɓallin kuma zaɓi Dropbox Storage daga menu.
- Shigar da sunan da kuka zaɓa a cikin filin Sunan Adanawa kuma danna Maɓallin Ƙirƙirar Token.
- Za a umarce ku don samar da cikakkun bayanan asusun ku na Dropbox kuma bayan an yi nasarar tabbatarwa, za a samar da alamar shiga.
- Danna maɓallin Ajiye.
Har ila yau, muna buƙatar sabunta bayanan ajiya don aikace-aikacen Cloud da muke samun dama a cikin lambar mu (ta hanyar ID na Abokin ciniki da takaddun shaidar Abokin ciniki). Yanzu danna zaɓin Fayilolin daga menu na hagu akan dashboard kuma zaɓi Dropbox Storage (sunan ajiya yana sama) kuma duk fayilolin da aka jera akan Dropbox za a nuna su.
A matakin lambar, ba ma buƙatar yin wani canji kuma lokacin da aka aiwatar da snippet code ɗin da aka raba a sama, ana loda sabon takaddar Kalma zuwa ajiyar Dropbox kuma sakamakon JPEG shima ana adana shi a cikin ajiya iri ɗaya. Duba hoton da ke ƙasa.
Ajiye Kalma cikin Hoto ta amfani da Umurnin CURL
Umarnin CURL ɗaya ne daga cikin ingantattun hanyoyin samun dama ga APIs REST ta hanzarin umarni. Tun da Aspose.Words Cloud kuma an haɓaka shi kamar yadda tsarin gine-gine na REST, don haka za mu iya samun dama gare shi ta umarnin cURL. Mun san cewa Aspose APIs ana samun dama ga masu izini kawai, don haka muna buƙatar samar da alamun samun damar JWT dangane da shaidar abokin ciniki. Da fatan za a aiwatar da umarni mai zuwa don samar da ɗaya:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=6185429e-17ce-468d-bb81-a51ac9d96c16&client_secret=73a07e2fb010f559e482d854fe5a8f49" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Yanzu aiwatar da umarnin cURL mai zuwa don canza daftarin aiki da ke akwai a cikin Ma’ajin gajimare zuwa tsarin JPEG. Hakanan ana adana fayil ɗin da aka samo a cikin ma’ajiyar girgije iri ɗaya.
curl -X GET "https://api.aspose.cloud/v4.0/words/source.doc?format=JPEG&outPath=Converted.jpeg" \
-H "accept: application/octet-stream" \
-H "Authorization: Bearer <JWT Token>"
Tunda an haɗa Dropbox azaman ajiya na yanzu tare da Aspose.Cloud API, don haka ana ɗora source.doc daga Dropbox kuma ana adana sakamakon JPEG akan ma’ajiyar guda ɗaya.
Kammalawa
A cikin wannan labarin, mun bincika iyawar Aspose.Words Cloud akan yadda ake canza Kalma zuwa JPG ta amfani da Python. Mun kuma tattauna matakan yin amfani da ma’ajiyar girgije daban-daban da ake da su, gami da Google Drive da Dropbox. Mun kuma bincika zaɓin yadda ake adana daftarin aiki azaman JPEG ta amfani da umarnin CURL. Da fatan za a lura cewa SDK ɗinmu an haɓaka su ta hanyar lasisin MIT, don haka cikakkiyar lambar tushen su tana nan don saukewa akan Github. Idan kun ci karo da wata matsala, ko kuna da wasu ƙarin tambayoyi, da fatan za ku ji daɗin tuntuɓar mu ta Zauren Tallafin samfur na Kyauta.
Labarai masu alaka
Muna ba da shawarar ku ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da