Ez a cikk útmutatást nyújt a Watermark Picture hozzáadásához a PowerPoint alkalmazásban a C# REST API-val. Megtanulja, hogyan készíthet vízjelet egy fényképből a PowerPoint programban C# REST felülettel .NET-alapú SDK használatával. Megosztja a részleteket a kép testreszabásához, mielőtt vízjelként hozzáadná a prezentációhoz.
Előfeltétel
Letöltés Aspose.Slides Cloud SDK for Dotnet to add an image watermark
Állítsa be a C# projektet a fenti SDK-val képvízjel beillesztéséhez
Képes vízjel beszúrásának lépései a PowerPointba a C# REST API segítségével
- Inicializálja az Aspose SlidesApi-t az ügyfél hitelesítő adataival
- Töltse fel a bemutató fájlt a szerverre az UploadFile() metódussal
- Olvassa be a vízjelhez használt képadatokat egy bájttömbbe
- Állítsa be a képkeretet, amely a vízjel képet fogja tárolni a PictureFrame osztály segítségével
- Adja hozzá a képet vízjelként a prezentációhoz a CreateImageWatermark() módszerrel
- Töltse le a módosított bemutatót a DownloadFile() metódussal hozzáadott vízjellel
- Mentse el a frissített prezentációt helyileg
Ezek a lépések azt írják le, hogyan lehet egy képet vízjelvé tenni a PowerPointban a C# RESTful Service segítségével. Inicializálja a SlidesApi objektumot, töltse fel a prezentációt a szerverre, és olvassa be a vízjelképet egy bájttömbbe. Állítsa be a PictureFrame objektumot a vízjel paramétereinek beállításához, és adja hozzá a bemutatóhoz a CreateImageWatermark() metódussal.
Kód vízjel hozzáadásához a PowerPointban C# .NET-alapú API-val
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); | |
} | |
} | |
} | |
} |
Ez a kód bemutatja, hogyan lehet egy képet vízjelvé tenni a PowerPointban C# .NET-alapú API-val. Állítsa be a képkeretet úgy, hogy a vízjel kép helyzetét a bal felső sarokban, méretét és kitöltési formátumát állítsa be. Ezenkívül beállíthatja a DPI-t, kivághatja a képeket, a mozaik eltolását és méretezését, valamint az SVG-adatokat.
Ez a cikk megtanított minket hogyan lehet vízjelet tenni a PowerPointban a C# Low Code API-val. A vízjel prezentációból való eltávolításához olvassa el a(z) {{HIPERLINK1}} cikket.