page_add_stamp
Adds stamp on page.
pub fn page_add_stamp(
&self,
num: i32,
alternative_text: &str,
image_data: &[u8],
is_background: bool,
x_indent: i32,
y_indent: i32,
height: i32,
width: i32,
rotation: Rotation,
opacity: f64,
) -> Result<(), PdfError>
Arguments
- num - the page number (1-based)
- alternative_text - the alternative stamp text
- image_data - the raw bytes of the image
- is_background - the stamp is background
- x_indent - the x indent of the stamp
- y_indent - the y indent of the stamp
- height - the height of the stamp
- width - the width of the stamp
- rotation - rotation angle as enum
Rotation:None,On90,On180,On270, orOn360 - opacity - the opacity (decimal)
Returns
- Ok(()) - if the operation succeeds
- Err(PdfError) - if the operation fails
Example
use asposepdf::{Document, Rotation};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Open a PDF-document with filename
let pdf = Document::open("sample.pdf")?;
// Load stamp image data
let image_data = std::fs::read("stamp.png")?;
// Add a stamp on page #1
pdf.page_add_stamp(
1,
"PageStamp",
&image_data,
true,
100,
100,
50,
50,
Rotation::On90,
0.5,
)?;
// Save the previously opened PDF-document with new filename
pdf.save_as("sample_page_add_stamp.pdf")?;
Ok(())
}