Bu makalede C# REST API ile PowerPoint‘a Filigran Resminin nasıl ekleneceği anlatılmaktadır. .NET tabanlı bir SDK kullanarak C# REST Arayüzü ile PowerPoint’te bir fotoğrafa nasıl filigran yapılacağını öğreneceksiniz. Resmi filigran olarak sunuma eklemeden önce özelleştirmeye yönelik ayrıntıları paylaşacaktır.
Önkoşul
İndirmek Aspose.Slides Cloud SDK for Dotnet to add an image watermark
Resim filigranı eklemek için yukarıdaki SDK ile C# projesini kurun
C# REST API ile PowerPoint’e Görüntü Filigranı Ekleme Adımları
- Aspose SlidesApi‘yi istemci kimlik bilgileriyle başlatın
- Sunum dosyasını UploadFile() yöntemini kullanarak sunucuya yükleyin
- Filigran için kullanılacak görüntü verilerini bir bayt dizisine okuyun
- PictureFrame sınıfını kullanarak filigran görüntüsünü tutacak görüntü çerçevesini ayarlayın
- CreateImageWatermark() yöntemini kullanarak görüntüyü filigran olarak sunuya ekleyin
- DownloadFile() yöntemiyle eklenen filigranı içeren değiştirilmiş sunumu indirin
- Güncellenen sunuyu yerel olarak kaydedin
Bu adımlarda C# RESTful Service ile PowerPoint’te bir resmin nasıl filigran oluşturulacağı açıklanmaktadır. SlidesApi nesnesini başlatın, sunumu sunucuya yükleyin ve filigran görüntüsünü bir bayt dizisine okuyun. Filigran parametrelerini ayarlamak ve CreateImageWatermark() yöntemini kullanarak sunuma eklemek için PictureFrame nesnesini ayarlayın.
C# .NET tabanlı API ile PowerPoint’te Görüntü Filigranı Ekleme Kodu
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); | |
} | |
} | |
} | |
} |
Bu kod C# .NET tabanlı API ile PowerPoint’te bir görüntünün nasıl filigran oluşturulacağını gösterir. Filigran görüntüsünün sol üst köşedeki konumunu, boyutunu ve dolgu biçimini ayarlamak için resim çerçevesini yapılandırın. Ayrıca DPI’yi, resimleri kırpın, döşeme ofsetini ve ölçeğini ve SVG verilerini de ayarlayabilirsiniz.
Bu makale bize C# Low Code API ile PowerPoint’te bir görsele nasıl filigran ekleyeceğimizi öğretti. Bir sunudan filigranı kaldırmak için C# REST API ile Filigranı Sunumdan Kaldırma makalesine bakın.