pub fn create_document() -> Document {
        let mut doc = Document::with_version("1.5");
        let info_id = doc.add_object(dictionary! {
            "Title" => Object::string_literal("Create PDF document example"),
            "Creator" => Object::string_literal("https://crates.io/crates/lopdf"),
            "CreationDate" => time::OffsetDateTime::now_utc(),
        });
        let pages_id = doc.new_object_id();
        let font_id = doc.add_object(dictionary! {
            "Type" => "Font",
            "Subtype" => "Type1",
            "BaseFont" => "Courier",
        });
        let resources_id = doc.add_object(dictionary! {
            "Font" => dictionary! {
                "F1" => font_id,
            },
        });
        let content = Content {
            operations: vec![
                Operation::new("BT", vec![]),
                Operation::new("Tf", vec!["F1".into(), 48.into()]),
                Operation::new("Td", vec![100.into(), 600.into()]),
                Operation::new("Tj", vec![Object::string_literal("Hello World!")]),
                Operation::new("ET", vec![]),
            ],
        };
        let content_id = doc.add_object(Stream::new(dictionary! {}, content.encode().unwrap()));
        let page_id = doc.add_object(dictionary! {
            "Type" => "Page",
            "Parent" => pages_id,
            "Contents" => content_id,
        });
        let pages = dictionary! {
            "Type" => "Pages",
            "Kids" => vec![page_id.into()],
            "Count" => 1,
            "Resources" => resources_id,
            "MediaBox" => vec![0.into(), 0.into(), 595.into(), 842.into()],
        };
        doc.objects.insert(pages_id, Object::Dictionary(pages));
        let catalog_id = doc.add_object(dictionary! {
            "Type" => "Catalog",
            "Pages" => pages_id,
        });
        doc.trailer.set("Root", catalog_id);
        doc.trailer.set("Info", info_id);
        doc.compress();

        doc
    }
/// Create and return a document for testing
Create and return a document for testing
Create and return a document for testing
pub fn create_document() -> Document {
        let mut doc = Document::with_version("1.5");
        let info_id = doc.add_object(dictionary! {
            "Title" => Object::string_literal("Create PDF document example"),
            "Creator" => Object::string_literal("https://crates.io/crates/lopdf"),
            "CreationDate" => time::OffsetDateTime::now_utc(),
        });
        let pages_id = doc.new_object_id();
        let font_id = doc.add_object(dictionary! {
            "Type" => "Font",
            "Subtype" => "Type1",
            "BaseFont" => "Courier",
        });
        let resources_id = doc.add_object(dictionary! {
            "Font" => dictionary! {
                "F1" => font_id,
            },
        });
        let content = Content {
            operations: vec![
                Operation::new("BT", vec![]),
                Operation::new("Tf", vec!["F1".into(), 48.into()]),
                Operation::new("Td", vec![100.into(), 600.into()]),
                Operation::new("Tj", vec![Object::string_literal("Hello World!")]),
                Operation::new("ET", vec![]),
            ],
        };
        let content_id = doc.add_object(Stream::new(dictionary! {}, content.encode().unwrap()));
        let page_id = doc.add_object(dictionary! {
            "Type" => "Page",
            "Parent" => pages_id,
            "Contents" => content_id,
        });
        let pages = dictionary! {
            "Type" => "Pages",
            "Kids" => vec![page_id.into()],
            "Count" => 1,
            "Resources" => resources_id,
            "MediaBox" => vec![0.into(), 0.into(), 595.into(), 842.into()],
        };
        doc.objects.insert(pages_id, Object::Dictionary(pages));
        let catalog_id = doc.add_object(dictionary! {
            "Type" => "Catalog",
            "Pages" => pages_id,
        });
        doc.trailer.set("Root", catalog_id);
        doc.trailer.set("Info", info_id);
        doc.compress();
        doc
    }
pub fn create_document ( ) -> Document { let mut doc = Document :: with_version ( " " ) ; let info_id = doc . add_object ( dictionary ! { " " Object string_literal ( " " ) " " Object string_literal ( " " ) " " time OffsetDateTime now_utc ( ) } ) ; let pages_id = doc . new_object_id ( ) ; let font_id = doc . add_object ( dictionary ! { " " " " " " " " " " " " } ) ; let resources_id = doc . add_object ( dictionary ! { " " dictionary { " " font_id } } ) ; let content = Content { operations : vec ! [ Operation new ( " " vec [ ] ) Operation new ( " " vec [ " " into ( ) 48 into ( ) ] ) Operation new ( " " vec [ 100 into ( ) 600 into ( ) ] ) Operation new ( " " vec [ Object string_literal ( " " ) ] ) Operation new ( " " vec [ ] ) ] , } ; let content_id = doc . add_object ( Stream :: new ( dictionary ! { } , content . encode ( ) . unwrap ( ) ) ) ; let page_id = doc . add_object ( dictionary ! { " " " " " " pages_id " " content_id } ) ; let pages = dictionary ! { " " " " " " vec [ page_id into ( ) ] " " 1 " " resources_id " " vec [ 0 into ( ) 0 into ( ) 595 into ( ) 842 into ( ) ] } ; doc . objects . insert ( pages_id , Object :: Dictionary ( pages ) ) ; let catalog_id = doc . add_object ( dictionary ! { " " " " " " pages_id } ) ; doc . trailer . set ( " " , catalog_id ) ; doc . trailer . set ( " " , info_id ) ; doc . compress ( ) ; doc }
Create and return a document for testing
Create and return a document for testing