summaryrefslogtreecommitdiff
path: root/examples/cli.rs
blob: 7e5e6db6b6962d37ea084088bfe034894e6f0906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use wasm_card::model::property_groups::address::Address;
use wasm_card::model::property_groups::name::Name;
use wasm_card::model::property_groups::telephone::Telephone;
use wasm_card::model::vcard;

fn main() {
    let mut data = vcard::VCardData::new();
    data.add_name(Name {
        first_name: "John".to_owned(),
        last_name: "Doe".to_owned(),
        ..Default::default()
    });
    data.add_telephone(Telephone {
        number: "+49 123 45678".to_owned(),
        cell: true,
        ..Default::default()
    });
    data.add_address(Address {
        street: "Musterweg 1".to_owned(),
        code: "12345".to_owned(),
        locality: "Musterhausen".to_owned(),
        country: "Germany".to_owned(),
        ..Default::default()
    });

    let pdf = data.generate_pdf().expect("Failed to generate PDF");
    std::fs::write("output.pdf", &pdf).expect("Failed to write PDF file");
}