PDF zuwa PNG

Maida PDF zuwa PNG tare da NET REST API.

Buɗe sabon matakin haɓakawa da tasirin gani ta hanyar canza fayilolinku PDF zuwa PNG hotuna. Haɓaka mai duba PDF ta kan layi ta amfani da ikon samar da hotuna masu inganci daga takaddun PDF. Matakai masu sauƙi da sauƙi don ƙirƙirar abubuwan gani masu ban sha’awa, raba abun ciki cikin sauƙi, da haɓaka ayyukan dijital ku zuwa mataki na gaba. Don haka, idan kuna neman nuna takamaiman shafuka, adana ingancin hoto, ko haɓaka daidaituwa a cikin dandamali, canza PDF zuwa PNG yana buɗe sabuwar duniyar yuwuwar. A cikin wannan labarin, za mu bincika yadda za ku iya yin amfani da ikon .NET REST API don jujjuyawar PDF zuwa PNG mara kyau don ƙarin ƙarfi da hanyar gani.

API ɗin Processing REST

Aspose.PDF Cloud SDK for .NET yana ba da ingantaccen bayani mai ƙarfi da aminci don canza PDF zuwa PNG. SDK yana ba da cikakkun tsarin hanyoyin da zaɓuɓɓuka don keɓance jujjuyawa gwargwadon buƙatunku. Ko kuna son cire takamaiman shafuka, saita ƙudurin hoto, ko daidaita ingancin hoto, Aspose.PDF Cloud SDK yana ba da sassauci da sarrafawa don cimma sakamakon da kuke so. Yin amfani da kayan aikin girgije, wannan SDK yana tabbatar da sauri da ingantaccen aiki, yana ba ku damar canza PDF zuwa PNG cikin sauƙi.

Yanzu, kawai bincika ‘Aspose.PDF-Cloud’ a cikin manajan fakitin NuGet a cikin Visual Studio IDE kuma danna maɓallin ‘Ƙara Kunshin’. Matakai masu mahimmanci na gaba shine samun takaddun shaidar abokin ciniki daga cloud dashboard. Idan ba ku da asusun da ke akwai, kawai ƙirƙiri asusun kyauta ta bin umarnin da aka kayyade a kan saurin farawa.

PDF zuwa PNG ta amfani da C# .NET

Bari mu bincika cikakkun bayanai da snippet code don cika buƙatun canza PDF zuwa tsarin PNG. Da fatan za a gwada amfani da snippet code mai zuwa don canza PDF zuwa hotuna PNG.

// Don ƙarin misalai, https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-dotnet/tree/master/Examples

// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";

// ƙirƙirar misali na PdfApi
PdfApi pdfApi = new PdfApi(clientSecret, clientID);

// Shigar da sunan fayil na PDF
String inputFile = "Binder1-1.pdf";

// Kira API don canza shafi na 1 na PDF zuwa hoton PNG
var response = pdfApi.GetPageConvertToPng(inputFile, 1, width: 800, height: 1000);

// Hanyar al'ada don adana sakamakon PNG akan faifan gida
saveToDisk(response, "/Users/nayer/Downloads/Convertednew.png");

// Hanya don adana abun ciki na rafi zuwa fayil akan faifan gida
public static void saveToDisk(Stream responseStream, String resultantFile)
{
    var fileStream = File.Create(resultantFile);
    responseStream.Seek(0, SeekOrigin.Begin);
    responseStream.CopyTo(fileStream);
    fileStream.Close();
}

An ba da cikakkun bayanai game da snippet code na sama.

PdfApi pdfApi = new PdfApi(clientSecret, clientID);

Da fari dai, ƙirƙiri wani abu na ajin PdfApi yayin ƙaddamar da bayanan abokin ciniki azaman mahawara ta shigarwa.

var response = pdfApi.GetPageConvertToPng(inputFile, 1, width: 800, height: 1000);

Kira API don loda fayil ɗin PDF daga ma’ajin gajimare kuma canza shafi na 1 zuwa tsarin PNG.

saveToDisk(response, "/Users/nayyer/Downloads/Converted.png");

Hanyar mu ta al’ada don adana sakamakon PNG zuwa tuƙi na gida.

canza pdf zuwa png

PDF zuwa PNG preview preview.

Ana iya saukar da takaddar PDF da aka yi amfani da ita a cikin misalin da ke sama daga Binder1.pdf .

Maida PDF zuwa PNG Kan layi ta amfani da Umarnin CURL

Hakanan zamu iya cim ma fassarar PDF zuwa PNG ta amfani da umarnin cURL da Aspose.PDF Cloud API. Tare da cURL, za mu iya yin buƙatun HTTP kai tsaye zuwa wuraren ƙarshen API ta hanyar samar da ma’auni masu mahimmanci da takaddun shaida. Wannan tsarin yana ba da sassauci da sauƙi, yana ba mu damar haɗa PDF zuwa fassarar PNG ba tare da ɓata lokaci ba cikin ayyukanku na yau da kullun ko aikace-aikacenku.

Mataki na farko na wannan hanyar shine ƙirƙirar alamar samun damar JWT. Da fatan za a 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"

Yanzu, da fatan za a aiwatar da umarni mai zuwa don canza shafi na biyu na fayil ɗin PDF zuwa tsarin PNG kuma adana abin fitarwa akan tuƙi na gida.

curl -v "https://api.aspose.cloud/v3.0/pdf/{inputFile}/pages/2/convert/png?width=800&height=1000" 
\ -X GET \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer {accessToken}" \
-o "converter.png"

Sauya ‘inputFile’ tare da sunan shigar da takaddun PDF da ke cikin ma’ajiyar girgije, da ‘accessToken’ tare da alamar samun damar JWT da aka samar a sama.

Kammalawa

A ƙarshe, juyar da PDF zuwa PNG abu ne mai mahimmanci wanda ke ba ku damar canza shafukan PDF zuwa hotuna PNG. Ko kun zaɓi yin amfani da Aspose.PDF Cloud SDK don NET ko umarnin cURL tare da Aspose.PDF Cloud API, duka hanyoyin suna ba da ingantacciyar mafita kuma abin dogaro. Tare da SDK, kuna da damar yin amfani da cikakken saitin fasali da ayyuka, sauƙaƙe tsarin jujjuyawa da ba da ƙarin damar aiki tare da fayilolin PDF. A gefe guda, umarnin cURL yana ba da sassauci da damar haɗin kai, yana ba da damar aiki da kai mara kyau da haɗin kai cikin ayyukan aiki na yanzu.

Ko wace hanya kuka zaɓa, Aspose.PDF Cloud API yana ba ku ikon canza PDF zuwa PNG ba tare da wahala ba kuma yana buɗe yuwuwar sarrafa takaddun PDF.

Hanyoyin haɗi masu amfani

Labarai masu alaka

Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: