Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
La classe Stamp vous permet d’ajouter un filigrane dans un fichier PDF. Vous pouvez spécifier l’image à ajouter en tant que tampon en utilisant la méthode BindImage. La méthode SetOrigin vous permet de définir l’origine du tampon ajouté ; cette origine est les coordonnées inférieures gauche du tampon. Vous pouvez également définir la taille de l’image en utilisant la méthode SetImageSize.
Maintenant, nous allons voir comment le tampon peut être tourné autour du centre du tampon. La classe Stamp fournit une propriété nommée Rotation. Cette propriété définit ou obtient la rotation de 0 à 360 du contenu du tampon. Nous pouvons spécifier n’importe quelle valeur de rotation de 0 à 360. En spécifiant la valeur de rotation, nous pouvons faire pivoter le tampon autour de son point central. Si un tampon est un objet de type Stamp, alors la valeur de rotation peut être spécifiée comme stamp.Rotation = 90. Dans ce cas, le tampon sera tourné à 90 degrés autour du centre du contenu du tampon. Le code suivant vous montre comment faire pivoter le tampon autour du point central.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddRotatingStampToPdf()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create PdfFileInfo object to get height and width of the pages
using (var fileInfo = new Aspose.Pdf.Facades.PdfFileInfo(dataDir + "RotatingStamp.pdf"))
{
// Create Stamp object
var stamp = new Aspose.Pdf.Facades.Stamp();
// Bind image file with the Stamp object
stamp.BindImage(dataDir + "RotatingStamp.jpg");
// Specify whether the stamp will be added as a background or not
stamp.IsBackground = false;
// Specifies at which pages to add the watermark
stamp.Pages = new int[] { 1 };
// Specifies the watermark rotation - rotate at 90 degrees
stamp.Rotation = 90;
// Specifies the position of stamp - lower left corner of the stamp
stamp.SetOrigin(fileInfo.GetPageWidth(1) / 2, fileInfo.GetPageHeight(1) / 2);
// Set the size of the watermark
stamp.SetImageSize(100, 100);
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "RotatingStamp_out.pdf"))
{
// Create PdfFileStamp class to bind input and output files
using (var stamper = new Aspose.Pdf.Facades.PdfFileStamp(document))
{
// Add the stamp in the PDF file
stamper.AddStamp(stamp);
}
}
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.