اتبع هذا الدليل حول كيفية إضافة رابط تشعبي إلى PowerPoint باستخدام C# REST API. سوف تتعلم كيفية إدراج الارتباط التشعبي تلقائيًا في PowerPoint باستخدام C# RESTful Service باستخدام Cloud SDK المستند إلى .NET والذي يدعم جميع الميزات المتقدمة للعمل مع العروض التقديمية. سيساعدك ذلك في تحديد شريحة وشكل معين لإضافة ارتباط تشعبي مخصص.
** المتطلب السابق **
تحميل Aspose.Slides Cloud SDK for Dotnet for inserting hyperlinks
إعداد مشروع C# باستخدام SDK أعلاه لإضافة رابط إلى الشكل
خطوات إضافة رابط إلى PowerPoint باستخدام واجهة برمجة التطبيقات المستندة إلى C# .NET
- قم بإنشاء مثيل SlidesApi باستخدام مفتاح API وسر المصادقة
- اقرأ ملف الإدخال في دفق الذاكرة وقم بتحميله
- تعيين فهارس الشرائح والأشكال لإضافة ارتباط تشعبي (فهرس يعتمد على 1)
- إنشاء كائن شكل مع ارتباط تشعبي
- Update الشكل الموجود على الشريحة المحددة مع الارتباط التشعبي
- قم بطباعة عنوان URL للارتباط التشعبي المحدث إلى وحدة التحكم للتحقق منه
- قم بتنزيل العرض التقديمي المحدث من السحابة كدفق واحفظه على القرص
تشرح هذه الخطوات كيفية إضافة ارتباط تشعبي في PowerPoint باستخدام C# REST API. يمكنك إنشاء شكل وإضافة ارتباط تشعبي عن طريق تحديد نوع الإجراء وعنوان URL الخارجي. وأخيرًا، قم بتحديث الشكل المستهدف في الشريحة المطلوبة باستخدام الشكل الذي تم إنشاؤه حديثًا واحفظ المخرجات على القرص إذا لزم الأمر.
رمز لإدراج رابط في PowerPoint باستخدام 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. | |
} | |
} | |
} |
يوضح هذا الرمز كيفية إدراج ارتباط تشعبي في PowerPoint باستخدام واجهة C# REST. يمكنك تعيين خصائص مختلفة للارتباط التشعبي مثل علامة لتمكين/تعطيل الارتباط التشعبي وتلميح الأدوات والمحفوظات والنقر المميز وإيقاف الصوت عند النقر. لاحظ أن كافة هذه الخصائص متوفرة عن طريق المرور فوق الارتباط التشعبي بدلاً من النقر فوقه.
علمتنا هذه المقالة كيفية إنشاء ارتباط تشعبي في PowerPoint باستخدام C# Low Code API. لإضافة SmartArt في شريحة، راجع المقالة الموجودة على أضف SmartArt إلى PowerPoint باستخدام C# REST API.