Back to Devexpress

PdfPageFacade.AddRubberStampAnnotation(PdfRectangle, Stream, Int32, Boolean) Method

officefileapi-devexpress-dot-pdf-dot-pdfpagefacade-dot-addrubberstampannotation-x28-devexpress-dot-pdf-dot-pdfrectangle-system-dot-io-dot-stream-system-dot-int32-system-dot-boolean-x29.md

latest4.0 KB
Original Source

PdfPageFacade.AddRubberStampAnnotation(PdfRectangle, Stream, Int32, Boolean) Method

Creates a rubber stamp annotation in the specified page rectangle.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfRubberStampAnnotationFacade AddRubberStampAnnotation(
    PdfRectangle rect,
    Stream pdfStream,
    int pageNumber,
    bool keepAspectRatio
)
vb
Public Function AddRubberStampAnnotation(
    rect As PdfRectangle,
    pdfStream As Stream,
    pageNumber As Integer,
    keepAspectRatio As Boolean
) As PdfRubberStampAnnotationFacade

Parameters

NameTypeDescription
rectPdfRectangle

A page area to add the rubber stamp annotation.

| | pdfStream | Stream |

A stream that contains a document used to generate a stamp.

| | pageNumber | Int32 |

The number of the document page (starting with 1) used to generate a stamp.

| | keepAspectRatio | Boolean |

true to make the stamp aspect ratio fit the specified rectangle; otherwise, false.

|

Returns

TypeDescription
PdfRubberStampAnnotationFacade

An object that contains rubber stamp annotation properties.

|

Remarks

The following code snippet uses another PDF document to generate a custom stamp:

csharp
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access the first page properties
    PdfDocumentFacade facade = processor.DocumentFacade;
    PdfPageFacade page = facade.Pages[0];

    // Define a rubber stamp rectangle
    PdfRectangle rubberStampRectangle = new PdfRectangle(663, 526, 763, 576);

    string customStampFile = "..\\..\\Demo.pdf";
    using (FileStream fileStream = new FileStream(customStampFile, FileMode.Open, FileAccess.Read))
    {
        // Create a rubber stamp annotation
        PdfRubberStampAnnotationFacade rubberStamp =
            page.AddRubberStampAnnotation(rubberStampRectangle, fileStream, 2, true);
        rubberStamp.Author = "Jesse Faden";
    }

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}
vb
Using processor As New PdfDocumentProcessor()
    ' Load a document
    processor.LoadDocument("..\..\Document.pdf")

    ' Access the first page properties
    Dim facade As PdfDocumentFacade = processor.DocumentFacade
    Dim page As PdfPageFacade = facade.Pages(0)

    ' Define a rubber stamp rectangle
    Dim rubberStampRectangle As New PdfRectangle(663, 526, 763, 576)

    Dim customStampFile As String = "..\..\Demo.pdf"
    Using fileStream As New FileStream(customStampFile, FileMode.Open, FileAccess.Read)

      ' Create a rubber stamp annotation
      Dim rubberStamp As PdfRubberStampAnnotationFacade =
        page.AddRubberStampAnnotation(rubberStampRectangle, fileStream, 2, True)
      rubberStamp.Author = "Jesse Faden"
    End Using

    ' Save the result
    processor.SaveDocument("..\..\Result.pdf")
  End Using

See Also

PdfPageFacade Class

PdfPageFacade Members

DevExpress.Pdf Namespace