C# REST API ile PowerPoint bağlantısına nasıl köprü ekleneceğini öğrenmek için bu kılavuzu izleyin. Sunumlarla çalışmaya yönelik tüm gelişmiş özellikleri destekleyen .NET tabanlı bir Bulut SDK kullanarak C# RESTful Hizmeti ile PowerPoint’e otomatik olarak köprü eklemeyi öğreneceksiniz. Özel bir köprü eklemek için belirli bir slayt ve şekli seçmenize yardımcı olacaktır.
Önkoşul
İndirmek Aspose.Slides Cloud SDK for Dotnet for inserting hyperlinks
Bir şekle bağlantı eklemek için yukarıdaki SDK ile C# projesini kurun
C# .NET tabanlı API ile PowerPoint’e Bağlantı Ekleme Adımları
- Kimlik doğrulama için API anahtarı ve sırrıyla SlidesApi örneğini oluşturun
- Giriş dosyasını bir bellek akışına okuyun ve yükleyin
- Köprü eklemek için slaytların ve şekillerin dizinlerini ayarlayın (1 tabanlı dizin)
- Köprü içeren bir şekil nesnesi oluşturma
- Update belirtilen slaytta köprü içeren şekil
- Doğrulama için güncellenen köprünün URL’sini konsola yazdırın
- Güncellenen sunumu buluttan akış olarak indirin ve diske kaydedin
Bu adımlarda C# REST API ile PowerPoint’te köprünün nasıl ekleneceği açıklanmaktadır. Eylem türünü ve harici URL’yi tanımlayarak bir Şekil oluşturabilir ve köprü ekleyebilirsiniz. Son olarak, yeni oluşturulan şekli kullanarak istenen slayttaki hedef şekli güncelleyin ve gerekirse çıktıyı diske kaydedin.
C# Düşük Kod API’si ile PowerPoint’e Bağlantı Ekleme Kodu
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. | |
} | |
} | |
} |
Bu kod C# REST Arayüzü ile PowerPoint’te köprünün nasıl ekleneceğini gösterir. Köprüyü etkinleştirmek/devre dışı bırakmak için bayrak, araç ipucu, geçmiş, tıklamayı vurgulama ve tıklama sırasında sesi durdurma gibi köprünün çeşitli özelliklerini ayarlayabilirsiniz. Tüm bu özelliklere, köprüyü tıklatmak yerine üzerine gelindiğinde ulaşılabileceğini unutmayın.
Bu makale bize PowerPoint’te C# Low Code API* ile bir *köprü oluşturmayı öğretti. Slayta SmartArt eklemek için C# REST API ile SmartArt’ı PowerPoint’e ekleyin hakkındaki makaleye bakın.