fn add_image_to_page_stream(
        &mut self,
        xobject_name: &str,
        page_id: ObjectId,
        rect: Rectangle,
    ) -> Result<(), Error> {
        use lopdf::{content::Operation, Object::*};
        let mut content = self.raw_document.get_and_decode_page_content(page_id)?;
        let position = (rect.x1, rect.y1);
        let size = (rect.x2 - rect.x1, rect.y2 - rect.y1);
        // The following lines use commands: see p643 (Table A.1) for more info
        // `q` = Save graphics state
        content.operations.push(Operation::new("q", vec![]));
        // `cm` = Concatenate matrix to current transformation matrix
        content.operations.push(Operation::new(
            "cm",
            vec![
                size.0.into(),
                0i32.into(),
                0i32.into(),
                size.1.into(),
                position.0.into(),
                position.1.into(),
            ],
        ));
        // `Do` = Invoke named XObject
        content.operations.push(Operation::new(
            "Do",
            vec![Name(xobject_name.as_bytes().to_vec())],
        ));
        // `Q` = Restore graphics state
        content.operations.push(Operation::new("Q", vec![]));

        self.raw_document
            .change_page_content(page_id, content.encode()?)?;

        Ok(())
    }
// The image must already be added to the object list!
// Please use `add_image` instead.
The image must already be added to the object list.
Please use `add_image` instead.
The image must already be added to the object list . Please use ` add_image ` instead .
fn add_image_to_page_stream(
        &mut self,
        xobject_name: &str,
        page_id: ObjectId,
        rect: Rectangle,
    ) -> Result<(), Error> {
        use lopdf::{content::Operation, Object::*};
        let mut content = self.raw_document.get_and_decode_page_content(page_id)?;
        let position = (rect.x1, rect.y1);
        let size = (rect.x2 - rect.x1, rect.y2 - rect.y1);
        // The following lines use commands: see p643 (Table A.1) for more info
        // `q` = Save graphics state
        content.operations.push(Operation::new("q", vec![]));
        // `cm` = Concatenate matrix to current transformation matrix
        content.operations.push(Operation::new(
            "cm",
            vec![
                size.0.into(),
                0i32.into(),
                0i32.into(),
                size.1.into(),
                position.0.into(),
                position.1.into(),
            ],
        ));
        // `Do` = Invoke named XObject
        content.operations.push(Operation::new(
            "Do",
            vec![Name(xobject_name.as_bytes().to_vec())],
        ));
        // `Q` = Restore graphics state
        content.operations.push(Operation::new("Q", vec![]));
        self.raw_document
            .change_page_content(page_id, content.encode()?)?;
        Ok(())
    }
fn add_image_to_page_stream ( & mut self , xobject_name : & str , page_id : ObjectId , rect : Rectangle , ) -> Result < ( ) , Error > { use lopdf :: { content :: Operation , Object :: * } ; let mut content = self . raw_document . get_and_decode_page_content ( page_id ) ? ; let position = ( rect . x1 , rect . y1 ) ; let size = ( rect . x2 - rect . x1 , rect . y2 - rect . y1 ) ; // The following lines use commands: see p643 (Table A.1) for more info // `q` = Save graphics state content . operations . push ( Operation :: new ( " " , vec ! [ ] ) ) ; // `cm` = Concatenate matrix to current transformation matrix content . operations . push ( Operation :: new ( " " , vec ! [ size 0 into ( ) 0i32 into ( ) 0i32 into ( ) size 1 into ( ) position 0 into ( ) position 1 into ( ) ] , ) ) ; // `Do` = Invoke named XObject content . operations . push ( Operation :: new ( " " , vec ! [ Name ( xobject_name as_bytes ( ) to_vec ( ) ) ] , ) ) ; // `Q` = Restore graphics state content . operations . push ( Operation :: new ( " " , vec ! [ ] ) ) ; self . raw_document . change_page_content ( page_id , content . encode ( ) ? ) ? ; Ok ( ( ) ) }
The image must already be added to the object list!
The image must already be added to the object list!
&mut self
xobject_name
&str
page_id
ObjectId
rect
Rectangle