A cikin duniyar dijital ta mu, inda bayanai ke gudana ba tare da wata matsala ba a ko’ina cikin dandamali, buƙatar canza hotunan JPG zuwa takaddun Kalma ya zama muhimmiyar larura. Ka yi tunanin kana da tarin takardu da aka buga, tsohon kundi na hoto na iyali, ko ma wani muhimmin rahoto da aka adana azaman hotunan JPG. Don haka a cikin wannan labarin, za mu shiga cikin buƙatu mai ƙarfi da fa’idodin [JPG] (https://docs.fileformat.com/image/jpeg/) zuwa Takardun Magana .com/word-processing/) jujjuya, yana ba da haske kan yadda wannan canjin ke baiwa mutane, kasuwanci damar buɗewa da amfani da juyar da Hoto zuwa Kalma.
- API ɗin REST zuwa Ƙarshen Takardun Kalma
- Canza JPG zuwa Takardun Kalma a cikin C# .NET
- JPG zuwa DOC ta amfani da Umarnin CURL
API ɗin REST zuwa Ƙarshen Takardun Kalma
Buɗe yuwuwar jujjuyawar ‘JPG zuwa Word’ cikin sauƙi mai sauƙi ta amfani da Aspose.Words Cloud SDK don NET. Wannan madaidaicin API ɗin REST ba kawai yana daidaita tsarin canji ba har ma yana ba da fa’idodi masu yawa waɗanda ke haɓaka gabaɗayan ƙwarewar samarwa da sarrafa takaddun Kalma.
Domin ƙara bayanin NET REST a cikin aikin, da fatan za a bincika ‘Aspose.Words-Cloud’ a cikin manajan fakitin NuGet kuma danna maɓallin ‘Ƙara Kunshin’. Bugu da ƙari, da fatan za a ziyarci cloud dashboard kuma sami keɓaɓɓen takaddun shaidar abokin ciniki.
Canza JPG zuwa Takardun Kalma a cikin C# .NET
Wannan sashe yana bayyana cikakkun bayanai kan yadda ake canza JPG zuwa Word C# .NET.
// Don cikakkun misalai da fayilolin bayanai, da fatan za a je zuwa
https://github.com/aspose-words-cloud/aspose-words-cloud-dotnet
// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";
// ƙirƙira abin daidaitawa ta amfani da ClientID da ClientSecret cikakkun bayanai
var config = new Aspose.Words.Cloud.Sdk.Configuration { ClientId = clientID, ClientSecret = clientSecret };
// fara misali WordsApi
var wordsApi = new WordsApi(config);
// ƙirƙirar misali na sabon takaddar Kalma
CreateDocumentRequest createRequest = new CreateDocumentRequest("input.docx", null, null);
// ƙirƙiri daftarin kalma mara komai kuma adana cikin ma'ajin gajimare
wordsApi.CreateDocument(createRequest);
// ƙirƙirar Abun Zana
DrawingObjectInsert requestDrawingObject = new DrawingObjectInsert();
// saita bayanin tsayi don zane abu
requestDrawingObject.Height = 0;
// saita bayanan gefen hagu don zana abu
requestDrawingObject.Left = 0;
// saita manyan bayanan gefe don zana abu
requestDrawingObject.Top = 0;
// saita bayanin faɗi don zane abu
requestDrawingObject.Width = 0;
// saita jeri a kwance don misalin zane
requestDrawingObject.RelativeHorizontalPosition= DrawingObjectInsert.RelativeHorizontalPositionEnum.Margin;
// saita jeri tsaye don misali zane
requestDrawingObject.RelativeVerticalPosition = DrawingObjectInsert.RelativeVerticalPositionEnum.Margin;
// saita nau'in kunsa cikakkun bayanai azaman Layin layi
requestDrawingObject.WrapType = DrawingObjectInsert.WrapTypeEnum.Inline;
// karanta shigar da hoton JPG
using var sourceImage = File.OpenRead("Landscape.jpg");
// ƙirƙiri misali zuwa SakaDrawingObject da ke ma'anar kumburi inda za'a sanya abu Zane
InsertDrawingObjectRequest request = new InsertDrawingObjectRequest("input.docx", requestDrawingObject,
sourceImage, "sections/0", null, null, null, null, null, "Resultant.docx", null, null);
// saka abin zana riqe da hoton JPG a cikin takaddar Word
wordsApi.InsertDrawingObject(request);
Yanzu, bari mu bincika wasu bayanai game da snippet code da aka bayyana a sama.
var config = new Configuration { ClientId = clientID, ClientSecret = clientSecret };
WordsApi wordsApi = new WordsApi(config);
Da fari dai, mun ƙirƙiri misali na ajin ‘WordsApi’ yayin da muke wuce bayanan abokin ciniki azaman mahawara.
CreateDocumentRequest createRequest = new CreateDocumentRequest("input.docx", null, null);
wordsApi.CreateDocument(createRequest);
Yanzu mun ƙirƙiri daftarin rubutu mara kyau mai suna input.docx.
DrawingObjectInsert requestDrawingObject = new DrawingObjectInsert();
Ƙirƙirar abin Zane kuma saita gefensa na sama da na hagu zuwa 0. Haka nan, domin JPG ya rufe dukkan ma’aunin shafin, saita ƙimar tsayi da faɗinsa zuwa 0.
InsertDrawingObjectRequest request = new InsertDrawingObjectRequest("input.docx", requestDrawingObject,
sourceImage, "sections/0", null, null, null, null, null, "Resultant.docx", null, null);
Ƙirƙiri abin buƙatar saka DrawingObject inda muka wuce shigar da babu sunan takaddar Kalma, shigar da rafin hoto na JPG, bayanin sashin rubutun kalma azaman 0 da sunan sakamakon daftarin Kalma.
wordsApi.InsertDrawingObject(request);
A ƙarshe, kira API don sanya hoton a cikin takaddar Kalma kuma adana fayil ɗin fitarwa zuwa ma’ajiyar girgije.
JPG zuwa DOC ta amfani da Umarnin CURL
A matsayin madadin, ƙila za ku iya samun canji maras kyau na hotuna JPG zuwa fayilolin Word DOC ta amfani da haɗin kai mai ƙarfi na Aspose.Words Cloud da umarnin cURL. Kamar yadda umarnin cURL ya ba da hanyar abokantaka da mai amfani da shirye-shirye don fara jujjuyawar, Aspose.Words Cloud yana ƙara haɓakar haɓakawa ga tsarin. Don haka, wannan haɗin kai ba wai yana sauƙaƙe jujjuyawar ‘Hoto zuwa Kalma’ kaɗai ba, har ma yana kawo ɗimbin sauran fa’idodi don haɓaka tsarin sarrafa takaddun Kalma.
Mataki na farko a cikin wannan hanyar shine samar da alamar samun damar JWT ta aiwatar da umarni mai zuwa:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Da zarar muna da alamar JWT, da fatan za a aiwatar da umarni mai zuwa don ƙirƙirar daftarin aiki mara kyau.
curl -v -X PUT "https://api.aspose.cloud/v4.0/words/create?fileName=input.docx" \
-H "accept: application/json" \
-H "Authorization: Bearer <JWT Token>"
Mataki na gaba shine saka hoton a cikin sabuwar takaddar Word da aka ƙirƙira.
curl -v -X POST "https://api.aspose.cloud/v4.0/words/{sourceFile}/sections/0/drawingObjects?destFileName={outputFile}" \
-H "accept: application/json" \
-H "Authorization: Bearer <JWT Token>" \
-H "Content-Type: multipart/form-data" \
-d {"drawingObject":"{ \"RelativeHorizontalPosition\": \"Margin\", \"Left\": 0, \"RelativeVerticalPosition\": \"Margin\", \"Top\": 0, \"Width\": 0, \"Height\": 0, \"WrapType\": \"Inline\"}","imageFile":{"Tulips.jpg"}}
Kawai maye gurbin ‘sourceFile’ tare da sunan shigar da ba komai a cikin takaddar Kalma da aka ƙirƙira a matakin baya. Hakanan, maye gurbin ‘fitarwa’ tare da sunan sakamakon daftarin aiki da za a ƙirƙira.
Kammalawa
Mun koyi cewa jujjuya daga hotuna JPG zuwa takaddun Kalma abu ne mai mahimmanci a zamanin mu na dijital. Yana buɗe duniyar yuwuwar sarrafa abun ciki da gyarawa. A cikin wannan labarin, mun bincika hanyoyi biyu masu ƙarfi don cimma wannan canji: ɗayan yana amfani da Aspose.Words Cloud SDK don NET, ɗayan kuma yana ba da ikon Aspose.Words Cloud tare da umarnin cURL.
Duk hanyoyin biyu a ƙarshe sun haɗu da tazara tsakanin hotuna masu tsattsauran ra’ayi da takaddun Kalma masu ɗorewa, haɓaka hanyar sarrafa, gyara, da raba abun ciki na dijital. Ko kun fi son sophistication na SDK ko kuma sauƙin umarnin cURL, hanyoyin biyu suna ba da mafita mai canzawa don haɓaka ‘hoton JPG zuwa mai sauya Kalma’.
Hanyoyin haɗi masu amfani
Labarai masu alaka
Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: