صورة العلامة المائية في PowerPoint مع C# REST API

ترشدك هذه المقالة حول كيفية إضافة صورة العلامة المائية في PowerPoint باستخدام C# REST API. سوف تتعلم كيفية جعل الصورة علامة مائية في PowerPoint باستخدام واجهة C# REST باستخدام SDK المستند إلى .NET. ستشارك التفاصيل لتخصيص الصورة قبل إضافتها كعلامة مائية إلى العرض التقديمي.

الشرط الأساسي

خطوات إدراج علامة مائية للصورة في PowerPoint باستخدام C# REST API

  1. قم بتهيئة Aspose SlidesApi باستخدام بيانات اعتماد العميل
  2. قم بتحميل ملف العرض التقديمي إلى الخادم باستخدام طريقة UploadFile()
  3. اقرأ بيانات الصورة التي سيتم استخدامها للعلامة المائية في مصفوفة بايت
  4. قم بإعداد إطار الصورة الذي سيحتوي على صورة العلامة المائية باستخدام فئة PictureFrame
  5. أضف الصورة كعلامة مائية إلى العرض التقديمي باستخدام طريقة CreateImageWatermark().
  6. قم بتنزيل العرض التقديمي المعدل مع إضافة العلامة المائية باستخدام طريقة DownloadFile()
  7. احفظ العرض التقديمي المحدث محليًا

تصف هذه الخطوات كيفية جعل الصورة علامة مائية في PowerPoint باستخدام C# RESTful Service. قم بتهيئة كائن SlidesApi، وقم بتحميل العرض التقديمي إلى الخادم، وقراءة صورة العلامة المائية في مصفوفة بايت. قم بإعداد كائن PictureFrame لتعيين معلمات العلامة المائية وإضافتها إلى العرض التقديمي باستخدام طريقة CreateImageWatermark().

رمز لإضافة علامة مائية للصورة في PowerPoint باستخدام واجهة برمجة التطبيقات المستندة إلى C# .NET

using Aspose.Slides.Cloud.Sdk;
using Aspose.Slides.Cloud.Sdk.Model;
using System;
using System.IO;
namespace PresentationProcessor
{
// This class demonstrates how to modify a slide deck by adding an image watermark.
class ModifySlide
{
static void Main(string[] args)
{
// Initialize the Aspose Slides API with client credentials (replace with actual credentials)
var slideService = new SlidesApi("ID", "KEY");
// Define the name of the presentation file to be modified
string inputFileName = "OriginalSlides.pptx";
// Specify the local path of the image that will be used as a watermark
string imagePath = "NewImage.png";
// Upload the presentation file to the server
var uploadResult = slideService.UploadFile(inputFileName, new MemoryStream(File.ReadAllBytes(inputFileName)));
// Read the image data that will be used for the watermark
byte[] imageContent = File.ReadAllBytes(imagePath);
// Set up the image frame that will hold the watermark image
PictureFrame newImageFrame = new PictureFrame
{
X = 50, // Horizontal position of the watermark (from the left)
Y = 50, // Vertical position of the watermark (from the top)
Width = 800, // Width of the watermark image
Height = 450, // Height of the watermark image
PictureFillFormat = new PictureFill
{
Base64Data = Convert.ToBase64String(imageContent), // The image data encoded in base64
PictureFillMode = PictureFill.PictureFillModeEnum.Stretch, // Image will stretch to fit the frame
}
};
// Add the image as a watermark to the presentation
slideService.CreateImageWatermark(inputFileName, null, newImageFrame);
// Download the modified presentation with the watermark added
Stream modifiedFileStream = slideService.DownloadFile(inputFileName);
// Save the updated presentation locally
using (var localFileStream = new FileStream("UpdatedSlideDeck.pptx", FileMode.Create, FileAccess.Write))
{
// Copy the content of the downloaded file stream to the local file stream
modifiedFileStream.CopyTo(localFileStream);
}
}
}
}

يوضح هذا الرمز كيفية جعل الصورة علامة مائية في PowerPoint باستخدام واجهة برمجة التطبيقات المستندة إلى C# .NET. قم بتكوين إطار الصورة لتعيين موضع صورة العلامة المائية من الزاوية العلوية اليسرى وحجمها وتنسيق التعبئة. يمكنك أيضًا تعيين DPI، واقتصاص الصور، وإزاحة البلاط وحجمه، وبيانات SVG.

علمتنا هذه المقالة كيفية وضع علامة مائية على صورة في PowerPoint باستخدام C# Low Code API. لإزالة علامة مائية من عرض تقديمي، راجع المقالة قم بإزالة العلامة المائية من العرض التقديمي باستخدام C# REST API.

 عربي