cire shafukan pdf

Cire Shafukan PDF ta amfani da NET REST API.

Don ingantacciyar isar da bayanai, fayil ɗin da aka ƙera a hankali PDF yana aiki azaman ma’auni na daidaito da dacewa. Koyaya, buƙatar cire takamaiman shafuka daga PDF galibi yana tasowa saboda dalilai da yawa. Wataƙila kana buƙatar kawar da bayanan da ba su da yawa, gyara kurakurai, ko ƙirƙirar ƙaƙƙarfan sigar takarda. Wataƙila kun sami cikakken rahoto, amma wani yanki ne kawai nasa ya dace da bukatunku. A irin waɗannan lokuta, ikon cire shafuka ta hanyar tiyata ba kawai saukakawa ba ne amma wajibi ne. Wannan labarin yana bincika dalilai daban-daban masu tursasawa da ke bayan buƙata kuma yana gabatar muku da ingantattun hanyoyi don cimma ta ta amfani da .NET REST API.

API ɗin REST don Cire Shafukan PDF

Cire shafuka daga takaddun PDF tsari ne mai tsauri tare da Aspose.PDF Cloud SDK don NET. Ko kuna buƙatar kawar da shafukan da ba su da yawa ko kuma datsa takarda zuwa sassan da suka fi dacewa, wannan SDK yana sauƙaƙa aikin. Madaidaicin SDK yana tabbatar da cewa an kawar da shafukan da aka yi niyya kawai, yana barin ku da takaddun PDF mai inganci da mai da hankali.

Yanzu, mataki na farko shine ƙara bayanin SDK a cikin aikinmu kuma don wannan dalili, da fatan za a bincika ‘Aspose.PDF-Cloud’ a cikin manajan fakitin NuGet a cikin IDE Studio Visual kuma danna maɓallin ‘Ƙara Kunshin’. Hakanan kuna buƙatar 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.

Cire Shafukan PDF ta amfani da C# .NET

Cire shafuka daga takaddun PDF an yi su maras kyau tare da Aspose.PDF Cloud SDK don NET. Bari mu bincika snippet code don kawar da shafukan PDF ta amfani da C# .NET.

// 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 kawar da shafin PDF a index 1
var response = pdfApi.DeletePage("Converted-PDF_A.pdf", 1);

// buga saƙon nasara, idan an kammala aikin cikin nasara 
if (response != null && response.Status.Equals("OK"))
{
    Console.WriteLine("Operation to eliminate PDF pages completed successfully !");
    Console.ReadKey();
}
kawar da shafukan PDF

Duban aikin share shafin PDF.

An bayar a ƙasa akwai cikakkun bayanai game da snippet na sama da aka bayyana.

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.DeletePage("Converted-PDF_A.pdf", 1);

Yanzu, kira API don cire shafin a farkon fihirisar kuma adana fitarwa zuwa ma’ajiyar girgije.

Share Shafuka a cikin PDF ta amfani da Umarnin CURL

Kawar da takamaiman shafuka daga takaddun PDF ta amfani da Aspose.PDF Cloud da umarnin cURL tsari ne mai sauƙi da inganci. Tare da Aspose.PDF Cloud’s RESTful API, zaku iya aika buƙatun HTTP cikin sauƙi don cire takamaiman shafuka daga PDF. Ta hanyar amfani da hanyar ‘DELETE’ akan takamaiman shafi ko kewayon shafuka, ana iya cire abun cikin da ba’a so ta hanyar tiyata.

Mataki na farko na wannan hanyar shine ƙirƙirar alamar samun damar JWT. Don haka, 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=163c02a1-fcaa-4f79-be54-33012487e783&client_secret=c71cfe618cc6c0944f8f96bdef9813ac" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Da zarar an ƙirƙiri alamar JWT, da fatan za a aiwatar da wannan umarni don share shafuka a cikin takaddar PDF. Bayan nasarar kammalawa, ana adana daftarin aiki da aka sabunta a cikin ma’ajiyar girgije.

curl -v "https://api.aspose.cloud/v3.0/pdf/{sourcePDF}/pages/1" \
-X DELETE \
-H  "accept: application/json" \
-H  "authorization: Bearer {accessToken}"
-d {}

Sauya ‘sourcePDF’ tare da sunan shigar da takaddun PDF da ake samu a cikin ma’ajiyar gajimare, da ‘accessToken’ tare da alamar samun damar JWT da aka samar a sama.

Kammalawa

A ƙarshe, buƙatar cire shafuka daga takaddun PDF wani muhimmin al’amari ne na gyaran takaddun da keɓancewa. Duk hanyoyin biyu, ta yin amfani da Aspose.PDF Cloud SDK don NET da kuma yin amfani da Aspose.PDF Cloud tare da umarnin cURL, gabatar da ingantattun mafita don cimma wannan. SDK yana ba da cikakkiyar kayan aiki na abokantaka mai haɓakawa, yana ba da ikon sarrafawa daidai da haɗin kai mara kyau don cire takamaiman shafuka da tsari. A gefe guda, ta yin amfani da Aspose.PDF Cloud tare da umarnin cURL yana ba da sauƙi, hanya mai zaman kanta ta dandamali don fara cire shafi ta hanyar buƙatun HTTP masu sauƙi.

Hanyoyin haɗi masu amfani

Labarai masu alaka

Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: