यह आलेख C# REST API** के साथ PowerPoint में **वॉटरमार्क चित्र कैसे जोड़ें, इस पर मार्गदर्शन करता है। आप .NET-आधारित SDK का उपयोग करके C# REST इंटरफ़ेस के साथ PowerPoint में किसी फ़ोटो को वॉटरमार्क कैसे बनाएं सीखेंगे। यह प्रस्तुति में वॉटरमार्क के रूप में जोड़ने से पहले चित्र को अनुकूलित करने के लिए विवरण साझा करेगा।
पूर्वावश्यकता
डाउनलोड करना Aspose.Slides Cloud SDK for Dotnet to add an image watermark
चित्र वॉटरमार्क डालने के लिए उपरोक्त एसडीके के साथ सी# प्रोजेक्ट सेटअप करें
C# REST API के साथ PowerPoint में इमेज वॉटरमार्क डालने के चरण
- क्लाइंट क्रेडेंशियल्स के साथ Aspose SlidesApi को प्रारंभ करें
- अपलोडफ़ाइल() विधि का उपयोग करके प्रस्तुति फ़ाइल को सर्वर पर अपलोड करें
- वॉटरमार्क के लिए उपयोग किए जाने वाले छवि डेटा को बाइट सरणी में पढ़ें
- पिक्चरफ़्रेम वर्ग का उपयोग करके छवि फ़्रेम सेट करें जो वॉटरमार्क छवि को धारण करेगा
- CreateImageWatermark() विधि का उपयोग करके छवि को प्रस्तुतिकरण में वॉटरमार्क के रूप में जोड़ें
- डाउनलोडफ़ाइल() विधि से जोड़े गए वॉटरमार्क के साथ संशोधित प्रस्तुति डाउनलोड करें
- अद्यतन प्रस्तुति को स्थानीय रूप से सहेजें
ये चरण वर्णन करते हैं C# RESTful Service के साथ PowerPoint में किसी चित्र को वॉटरमार्क कैसे बनाएं। SlidesApi ऑब्जेक्ट को प्रारंभ करें, प्रेजेंटेशन को सर्वर पर अपलोड करें, और वॉटरमार्क छवि को बाइट सरणी में पढ़ें। वॉटरमार्क पैरामीटर सेट करने के लिए पिक्चरफ़्रेम ऑब्जेक्ट सेट करें और इसे CreateImageWatermark() विधि का उपयोग करके प्रस्तुति में जोड़ें।
C# .NET-आधारित API के साथ PowerPoint में छवि वॉटरमार्क जोड़ने के लिए कोड
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); | |
} | |
} | |
} | |
} |
यह कोड दर्शाता है कि C# .NET-आधारित API के साथ PowerPoint में किसी छवि को वॉटरमार्क कैसे बनाया जाए। ऊपरी-बाएँ कोने से वॉटरमार्क छवि की स्थिति, उसका आकार और भरण प्रारूप सेट करने के लिए चित्र फ़्रेम को कॉन्फ़िगर करें। आप डीपीआई, क्रॉप पिक्चर्स, टाइल ऑफसेट और स्केल और एसवीजी डेटा भी सेट कर सकते हैं।
इस लेख ने हमें सिखाया है कि C# लो कोड एपीआई के साथ PowerPoint में किसी छवि को वॉटरमार्क कैसे करें। किसी प्रेजेंटेशन से वॉटरमार्क हटाने के लिए, लेख C# REST API के साथ प्रेजेंटेशन से वॉटरमार्क हटाएं देखें।