C# REST API를 사용하여 PowerPoint에서 그림 추출

이 문서에서는 C# REST API를 사용하여 PowerPoint에서 그림을 추출하는 방법을 안내합니다. .NET 기반 클라우드 SDK를 사용하여 C# REST 인터페이스가 포함된 PowerPoint에서 이미지를 자동으로 검색하는 방법을 알아봅니다. 모든 이미지를 추출하거나 프레젠테이션에서 선택한 이미지를 가져오는 세부 정보를 공유합니다.

전제조건

C# REST API를 사용하여 PowerPoint 사진을 추출하는 단계

  1. SlidesApi 개체를 초기화하여 클라이언트 ID와 비밀번호를 사용하여 사진을 추출합니다.
  2. 이미지가 포함된 PowerPoint 파일을 Aspose 클라우드 스토리지에 업로드하세요.
  3. DownloadImagesDefaultFormat() 방법을 사용하여 PowerPoint 프레젠테이션의 모든 이미지를 ZIP 파일로 다운로드하세요.
  4. 추출된 모든 이미지가 포함된 ZIP 파일을 로컬 저장소에 저장합니다.
  5. PowerPoint 프레젠테이션에서 단일 이미지 다운로드
  6. 추출된 단일 이미지를 로컬 저장소에 PNG 파일로 저장합니다.

다음 단계에서는 C# .NET 기반 API*를 사용하여 *PowerPoint 프레젠테이션 이미지를 가져오는 방법을 설명합니다. SlidesApi 개체를 초기화하고, 프레젠테이션을 서버에 업로드하고, API 응답에서 모든 이미지를 ZIP 스트림으로 다운로드하여 디스크에 저장합니다. 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
}
}
}
}

이 코드는 C# Low Code API를 사용하여 PowerPoint에서 그림을 추출하는 방법을 보여줍니다. DownloadImagesDefaultFormat() 메서드는 프레젠테이션 파일 이름을 가져와 로컬 저장소에 저장된 ZIP 스트림을 반환합니다. ZIP 파일의 모든 파일에는 기본 이미지 유형이 포함되어 있습니다.

이 기사에서는 C# REST 인터페이스를 사용하여 *PowerPoint 슬라이드 이미지를 추출하는 방법을 설명했습니다. 프레젠테이션에 워터마크를 추가하려면 C# REST API를 사용하여 PPT에 워터마크 추가 문서를 참조하세요.

 한국인