Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot convert from primitive to type Catalog #17

Closed
hahnrobert opened this issue May 26, 2019 · 1 comment
Closed

Cannot convert from primitive to type Catalog #17

hahnrobert opened this issue May 26, 2019 · 1 comment

Comments

@hahnrobert
Copy link

hahnrobert commented May 26, 2019

This PDF causes the following error when trying to load the pdf via:
let _file = pdf::file::File::<Vec<u8>>::open("test.pdf")?;

Error: Error(Msg("Key Root: cannot convert from primitive to type Catalog"), State { next_error: Some(Error(Msg("Key Pages: cannot convert from primitive to type PageTree"), State { next_error: Some(Error(Msg("Key Kids: cannot convert from primitive to type Vec < PagesNode >"), State { next_error: Some(Error(Msg("Key Resources: cannot convert from primitive to type Option < Resources >"), State { next_error: Some(Error(Msg("Key XObject: cannot convert from primitive to type Option < BTreeMap < String , XObject > >"), State { next_error: Some(Error(EntryNotFound { key: "Type" }, State { next_error: None, backtrace: Some(stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized::hee1893eb5da7e7a9 (0x10e8a070c)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.26/src/backtrace/mod.rs:66
   1: backtrace::backtrace::trace::hca6b1efc3d61f6e3 (0x10e8a0692)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.26/src/backtrace/mod.rs:53
   2: backtrace::capture::Backtrace::create::hd47ce747c1184538 (0x10e898896)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.26/src/capture.rs:163
   3: backtrace::capture::Backtrace::new::h2c9cb6b3d23b2b00 (0x10e8987d4)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.26/src/capture.rs:126
   4: error_chain::make_backtrace::h2587ae8cf04d98e7 (0x10e74a3f1)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.11.0/src/lib.rs:616
   5: <error_chain::State as core::default::Default>::default::h6aba5dc07456c848 (0x10e74a45f)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.11.0/src/lib.rs:710
   6: pdf::err::Error::from_kind::hcf862d3fafe4c047 (0x10e6d1bb0)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/<::error_chain::error_chain::impl_error_chain_processed macros>:53
   7: <pdf::err::Error as core::convert::From<pdf::err::ErrorKind>>::from::hb3577d866bd2cdae (0x10e6d4977)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/<::error_chain::error_chain::impl_error_chain_processed macros>:98
   8: <pdf::object::types::XObject as pdf::object::Object>::from_primitive::h7b8c25308f2940a5 (0x10e62f63e)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/types.rs:210
   9: <alloc::collections::btree::map::BTreeMap<alloc::string::String, V> as pdf::object::Object>::from_primitive::h7ecb996880b2bfbf (0x10e66abea)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/mod.rs:236
  10: <alloc::collections::btree::map::BTreeMap<alloc::string::String, V> as pdf::object::Object>::from_primitive::h7ecb996880b2bfbf (0x10e66af4a)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/mod.rs:240
  11: pdf::primitive::<impl pdf::object::Object for core::option::Option<T>>::from_primitive::h732f52252c607dd5 (0x10e6911e6)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/primitive.rs:326
  12: <pdf::object::types::Resources as pdf::object::Object>::from_primitive::hd45eab241d4dec61 (0x10e63b059)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/types.rs:135
  13: pdf::primitive::<impl pdf::object::Object for core::option::Option<T>>::from_primitive::hd977042959c5f6cf (0x10e692483)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/primitive.rs:326
  14: <pdf::object::types::Page as pdf::object::Object>::from_primitive::h335ba1f03f02c092 (0x10e638093)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/types.rs:89
  15: <pdf::object::types::PagesNode as pdf::object::Object>::from_primitive::h24811c69acca4443 (0x10e62e1f1)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/types.rs:25
  16: <alloc::vec::Vec<T> as pdf::object::Object>::from_primitive::{{closure}}::hedb9a02a32628cda (0x10e6c860c)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/mod.rs:195
  17: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once::h149d4c1aea1a0351 (0x10e6bebb0)
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/ops/function.rs:279
  18: <core::option::Option<T>>::map::h4a7723266d769797 (0x10e689b9d)
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/option.rs:414
  19: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next::h51bfd912e8d5e7ef (0x10e6dc36e)
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/mod.rs:1428
  20: <<core::result::Result<V, E> as core::iter::traits::FromIterator<core::result::Result<A, E>>>::from_iter::Adapter<Iter, E> as core::iter::iterator::Iterator>::next::h5b9a342e2ed9f8a2 (0x10e6e2e58)
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/result.rs:1220
  21: <&mut I as core::iter::iterator::Iterator>::next::h58363be6b4480122 (0x10e6eb68e)
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/iterator.rs:2644
  22: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter::hf2babf0635f53d93 (0x10e6b89bb)
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/liballoc/vec.rs:1813
  23: <alloc::vec::Vec<T> as core::iter::traits::FromIterator<T>>::from_iter::hf1c3f6cdad026dbf (0x10e6b8f23)
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/liballoc/vec.rs:1725
  24: <core::result::Result<V, E> as core::iter::traits::FromIterator<core::result::Result<A, E>>>::from_iter::hf5fae6ddabd204a1 (0x10e6e25d0)
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/result.rs:1237
  25: core::iter::iterator::Iterator::collect::h3e0eb7698cf25103 (0x10e6db147)
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/iterator.rs:1468
  26: <alloc::vec::Vec<T> as pdf::object::Object>::from_primitive::hd6bcee64ade5112c (0x10e6bbdec)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/mod.rs:193
  27: <pdf::object::types::PageTree as pdf::object::Object>::from_primitive::h962ee7a4c4cc6534 (0x10e635e23)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/types.rs:69
  28: <pdf::object::types::Catalog as pdf::object::Object>::from_primitive::h76a04b5e422d45fc (0x10e633969)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/object/types.rs:34
  29: <pdf::file::Trailer as pdf::object::Object>::from_primitive::h1df45626e88e653a (0x10e6cd14b)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/file.rs:252
  30: <pdf::file::File<B>>::open::h40b1658bb78a8ab7 (0x10e6211da)
             at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/pdf-0.6.3/src/file.rs:142
@Ploppz
Copy link
Member

Ploppz commented Jun 1, 2019

Thanks, I found the bug. The reference says that /Type in XObject is optional. Fixed in latest master.

@Ploppz Ploppz closed this as completed Jun 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants