Այս հոդվածը ցույց է տալիս, թե ինչպես արտահանել նկարներ PowerPoint-ից C# REST API-ով: Դուք կսովորեք ավտոմատ կերպով առբերել պատկերները PowerPoint-ում C# REST ինտերֆեյսով՝ օգտագործելով .NET-ի վրա հիմնված ամպային SDK-ն: Այն կկիսվի մանրամասներ՝ բոլոր պատկերները հանելու կամ ներկայացումից ընտրված պատկերները վերցնելու համար:
Նախապայման
[Ստեղծել հաշվի API հավատարմագրեր] ( https://kb.aspose.cloud/ hy/total/net/how-to-create-aspose-cloud-apis-account/)
Բեռնել Aspose.Slides Cloud SDK for Dotnet to retrieve images from the presentation
Կարգավորեք C# նախագիծը վերը նշված SDK-ով նկարներ հանելու համար
PowerPoint նկարներ հանելու քայլեր C# REST API-ով
- Նախաձեռնեք SlidesApi օբյեկտը
նկարներ հանելու համար
օգտագործելով Հաճախորդի ID-ն և գաղտնիքը - Վերբեռնեք PowerPoint ֆայլը պատկերներով Aspose ամպային պահեստում
- Ներբեռնեք PowerPoint ներկայացման բոլոր պատկերները ZIP ֆայլում՝ օգտագործելով DownloadImagesDefaultFormat() մեթոդը
- Պահպանեք ZIP ֆայլը, որը պարունակում է բոլոր արդյունահանված պատկերները տեղական պահեստում
- Ներբեռնեք մեկ պատկեր PowerPoint-ի շնորհանդեսից
- Պահպանեք արդյունահանված մեկ պատկերը որպես PNG ֆայլ տեղական պահեստում
Այս քայլերը նկարագրում են, թե ինչպես կարելի է ստանալ PowerPoint ներկայացման պատկերներ C# .NET-ի վրա հիմնված API-ով: Նախաձեռնեք SlidesApi օբյեկտը, վերբեռնեք ներկայացումը սերվեր, ներբեռնեք բոլոր պատկերները որպես ZIP հոսք API պատասխանից և պահեք դրանք սկավառակի վրա: Ցանկալի պատկերը ստանալու համար օգտագործեք DownloadImageDefaultFormat() մեթոդը՝ ներկայացնելով միայն պատկերի ինդեքսը:
Կոդ՝ C# RESTful ծառայության միջոցով ներկայացումներում նկարներ հանելու համար
// Importing the Aspose.Slides.Cloud.Sdk library to work with PowerPoint files in the cloud | |
using Aspose.Slides.Cloud.Sdk; | |
using System.IO; // Importing System.IO for file handling operations | |
namespace PresentationProcessor | |
{ | |
class ExtractImages | |
{ | |
static void Main(string[] args) | |
{ | |
// Creating an instance of the SlidesApi class using API credentials (API Key and App SID) | |
var slideService = new SlidesApi("API Key", "SID"); | |
// Defining the name of the input PowerPoint file | |
string inputFileName = "PresentationWithPics.pptx"; | |
// Uploading the PowerPoint file to Aspose cloud storage | |
var uploadResult = slideService.UploadFile(inputFileName, new MemoryStream(File.ReadAllBytes(inputFileName))); | |
// Downloading all images from the PowerPoint presentation in a ZIP file | |
var stream_zip = slideService.DownloadImagesDefaultFormat(name: "PresentationWithPics.pptx"); | |
// Saving the ZIP file containing all extracted images to the local storage | |
using (var fileStream = new FileStream("AllImages.zip", FileMode.Create, FileAccess.Write)) | |
{ | |
stream_zip.CopyTo(fileStream); // Copying the downloaded ZIP stream to a file | |
} | |
// Downloading a single image (indexed as 1) from the PowerPoint presentation | |
var singleImage = slideService.DownloadImageDefaultFormat(name: "PresentationWithPics.pptx", index: 1); | |
// Saving the extracted single image as a PNG file to the local storage | |
using (var fileStream = new FileStream("singleImage.png", FileMode.Create, FileAccess.Write)) | |
{ | |
singleImage.CopyTo(fileStream); // Copying the image stream to the file | |
} | |
} | |
} | |
} |
Այս կոդը ցույց է տալիս ինչպես նկարներ հանել PowerPoint-ից C# Low Code API-ով: DownloadImagesDefaultFormat() մեթոդը վերցնում է ներկայացման ֆայլի անունը և վերադարձնում ZIP հոսք, որը պահվում է տեղական պահեստում: ZIP ֆայլի բոլոր ֆայլերը պարունակում են նախնական պատկերի տեսակը:
Այս հոդվածը մեզ սովորեցրել է արդյունահանել PowerPoint սլայդների պատկերները C# REST ինտերֆեյսով: Ներկայացման մեջ ջրի մակարդակի նշագիծ ավելացնելու համար տես Ավելացրեք ջրի մակարդակի նշագիծ PPT-ին C# REST API-ով հոդվածը: