Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Класс Stamp позволяет добавлять водяной знак в PDF-файл. Вы можете указать изображение, которое будет добавлено в качестве штампа, с помощью метода BindImage. Метод SetOrigin позволяет установить начало добавленного штампа; это начало координат — координаты нижнего левого угла штампа. Вы также можете задать размер изображения с помощью метода SetImageSize.
Теперь мы видим, как штамп можно повернуть относительно центра штампа. Класс Stamp предоставляет свойство с именем Rotation. Это свойство устанавливает или получает поворот от 0 до 360 содержимого штампа. Мы можем указать любое значение поворота от 0 до 360. Указав значение поворота, мы можем повернуть штамп относительно его центра. Если Stamp является объектом типа Stamp, то значение поворота можно указать как aStamp.Rotation = 90. В этом случае штамп будет повёрнут на 90 градусов относительно центра содержимого штампа. Следующий фрагмент кода показывает, как повернуть штамп относительно центральной точки:
// 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 aStamp = new Aspose.Pdf.Facades.Stamp();
// Bind image file with the Stamp object
aStamp.BindImage(dataDir + "RotatingStamp.jpg");
// Specify whether the stamp will be added as a background or not
aStamp.IsBackground = false;
// Specifies at which pages to add the watermark
aStamp.Pages = new int[] { 1 };
// Specifies the watermark rotation - rotate at 90 degrees
aStamp.Rotation = 90;
// Specifies the position of stamp - lower left corner of the stamp
aStamp.SetOrigin(fileInfo.GetPageWidth(1) / 2, fileInfo.GetPageHeight(1) / 2);
// Set the size of the watermark
aStamp.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(aStamp);
}
}
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.