Aiwatar da sauri da sauƙi don haɗa hotuna JPG akan layi.
Tsarin hoton raster (JPG, PNG, GIF, PNG da sauransu) sune shahararrun tsarin raba bayanan hoto. Yawancin na’urorin da suka haɗa da kyamarori na zamani da wayoyin hannu suna samar da kayan aiki kai tsaye a ɗayan waɗannan nau’ikan. Kowane hoto an adana shi daban kuma daga yanayin raba bayanai, ana raba shi tsakanin masu amfani. Koyaya, ƙila mu sami buƙatu don raba hotuna da yawa tare ko haɗa hotunan da suka daɗe kuma mu raba su azaman hoton raster guda ɗaya. Don wannan dalili, ana samun software na kasuwanci amma suna haifar da shigarwa da farashin lasisi.
Don haka idan kawai abin da ake buƙata shine haɗa hotunan JPG, to me yasa kuke ciyar da lokaci mai yawa akan saitin software kuma ku biya ƙarin kuɗin cikakken lasisi na aiki ɗaya. Hakanan, yawancin aikace-aikacen suna samuwa don tsarin tebur, kuma idan kuna buƙatar aiwatar da ayyukan akan na’urorin hannu, yana samun rikitarwa sosai. Sabili da haka, don haɓaka mafita mai zaman kanta na dandamali wanda zai samar da ingantaccen ƙwarewar mai amfani, Cloud REST API wata hanya ce mai dacewa. A cikin wannan labarin, za mu ƙara tattauna cikakkun bayanai game da yadda ake aiwatar da haɗin JPG ta amfani da C# REST API.
Bayani: Aspose kwanan nan ya ƙirƙira wani Collage app wanda ke ba ku damar haɗa hotunan JPG ko haɗa hotuna akan layi akan grid.
API ɗin Canjin PDF
Aspose yana ba da plethora na APIs masu sarrafa daftarin aiki kuma Aspose.PDF Cloud yana ɗaya daga cikin manyan APIs waɗanda ke ba da damar ƙirƙira tare da sarrafa takaddun PDF. Domin sauƙaƙe masu shirye-shirye ta hanyar amfani da C# .NET, mun ƙirƙiri Aspose.PDF Cloud SDK don NET wanda ke kewaye da Cloud API. Domin amfani da SDK, mataki na farko shine shigar da shi akan tsarin. Ana samun SDK akan NuGet da GitHub.
Da fatan za a aiwatar da umarni mai zuwa akan tashar don shigar da SDK daga NuGet
Install-Package Aspose.Pdf-Cloud
Kuna iya la’akari da ziyartar hanyar haɗin yanar gizon don ƙarin cikakkun bayanai akan Yadda ake shigar da Aspose.Cloud SDKs.
Koyaya, kafin ci gaba, mataki na farko shine ƙirƙirar asusu ta ziyartar Aspose.Cloud dashboard. Idan kuna da asusun GitHub ko Google, kawai Yi rajista. In ba haka ba, 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.
Haɗa JPG cikin C#
Aspose.PDF Cloud yana ba da damar iyawa don Ƙirƙiri PDF mara kyau, Ƙara sabon Hoto zuwa Takardun PDF, da Mayar da Shafukan Takaddun Takaddun zuwa Tsarin Hoto. Don haka don haɗa JPG akan layi, da fatan za a bi umarnin da aka bayar a ƙasa
- Da farko, ƙirƙiri wani abu na PdfApi yayin wuce ClientID da cikakkun bayanan sirrin Client.
- Na biyu, kira hanyar PutCreateDocument(…) na ajin PdfApi don ƙirƙirar takaddar PDF mara kyau.
- Yanzu kira PostInsertImage(..) wanda ke ɗaukar shigar da sunan fayil na PDF, PageNumber, daidaitawar XY, da sunan fayil ɗin hoto azaman muhawara.
- Maimaita hanyar don ƙara ƙarin hotuna
- A ƙarshe, kira hanyar PutPageConvertToJpeg(…) don canza fayilolin PDF zuwa hotuna JPEG da adana fitarwa a cikin ma’ajin gajimare.
string clientID = "718e4235-8866-4ebe-bff4-f5a14a4b6466"; // Get ClientID from https://dashboard.aspose.cloud/
string clientSecret = "388e864b819d8b067a8b1cb625a2ea8e"; // Get CLientSecret from https://dashboard.aspose.cloud/
// sunan fayil don ƙirƙirar PDF
String fileName = "input.pdf";
// ƙirƙirar misali na PdfApi
PdfApi pdfApi = new PdfApi(clientSecret, clientID);
// Kira Aspose.PDF Cloud SDK API don ƙirƙirar fayil ɗin pdf mara komai
DocumentResponse apiResponse = pdfApi.PutCreateDocument(fileName);
// lambar shafi na fayil ɗin PDF
int pageNumber = 1;
// Saka hoto na 1 a cikin PDF akan ƙayyadaddun abubuwan haɗin gwiwa
// Masu haɗin gwiwar suna cikin Point suna farawa daga ƙasa-hagu zuwa sama-dama
pdfApi.PostInsertImage(fileName, pageNumber, 10, 850, 310, 650, "Flower-Backgrounds.jpg");
// Saka hoto na 2 a cikin PDF akan ƙayyadaddun abubuwan haɗin gwiwa
pdfApi.PostInsertImage(fileName, pageNumber, 320, 850, 600, 650, "png-vs-jpeg.jpg");
// Saka hoto na 3 a cikin PDF akan ƙayyadaddun abubuwan haɗin gwiwa
pdfApi.PostInsertImage(fileName, pageNumber, 10, 620, 310, 420, "purple_flowers_201054.jpg");
// Saka hoto na 4 a cikin PDF akan ƙayyadaddun abubuwan haɗin gwiwa
pdfApi.PostInsertImage(fileName, pageNumber, 320, 620, 600, 420, "Forest.jpg");
// canza fayil ɗin PDF zuwa tsarin JPEG kuma adana akan ma'ajiyar gajimare
var finalResponse = pdfApi.PutPageConvertToJpeg(fileName,pageNumber,"FinalConverted.jpeg");
if (finalResponse != null && finalResponse.Status.Equals("OK"))
{
Console.WriteLine("PDF Converted to JPEG, Done!");
Console.ReadKey();
}
Haɗa JPG ta amfani da Umarnin CURL
Umarnin CURL hanya ce mai ban sha’awa da dacewa don samun dama ga REST APIs ta hanzarin umarni akan kowane dandamali kuma suna ba da ƙwarewa iri ɗaya. Don haka za mu iya cimma aikin haɗin gwiwar JPEG ta hanyar umarnin cURL.
Domin amfani da umarnin cURL, mataki na farko shine samar da alamar shiga JWT. Yi amfani da umarni mai zuwa don samar da alamar da ake buƙata. Don ƙarin bayani, da fatan za a ziyarci [Yadda ake samun alamar JWT ta amfani da ID na Abokin ciniki da maɓallin Sirrin Abokin ciniki22.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=718e4235-8866-4ebe-bff4-f5a14a4b6466&client_secret=388e864b819d8b067a8b1cb625a2ea8e" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Mataki na gaba shine ƙirƙirar takaddar PDF mara kyau.
curl -X PUT "https://api.aspose.cloud/v3.0/pdf/Sample.pdf" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
curl -X POST "https://api.aspose.cloud/v3.0/pdf/Sample.pdf/pages/1/images?llx=10&lly=850&urx=310&ury=650&imageFilePath=Flower-Backgrounds.jpg" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: multipart/form-data" \
-d {"image":{}}
Maimaita mataki guda don saka wasu hotuna tare da daidaitawa daban-daban. A ƙarshe, canza fayil ɗin PDF zuwa Tsarin Hoto ta amfani da umarni mai zuwa.
curl -X PUT "https://api.aspose.cloud/v3.0/pdf/Sample.pdf/pages/1/convert/jpeg?outPath=output.jpeg&width=0&height=0" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
Samfurin PDF da hoton sakamakon da aka samar an haɗe su a ƙasa.
Kammalawa
Wannan labarin ya bayyana matakai / cikakkun bayanai kan yadda ake yin aikin haɗin gwiwar JPG akan layi. Mun kuma koyi cikakkun bayanai don haɗa hotunan JPG ta amfani da umarnin cURL. Yanzu ban da abubuwan da aka ambata a sama, API ɗin kuma yana iya yin wasu abubuwa masu ban mamaki kuma ana iya samun cikakkun bayanan su a cikin Aspose.PDF Cloud Features da Bayyana sassan.
Idan kun ci karo da kowace matsala yayin amfani da API, da fatan za ku ji daɗin tuntuɓar Zauren tallafin samfur kyauta. Muna kuma ba da shawarar ziyartar shafukan yanar gizo masu zuwa don bayani akan