C# REST API를 사용하여 PowerPoint에 하이퍼링크를 추가하는 방법에 대한 이 가이드를 따르세요. 프레젠테이션 작업을 위한 모든 고급 기능을 지원하는 .NET 기반 Cloud SDK를 사용하여 C# RESTful 서비스로 PowerPoint에 하이퍼링크를 자동으로 삽입하는 방법을 배웁니다. 사용자 정의 하이퍼링크를 추가하기 위해 특정 슬라이드와 모양을 선택하는 데 도움이 됩니다.
전제조건
다운로드 Aspose.Slides Cloud SDK for Dotnet for inserting hyperlinks
위 SDK로 C# 프로젝트를 설정하여 셰이프에 링크를 추가합니다.
C# .NET 기반 API를 사용하여 PowerPoint에 링크를 추가하는 단계
- 인증을 위해 API 키와 비밀번호를 사용하여 SlidesApi를 인스턴스화합니다.
- 입력 파일을 메모리 스트림으로 읽고 업로드합니다.
- 하이퍼링크 추가를 위한 슬라이드 및 도형의 인덱스 설정(1 기반 인덱스)
- 하이퍼링크가 있는 모양 개체 만들기
- Update 하이퍼링크가 있는 지정된 슬라이드의 도형
- 확인을 위해 업데이트된 하이퍼링크의 URL을 콘솔에 인쇄합니다.
- 업데이트된 프레젠테이션을 클라우드에서 스트림으로 다운로드하고 디스크에 저장하세요.
이 단계에서는 C# REST API를 사용하여 PowerPoint에 하이퍼링크를 추가하는 방법을 설명합니다. 동작 유형과 외부 URL을 정의하여 Shape를 생성하고 하이퍼링크를 추가할 수 있습니다. 마지막으로 새로 생성된 모양을 사용하여 원하는 슬라이드의 대상 모양을 업데이트하고 필요한 경우 출력을 디스크에 저장합니다.
C# 로우 코드 API를 사용하여 PowerPoint에 링크를 삽입하는 코드
using Aspose.Slides.Cloud.Sdk; // Import the Aspose.Slides Cloud SDK to work with PowerPoint presentations. | |
using Aspose.Slides.Cloud.Sdk.Model; // Import models used by the SDK. | |
using System; // Import the System namespace for basic functionalities. | |
using System.IO; // Import System.IO for file input/output operations. | |
namespace AsposeTestCodes | |
{ | |
class Program | |
{ | |
static void Main(string[] args) // Main method - the program's entry point. | |
{ | |
// Instantiate the SlidesApi with the API key and secret for authentication. | |
SlidesApi slidesApi = new SlidesApi("Client ID", "Client Secret"); | |
// Name of the PowerPoint file to work with. | |
string fileName = "PresentationWithoutHyperlink.pptx"; | |
// Read the file into a memory stream and upload it to the Aspose.Slides cloud storage. | |
FilesUploadResult uploadedPresResult = slidesApi.UploadFile(fileName, new MemoryStream(File.ReadAllBytes(fileName))); | |
// Index of the slide and shape where the target shape is located (1-based index). | |
int slideIndex = 2, shapeIndex = 2; | |
Shape shape = new Shape // Create a shape object with a hyperlink | |
{ | |
HyperlinkClick = new Hyperlink | |
{ | |
ActionType = Hyperlink.ActionTypeEnum.Hyperlink, // Set the action type as a hyperlink. | |
ExternalUrl = "https://docs.aspose.cloud/slides" // The URL for the hyperlink. | |
} | |
}; | |
// Update the shape on the specified slide with the hyperlink. | |
ShapeBase updatedShpWithHyperlink = slidesApi.UpdateShape(fileName, slideIndex, shapeIndex, shape); | |
// Print the updated hyperlink's URL to the console for verification. | |
Console.WriteLine(updatedShpWithHyperlink.HyperlinkClick.ExternalUrl); | |
// Download the updated presentation from the cloud as a stream. | |
Stream stream = slidesApi.DownloadFile(fileName); | |
// Save the downloaded presentation to the local file system with a new name. | |
var fs = new FileStream("PresWithHyperlinks.pptx", FileMode.Create, FileAccess.Write); | |
stream.CopyTo(fs); // Copy the content from the stream to the file. | |
} | |
} | |
} |
이 코드는 C# REST 인터페이스를 사용하여 PowerPoint에 하이퍼링크를 삽입하는 방법을 보여줍니다. 하이퍼링크, 도구 설명, 기록, 강조 표시 클릭 및 클릭 시 사운드 중지를 활성화/비활성화하는 플래그와 같은 하이퍼링크의 다양한 속성을 설정할 수 있습니다. 이러한 모든 속성은 하이퍼링크를 클릭하는 대신 하이퍼링크 위로 마우스를 가져가면 사용할 수 있습니다.
이 문서에서는 C# Low Code API*를 사용하여 PowerPoint에서 *하이퍼링크를 만드는 방법을 설명했습니다. 슬라이드에 SmartArt를 추가하려면 C# REST API를 사용하여 PowerPoint에 SmartArt 추가의 문서를 참조하세요.