این راهنما را در مورد نحوه افزودن هایپرلینک به PowerPoint با C# REST API دنبال کنید. شما یاد خواهید گرفت که به طور خودکار درج هایپرلینک در پاورپوینت با C# RESTful Service با استفاده از یک Cloud SDK مبتنی بر NET که از تمام ویژگی های پیشرفته برای کار با ارائه ها پشتیبانی می کند. این به شما در انتخاب یک اسلاید و شکل خاص برای افزودن یک لینک سفارشی کمک می کند.
پیش نیاز
دانلود کنید Aspose.Slides Cloud SDK for Dotnet for inserting hyperlinks
پروژه C# را با SDK بالا راه اندازی کنید تا پیوندی به یک شکل اضافه کنید
مراحل افزودن پیوند به پاورپوینت با C#.NET-based API
- SlidesApi را با کلید API و راز برای احراز هویت نمونه سازی کنید
- فایل ورودی را در یک جریان حافظه بخوانید و آن را آپلود کنید
- تنظیم نمایههای اسلایدها و اشکال برای افزودن لینک (شاخص مبتنی بر 1)
- یک شی شکل با یک لینک ایجاد کنید
- Update شکل موجود در اسلاید مشخص شده با پیوند
- برای تأیید، URL هایپرلینک به روز شده را در کنسول چاپ کنید
- ارائه به روز شده را از ابر به صورت جریانی دانلود کنید و آن را روی دیسک ذخیره کنید
این مراحل چگونگی افزودن هایپرلینک در پاورپوینت با C# REST API را توضیح می دهد. شما می توانید با تعریف نوع عمل و URL خارجی، یک شکل ایجاد کنید و یک لینک اضافه کنید. در نهایت با استفاده از شکل جدید ایجاد شده، شکل هدف را در اسلاید مورد نظر به روز کنید و در صورت نیاز خروجی را روی دیسک ذخیره کنید.
کد برای درج لینک در پاورپوینت با C# Low Code API
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 را نشان می دهد. شما می توانید ویژگی های مختلف یک هایپرلینک مانند یک پرچم را برای فعال/غیرفعال کردن هایپرلینک، راهنمای ابزار، تاریخچه، برجسته کردن کلیک و توقف صدا در هنگام کلیک تنظیم کنید. توجه داشته باشید که همه این ویژگی ها با نگه داشتن ماوس روی لینک به جای کلیک کردن روی آن در دسترس هستند.
این مقاله به ما آموزش ایجاد هایپرلینک در پاورپوینت با C# Low Code API را داده است. برای افزودن SmartArt در یک اسلاید، به مقاله در SmartArt را با C# REST API به پاورپوینت اضافه کنید مراجعه کنید.