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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#![feature(attr_literals)]
#![recursion_limit="128"]
//#![feature(collections_range)]
//#![feature(slice_get_slice)]
#![allow(non_camel_case_types)]  /* TODO temporary becaues of pdf_derive */
#[macro_use]
extern crate pdf_derive;
#[macro_use]
extern crate error_chain;
extern crate num_traits;
extern crate inflate;
extern crate ansi_term;
extern crate byteorder;
extern crate itertools;
extern crate ordermap;
extern crate memmap;
extern crate encoding;
extern crate tuple;

#[macro_use]
mod macros;
pub mod parser;
pub mod object;
pub mod types;
pub mod xref;
pub mod primitive;
pub mod stream;
pub mod file;
pub mod backend;

mod err;
// mod content;
mod enc;

// pub use content::*;
pub use err::*;

// hack to use ::pdf::object::Object in the derive
mod pdf {
    pub use super::*;
}

/// Prints the error if it is an Error
pub fn print_err<T>(err: Error) -> T {
    println!("\n === \nError: {}", err);
    for e in err.iter().skip(1) {
        println!("  caused by: {}", e);
    }
    println!(" === \n");

    if let Some(backtrace) = err.backtrace() {
        println!("backtrace: {:?}", backtrace);
    }

    println!(" === \n");
    panic!("Exiting");
}